redis_snippets 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e23e82090d87175ad955c952631f69c82c81f8a44bb31425e0d8fd23cd3efb
|
4
|
+
data.tar.gz: 7a10f98d066f22d13fc396738f5caacf784864f0ecd27bc64768c7b3e5c31592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e07f026b183cad598364729618af9fe667e3edadbf3797897d2f19adf05738f3e74373c342085230ec28fa549d892d0a54010779ff86e2c8a8861fadc84444d7
|
7
|
+
data.tar.gz: 90c0e1f7b2245e79afdb0acf63e7937455651177c547805eec6f578bec1c8791958f6f3d61a96ff806798074148c349ee622016285283925a1bb8bdf9eca38b4
|
@@ -2,6 +2,12 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
describe RedisSnippets::SnippetsHelper, type: :helper do
|
4
4
|
let(:code) { "<p>Buy this from Amazon.</p>" }
|
5
|
+
let(:multiple_adverts) { <<-HEREDOC
|
6
|
+
<p>Buy this from Amazon.</p>
|
7
|
+
[section]
|
8
|
+
<p>Buy this from Apple.</p>
|
9
|
+
HEREDOC
|
10
|
+
}
|
5
11
|
let(:view) { ActionController::Base.new.view_context }
|
6
12
|
|
7
13
|
describe "#snippet_has_content?" do
|
@@ -19,20 +25,33 @@ describe RedisSnippets::SnippetsHelper, type: :helper do
|
|
19
25
|
end
|
20
26
|
|
21
27
|
describe "#snippet" do
|
22
|
-
|
23
|
-
|
28
|
+
context "with a single snippet" do
|
29
|
+
before do
|
30
|
+
SnippetStoreService.update(snippet_key(:advert_header), code)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "adds the snippet key as the class" do
|
34
|
+
expect(snippet(:advert_header)).to eq("<div class=\"snippet advert_header\"><p>Buy this from Amazon.</p></div>")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "adds more classes from a string" do
|
38
|
+
expect(snippet(:advert_header, "advert-responsive")).to eq("<div class=\"snippet advert_header advert-responsive\"><p>Buy this from Amazon.</p></div>")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "adds more classes from an array" do
|
42
|
+
expect(snippet(:advert_header, ["advert-responsive", "p-4"])).to eq("<div class=\"snippet advert_header advert-responsive p-4\"><p>Buy this from Amazon.</p></div>")
|
43
|
+
end
|
24
44
|
end
|
25
45
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
it "adds more classes from a string" do
|
31
|
-
expect(snippet(:advert_header, "advert-responsive")).to eq("<div class=\"snippet advert_header advert-responsive\"><p>Buy this from Amazon.</p></div>")
|
32
|
-
end
|
46
|
+
context "with multiple snippets" do
|
47
|
+
before do
|
48
|
+
SnippetStoreService.update(snippet_key(:advert_header), multiple_adverts)
|
49
|
+
end
|
33
50
|
|
34
|
-
|
35
|
-
|
51
|
+
it "adds the snippet key as the class" do
|
52
|
+
expect(SnippetFinderService).to receive(:rand).and_return(1)
|
53
|
+
expect(snippet(:advert_header)).to eq("<div class=\"snippet advert_header\"><p>Buy this from Apple.</p>\n</div>")
|
54
|
+
end
|
36
55
|
end
|
37
56
|
end
|
38
57
|
end
|