redis_snippets 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38d19f802623e08cc2333422077396ff73fdec011ec9bdfdb1b302abd3e7c096
4
- data.tar.gz: e0d7c8e3665e5b631fa5c3a0544cf1933ea318ee0e9633e5e78d93885fa5d6c8
3
+ metadata.gz: a6e23e82090d87175ad955c952631f69c82c81f8a44bb31425e0d8fd23cd3efb
4
+ data.tar.gz: 7a10f98d066f22d13fc396738f5caacf784864f0ecd27bc64768c7b3e5c31592
5
5
  SHA512:
6
- metadata.gz: 243b2a8c9756060110b4b912d85560a5b8120b2839c6833ee19f0a0721af80272ab1f8338286cac0c81dff0283c0bb063bc33d51d9bf40a818cb52e7c3fd0737
7
- data.tar.gz: 0e6e2aa4a13adb008dca059bc5c0397d3ae6cfadd2879953637822bbda938c73af0cf2a9e0f8326c68d7953c97be53b6c2b0cd3a3ab571ef27a5d65f8689faeb
6
+ metadata.gz: e07f026b183cad598364729618af9fe667e3edadbf3797897d2f19adf05738f3e74373c342085230ec28fa549d892d0a54010779ff86e2c8a8861fadc84444d7
7
+ data.tar.gz: 90c0e1f7b2245e79afdb0acf63e7937455651177c547805eec6f578bec1c8791958f6f3d61a96ff806798074148c349ee622016285283925a1bb8bdf9eca38b4
@@ -8,7 +8,7 @@ class SnippetFinderService
8
8
  end
9
9
 
10
10
  def call
11
- SnippetStoreService.send(snippet_key(@key))
11
+ self.class.random_snippet(SnippetStoreService.send(snippet_key(@key)))
12
12
  end
13
13
 
14
14
  protected
@@ -1,3 +1,3 @@
1
1
  module RedisSnippets
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -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
- before do
23
- SnippetStoreService.update(snippet_key(:advert_header), code)
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
- it "adds the snippet key as the class" do
27
- expect(snippet(:advert_header)).to eq("<div class=\"snippet advert_header\"><p>Buy this from Amazon.</p></div>")
28
- end
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
- it "adds more classes from an array" do
35
- 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>")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_snippets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Moen Wulffeld