Skip to content

Commit 1497d38

Browse files
committed
Add test to make sure that objects put in site.github.url are converted to strings before use
1 parent a4c9e8a commit 1497d38

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

spec/jekyll_redirect_from/redirector_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@
8888
expect(redirector.redirect_url(@site, page_with_one)).to start_with("http://example.github.io/test")
8989
end
9090

91+
it "converts non-string values in site.github.url to strings" do
92+
@site.config['github'] = { "url" => TestStringContainer.new("http://example.github.io/test") }
93+
expect(redirector.redirect_url(@site, page_with_one)).to start_with("http://example.github.io/test")
94+
end
95+
9196
it "uses site.baseurl as the redirect prefix when site.github.url is not set" do
9297
@site.config['baseurl'] = "/fancy/prefix"
9398
expect(redirector.redirect_url(@site, page_with_one)).to start_with("/fancy/prefix")

spec/spec_helper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,13 @@ def destination_sitemap
7979
File.read(File.join(@dest.to_s, 'sitemap.xml'))
8080
end
8181
end
82+
83+
class TestStringContainer
84+
def initialize(strValue)
85+
@val = strValue
86+
end
87+
88+
def to_s
89+
@val
90+
end
91+
end

0 commit comments

Comments
 (0)