Skip to content

Commit d023020

Browse files
committed
add test
1 parent f6d5e6b commit d023020

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

spec/gist_tag_spec.rb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
it "produces the correct script tag" do
1919
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
2020
end
21-
it "produces the correct noscript tag" do
21+
it "produces the correct noscript tag" do
2222
expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
2323
end
2424
end
@@ -30,7 +30,7 @@
3030
it "produces the correct script tag" do
3131
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
3232
end
33-
it "produces the correct noscript tag" do
33+
it "produces the correct noscript tag" do
3434
expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
3535
end
3636
end
@@ -42,7 +42,7 @@
4242
it "produces the correct script tag" do
4343
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
4444
end
45-
it "produces the correct noscript tag" do
45+
it "produces the correct noscript tag" do
4646
expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
4747
end
4848
end
@@ -56,7 +56,7 @@
5656
it "produces the correct script tag" do
5757
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js\?file=#{filename}">\s<\/script>/)
5858
end
59-
it "produces the correct noscript tag" do
59+
it "produces the correct noscript tag" do
6060
expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
6161
end
6262
end
@@ -74,7 +74,7 @@
7474
it "produces the correct script tag" do
7575
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{doc.data['gist_id']}.js">\s<\/script>/)
7676
end
77-
it "produces the correct noscript tag" do
77+
it "produces the correct noscript tag" do
7878
expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
7979
end
8080
end
@@ -97,12 +97,12 @@
9797
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{doc.data['gist_id']}.js\?file=#{doc.data['gist_filename']}">\s<\/script>/)
9898
end
9999

100-
it "produces the correct noscript tag" do
100+
it "produces the correct noscript tag" do
101101
expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
102102
end
103103
end
104104

105-
context "with valid gist id and invalid filename" do
105+
context "with valid gist id and invalid filename" do
106106
before { stub_request(:get, "https://gist.githubusercontent.com/#{gist_id}/raw/#{gist_filename}").to_return(status: 404) }
107107
let(:gist_id) { "mattr-/24081a1d93d2898ecf0f" }
108108
let(:gist_filename) { "myfile.ext" }
@@ -112,14 +112,25 @@
112112
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist_id}.js\?file=#{gist_filename}">\s<\/script>/)
113113
end
114114

115-
it "does not produce the noscript tag" do
115+
it "does not produce the noscript tag" do
116116
expect(output).to_not match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
117117
end
118118

119119
end
120120

121-
end
121+
context "with noscript disabled" do
122+
let(:doc) { doc_with_content(content, { "gist" => { "noscript" => false } }) }
123+
let(:output) do
124+
doc.content = content
125+
doc.output = Jekyll::Renderer.new(doc.site, doc).run
126+
end
122127

128+
it "does not produce the noscript tag" do
129+
expect(output).to_not match(/<noscript>/)
130+
end
131+
end
132+
133+
end
123134

124135
context "invalid gist" do
125136

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def dest_dir(*files)
2727
end
2828

2929
def doc_with_content(content, opts = {})
30-
my_site = site
30+
my_site = site(opts)
3131
Jekyll::Document.new(source_dir('_test/doc.md'), {site: my_site, collection: collection(my_site)})
3232
end
3333

0 commit comments

Comments
 (0)