Skip to content

Commit 1decd36

Browse files
committed
fix up specs for 3.x
1 parent b12bc4d commit 1decd36

File tree

4 files changed

+23
-34
lines changed

4 files changed

+23
-34
lines changed

spec/integrations_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
describe("Integration Tests") do
44
it "writes the redirect pages for collection items which are outputted" do
5-
expect(@dest.join("articles", "redirect-me-plz.html")).to exist
6-
expect(@dest.join("articles", "23128432159832", "mary-had-a-little-lamb")).to exist
5+
expect(dest_dir("articles", "redirect-me-plz.html")).to exist
6+
expect(dest_dir("articles", "23128432159832", "mary-had-a-little-lamb.html")).to exist
77
end
88

99
it "doesn't write redirect pages for collection items which are not outputted" do
10-
expect(@dest.join("authors")).not_to exist
11-
expect(@dest.join("kansaichris")).not_to exist
10+
expect(dest_dir("authors")).not_to exist
11+
expect(dest_dir("kansaichris")).not_to exist
1212
end
1313
end

spec/jekyll_redirect_from/redirect_page_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
let(:redirect_page) { new_redirect_page(permalink_dir) }
3737

3838
it "knows to add the index.html if it's a folder" do
39-
dest = dest_dir("/posts/1914798137981389/larry-had-a-little-lamb/index.html")
39+
dest = dest_dir("posts", "1914798137981389", "larry-had-a-little-lamb", "index.html").to_s
4040
expect(redirect_page.destination("/")).to eql(dest)
4141
end
4242
end
4343

4444
context "of a redirect page meant to be a file" do
4545
it "knows not to add the index.html if it's not a folder" do
46-
dest = dest_dir("/posts/12435151125/larry-had-a-little-lamb")
46+
dest = dest_dir("posts", "12435151125", "larry-had-a-little-lamb.html").to_s
4747
expect(redirect_page.destination("/")).to eql(dest)
4848
end
4949
end
@@ -58,7 +58,7 @@
5858
end
5959

6060
it "fetches the path properly" do
61-
expect(redirect_page_full_path).to match /\/spec\/fixtures\/\_site\/posts\/12435151125\/larry-had-a-little-lamb$/
61+
expect(redirect_page_full_path).to match /\/spec\/fixtures\/\_site\/posts\/12435151125\/larry-had-a-little-lamb.html$/
6262
end
6363

6464
it "is written to the proper location" do

spec/jekyll_redirect_from/redirector_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,33 @@
5252
end
5353

5454
it "generates the refresh page for the post properly" do
55-
expect(destination_file_exists?("posts/23128432159832/mary-had-a-little-lamb")).to be_truthy
55+
expect(dest_dir("posts/23128432159832/mary-had-a-little-lamb.html")).to exist
5656
end
5757

5858
it "generates the refresh pages for the page with multiple redirect_from urls" do
59-
expect(destination_file_exists?("help")).to be_truthy
60-
expect(destination_file_exists?("contact")).to be_truthy
61-
expect(destination_file_exists?("let-there/be/light-he-said")).to be_truthy
62-
expect(destination_file_exists?("/geepers/mccreepin")).to be_truthy
59+
expect(dest_dir("help")).to be_truthy
60+
expect(dest_dir("contact")).to be_truthy
61+
expect(dest_dir("let-there/be/light-he-said")).to be_truthy
62+
expect(dest_dir("/geepers/mccreepin")).to be_truthy
6363
end
6464

6565
it "generates the refresh page for the page with one redirect_from url" do
66-
expect(destination_file_exists?("mencius/was/my/father")).to be_truthy
66+
expect(dest_dir("mencius/was/my/father.html")).to exist
6767
end
6868

6969
it "generates the refresh page for the collection with one redirect_to url" do
70-
expect(@dest.join("articles", "redirect-somewhere-else-plz.html")).to exist
71-
expect(destination_doc_contents("articles", "redirect-somewhere-else-plz.html")).to include(%|<meta http-equiv="refresh" content="0; url=http://www.zombo.com">|)
70+
expect(dest_dir("articles", "redirect-somewhere-else-plz.html")).to exist
71+
expect(dest_dir("articles", "redirect-somewhere-else-plz.html").read).to include(%|<meta http-equiv="refresh" content="0; url=http://www.zombo.com">|)
7272
end
7373

7474
it "generates the refresh page for the page with one redirect_to url" do
75-
expect(destination_file_exists?("one_redirect_to.html")).to be_truthy
76-
expect(destination_file_contents("one_redirect_to.html")).to include(%|<meta http-equiv="refresh" content="0; url=https://www.github.com">|)
75+
expect(dest_dir("one_redirect_to.html")).to exist
76+
expect(dest_dir("one_redirect_to.html").read).to include(%|<meta http-equiv="refresh" content="0; url=https://www.github.com">|)
7777
end
7878

7979
it "generates the refresh page for the page with multiple redirect_to urls" do
80-
expect(destination_file_exists?("multiple_redirect_tos.html")).to be_truthy
81-
expect(destination_file_contents("multiple_redirect_tos.html")).to include(%|<meta http-equiv="refresh" content="0; url=https://www.jekyllrb.com">|)
80+
expect(dest_dir("multiple_redirect_tos.html")).to exist
81+
expect(dest_dir("multiple_redirect_tos.html").read).to include(%|<meta http-equiv="refresh" content="0; url=https://www.jekyllrb.com">|)
8282
end
8383
end
8484

spec/spec_helper.rb

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
end
3939

4040
def dest_dir(*paths)
41-
File.join(@dest.to_s, *paths)
41+
@dest.join(*paths)
4242
end
4343

4444
def unpublished_doc
@@ -57,26 +57,15 @@ def setup_page(file)
5757
Jekyll::Page.new(@site, @fixtures_path.to_s, File.dirname(file), File.basename(file))
5858
end
5959

60-
def destination_file_exists?(file)
61-
File.exists?(File.join(@dest.to_s, file))
62-
end
63-
64-
def destination_file_contents(file)
65-
File.read(File.join(@dest.to_s, file))
66-
end
67-
68-
def destination_doc_contents(collection, file)
69-
File.read(File.join(@dest.to_s, collection, file))
70-
end
71-
7260
def new_redirect_page(permalink)
73-
page = JekyllRedirectFrom::RedirectPage.new(@site, @site.source, "", "")
61+
page = JekyllRedirectFrom::RedirectPage.new(@site, @site.source, "", "index.html")
7462
page.data['permalink'] = permalink
63+
page.data['sitemap'] = false
7564
page
7665
end
7766

7867
def destination_sitemap
79-
File.read(File.join(@dest.to_s, 'sitemap.xml'))
68+
@dest.join("sitemap.xml").read
8069
end
8170
end
8271

0 commit comments

Comments
 (0)