cacheable_flash 0.3.3 → 0.3.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
  SHA1:
3
- metadata.gz: 8bdb098987853b71c911ad84e070ca44e3c3dee1
4
- data.tar.gz: 167e3d10c1679c57f12d1a7f8127509301092e65
3
+ metadata.gz: 961455be26c61651eb110faf6af10b4bfccd10bf
4
+ data.tar.gz: 9c8087e7e479bf5c8d763871d4a090dde48810ff
5
5
  SHA512:
6
- metadata.gz: 3bdf569f5354470eba7634a09c55dfe35d8f43362a1d2ef9949d290b6855bf781023df8555560ee8131851115d4a9150a572df528c56d245439f883b5f338493
7
- data.tar.gz: b5a1f3892cefd5b90b3c450b27090e34b9d38fc33486ddd18fcc5cc48968aa2bdaf8c3f5dd050f86e672b46a3546c2826e2875c30dd583549af793c1e59890bf
6
+ metadata.gz: 2b86f36dce97b83134ba04e0609e4860e41716b2f5471870354e9e1ac7ca4cd351f59d8e8615209ce8f85b653dc346c40a435acfa0c9442b40464ffba3d01bbf
7
+ data.tar.gz: e893e5b5bb52d187dc2a792038aabec34f5316a8d98ca545beae27237c6ef9a967269f5b3e165cc2a7f007402e4f74ee8f055df33750d44c709db5b79503cca3
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.3.4 - SEP.28.2015
2
+ * Maintenance release with minor changes and a security fix
3
+ * fix JS error when flash cookie is not set (new version of jquery.cookie returns undefined when a cookie does not exist) [nickurban]
4
+ * Reflected XSS vulnerability fix [rubyconvict]
5
+ * If domain is not set, do not force as empty string. Breaks IE. [ndreckshage]
6
+ * Update CacheableFlash::RspecMatchers and rspec test suite for latest Rspec v3.3 [Peter Boling]
7
+
1
8
  0.3.3 - SEP.13.2013
2
9
  * Maintenance release with lots of minor changes and fixes.
3
10
  * Main gem should be API compatible.
@@ -24,11 +24,11 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_runtime_dependency(%q<stackable_flash>, [">= 0.0.7"])
26
26
  s.add_runtime_dependency(%q<json>, [">= 0"])
27
- s.add_development_dependency(%q<rails>, ["~> 3.1.3"])
27
+ s.add_development_dependency(%q<rails>, ["~> 3.1.12"])
28
28
  s.add_development_dependency(%q<jquery-rails>, [">= 0"])
29
- s.add_development_dependency(%q<rspec-rails>, [">= 2.11.0"])
29
+ s.add_development_dependency(%q<rspec-rails>, [">= 3.3.3"])
30
30
  s.add_development_dependency(%q<rdoc>, [">= 3.12"])
31
- s.add_development_dependency(%q<reek>, [">= 1.2.8"])
32
- s.add_development_dependency(%q<roodi>, [">= 2.1.0"])
31
+ s.add_development_dependency(%q<reek>, [">= 3.5.0"])
32
+ s.add_development_dependency(%q<roodi>, [">= 5.0.0"])
33
33
  s.add_development_dependency(%q<rake>, [">= 0"])
34
34
  end
@@ -16,7 +16,7 @@ module CacheableFlash
16
16
  if env_flash
17
17
  domain = CacheableFlash::Config.config[:domain]
18
18
  cookies = Rack::Request.new(env).cookies
19
- Rack::Utils.set_cookie_header!(headers, "flash", :value => cookie_flash(env_flash, cookies), :path => "/", :domain => "#{domain}")
19
+ Rack::Utils.set_cookie_header!(headers, "flash", :value => cookie_flash(env_flash, cookies), :path => "/", :domain => domain)
20
20
  end
21
21
 
22
22
  [status, headers, body]
@@ -11,10 +11,10 @@ module CacheableFlash
11
11
  flash_in_stack(flash_cookie_for(response)[flash_status], expecting)
12
12
  end
13
13
  match{|response| has_flash_cookie?(response)}
14
- failure_message_for_should do |actual|
14
+ failure_message do |actual|
15
15
  "expected flash[:#{expected[0]}] to be or include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
16
16
  end
17
- failure_message_for_should_not do |actual|
17
+ failure_message_when_negated do |actual|
18
18
  "expected flash[:#{expected[0]}] to not be and not include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
19
19
  end
20
20
  end
@@ -24,10 +24,10 @@ module CacheableFlash
24
24
  flash_in_stack(flash_cookie_for(response)[flash_status], expecting)
25
25
  end
26
26
  match{|response| has_cacheable_flash?(response)}
27
- failure_message_for_should do |actual|
27
+ failure_message do |actual|
28
28
  "expected flash[:#{expected[0]}] to be or include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
29
29
  end
30
- failure_message_for_should_not do |actual|
30
+ failure_message_when_negated do |actual|
31
31
  "expected flash[:#{expected[0]}] to not be and not include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
32
32
  end
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module CacheableFlash
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -4,11 +4,11 @@ describe 'CacheableFlash' do
4
4
  attr_reader :controller_class, :controller, :cookies
5
5
  before do
6
6
  @controller_class = Struct.new(:cookies, :flash)
7
- @controller_class.stub(:around_filter)
7
+ allow(@controller_class).to receive(:around_filter)
8
8
  @controller_class.send(:include, CacheableFlash)
9
9
  @controller = @controller_class.new({}, {})
10
10
  @cookies = {}
11
- @controller.stub(:cookies).and_return(@cookies)
11
+ allow(@controller).to receive(:cookies) { @cookies }
12
12
  end
13
13
 
14
14
  def controller_cookie_flash
@@ -26,7 +26,7 @@ describe 'CacheableFlash' do
26
26
  @controller.flash = expected_flash.dup
27
27
  @controller.write_flash_to_cookie
28
28
 
29
- JSON(controller_cookie_flash).should == expected_flash
29
+ expect(JSON(controller_cookie_flash)).to eq expected_flash
30
30
  end
31
31
  end
32
32
 
@@ -49,52 +49,50 @@ describe 'CacheableFlash' do
49
49
  'notice' => "New notice",
50
50
  'errors' => "New errors",
51
51
  }
52
- JSON(controller_cookie_flash).should == expected_flash
52
+ expect(JSON(controller_cookie_flash)).to eq expected_flash
53
53
  end
54
54
  end
55
55
 
56
56
  context "when the flash cookie is 'invalid' json" do
57
57
  it "does not have an error and starts with an empty Hash" do
58
58
  @cookies['flash'] = ""
59
- lambda do
60
- JSON(@cookies['flash'])
61
- end.should raise_error(JSON::ParserError)
59
+ expect { JSON(@cookies['flash']) }.to raise_error(JSON::ParserError)
62
60
 
63
61
  @controller.write_flash_to_cookie
64
62
 
65
- JSON(@cookies['flash'][:value]).should == {}
63
+ expect(JSON(@cookies['flash'][:value])).to eq({})
66
64
  end
67
65
  end
68
66
  end
69
-
67
+
70
68
  it "converts flash value to string before storing in cookie if value is a number" do
71
69
  @controller.flash = { 'quantity' => 5 }
72
70
  @controller.write_flash_to_cookie
73
- JSON(controller_cookie_flash).should == { 'quantity' => 5 }
71
+ expect(JSON(controller_cookie_flash)).to eq({ 'quantity' => 5 })
74
72
  end
75
-
73
+
76
74
  it "does not convert flash value to string before storing in cookie if value is anything other than a number" do
77
75
  @controller.flash = { 'foo' => { 'bar' => 'baz' } }
78
76
  @controller.write_flash_to_cookie
79
- JSON(controller_cookie_flash).should == { 'foo' => { 'bar' => 'baz' } }
77
+ expect(JSON(controller_cookie_flash)).to eq({ 'foo' => { 'bar' => 'baz' } })
80
78
  end
81
-
79
+
82
80
  it "encodes plus signs in generated JSON before storing in cookie" do
83
81
  @controller.flash = { 'notice' => 'Life, Love + Liberty' }
84
82
  @controller.write_flash_to_cookie
85
- controller_cookie_flash.should == "{\"notice\":\"Life, Love %2B Liberty\"}"
83
+ expect(controller_cookie_flash).to eq "{\"notice\":\"Life, Love %2B Liberty\"}"
86
84
  end
87
85
 
88
86
  it "escapes strings when not html safe" do
89
87
  @controller.flash = { 'notice' => '<em>Life, Love + Liberty</em>' } # Not html_safe, so it will be escaped
90
88
  @controller.write_flash_to_cookie
91
- controller_cookie_flash.should == "{\"notice\":\"&lt;em&gt;Life, Love %2B Liberty&lt;/em&gt;\"}"
89
+ expect(controller_cookie_flash).to eq "{\"notice\":\"&lt;em&gt;Life, Love %2B Liberty&lt;/em&gt;\"}"
92
90
  end
93
91
 
94
92
  it "does not escape strings that are html_safe" do
95
93
  @controller.flash = { 'notice' => '<em>Life, Love + Liberty</em>'.html_safe } # html_safe so it will not be escaped
96
94
  @controller.write_flash_to_cookie
97
- controller_cookie_flash.should == "{\"notice\":\"<em>Life, Love %2B Liberty</em>\"}"
95
+ expect(controller_cookie_flash).to eq "{\"notice\":\"<em>Life, Love %2B Liberty</em>\"}"
98
96
  end
99
97
 
100
98
  it "clears the controller.flash hash provided by Rails" do
@@ -105,25 +103,25 @@ describe 'CacheableFlash' do
105
103
  @controller.flash = flash
106
104
  @controller.write_flash_to_cookie
107
105
 
108
- @controller.flash.should == {}
106
+ expect(@controller.flash).to eq({})
109
107
  end
110
-
108
+
111
109
  it "escapes HTML if the flash value is not html safe" do
112
110
  @controller.flash = { 'quantity' => "<div>foobar</div>" }
113
111
  @controller.write_flash_to_cookie
114
- JSON(controller_cookie_flash).should == { 'quantity' => "&lt;div&gt;foobar&lt;/div&gt;" }
112
+ expect(JSON(controller_cookie_flash)).to eq({ 'quantity' => "&lt;div&gt;foobar&lt;/div&gt;" })
115
113
  end
116
-
114
+
117
115
  it "does not escape flash HTML if the value is html safe" do
118
116
  @controller.flash = { 'quantity' => '<div>foobar</div>'.html_safe }
119
117
  @controller.write_flash_to_cookie
120
- JSON(controller_cookie_flash).should == { 'quantity' => "<div>foobar</div>" }
118
+ expect(JSON(controller_cookie_flash)).to eq({ 'quantity' => "<div>foobar</div>" })
121
119
  end
122
120
  end
123
121
 
124
122
  describe ".included" do
125
123
  it "sets the around_filter on the controller to call #write_flash_to_cookie" do
126
- @controller_class.should_receive(:around_filter).with(:write_flash_to_cookie)
124
+ expect(@controller_class).to receive(:around_filter).with(:write_flash_to_cookie)
127
125
  @controller_class.send(:include, CacheableFlash)
128
126
  end
129
127
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  # even if you are actually using the Middleware in your actual app
6
6
  # The DummyController in the dummy app includes CacheableFlash to make the helpers testable as a controller spec.
7
7
 
8
- describe ComparisonController do
8
+ describe ComparisonController, type: :controller do
9
9
 
10
10
  render_views
11
11
 
@@ -20,19 +20,19 @@ describe ComparisonController do
20
20
  #end
21
21
  it "should handle comparison with hash through keys" do
22
22
  get :single_key_hash
23
- flash_cookie['notice'].should == {'hello' => 'asdf'} # Keys of hashes are always strings on the other side of JSON
23
+ expect(flash_cookie['notice']).to eq({'hello' => 'asdf'}) # Keys of hashes are always strings on the other side of JSON
24
24
  end
25
25
  it "should handle comparison with number" do
26
26
  get :single_key_number
27
- flash_cookie['notice'].should == 1
27
+ expect(flash_cookie['notice']).to eq(1)
28
28
  end
29
29
  it "should handle comparison with string" do
30
30
  get :single_key_string
31
- flash_cookie['notice'].should == 'message'
31
+ expect(flash_cookie['notice']).to eq('message')
32
32
  end
33
33
  it "should handle comparison with array" do
34
34
  get :single_key_array
35
- flash_cookie['notice'].should == ['message'] # Because actually set to an array, not because stacking
35
+ expect(flash_cookie['notice']).to eq(['message']) # Because actually set to an array, not because stacking
36
36
  end
37
37
  end
38
38
  describe "stacking" do
@@ -47,19 +47,19 @@ describe ComparisonController do
47
47
  end
48
48
  it "should handle comparison with hash through keys" do
49
49
  get :single_key_hash
50
- flash_cookie['notice'].should == [{'hello' => 'asdf'}] # Keys of hashes are always strings on the other side of JSON
50
+ expect(flash_cookie['notice']).to eq([{'hello' => 'asdf'}]) # Keys of hashes are always strings on the other side of JSON
51
51
  end
52
52
  it "should handle comparison with number" do
53
53
  get :single_key_number
54
- flash_cookie['notice'].should == [1]
54
+ expect(flash_cookie['notice']).to eq([1])
55
55
  end
56
56
  it "should handle comparison with string" do
57
57
  get :single_key_string
58
- flash_cookie['notice'].should == ['message'] # flash was set to a string, but comparison is with an array!
58
+ expect(flash_cookie['notice']).to eq(['message']) # flash was set to a string, but comparison is with an array!
59
59
  end
60
60
  it "should handle comparison with array" do
61
61
  get :single_key_array
62
- flash_cookie['notice'].should == ['message']
62
+ expect(flash_cookie['notice']).to eq(['message'])
63
63
  end
64
64
  end
65
65
  end
@@ -80,18 +80,18 @@ describe ComparisonController do
80
80
  end
81
81
  context "#should" do
82
82
  it "raises error when not a match" do
83
- lambda {response.should have_cacheable_flash('notice','not message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
83
+ expect { expect(response).to have_cacheable_flash('notice','not message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
84
84
  end
85
85
  it "should not raise error when a match" do
86
- lambda {response.should have_cacheable_flash('notice','message')}.should_not raise_exception
86
+ expect { expect(response).to have_cacheable_flash('notice','message')}.to_not raise_error
87
87
  end
88
88
  end
89
89
  context "#should_not" do
90
90
  it "raises error when a match" do
91
- lambda {response.should_not have_cacheable_flash('notice','message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
91
+ expect { expect(response).to_not have_cacheable_flash('notice','message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
92
92
  end
93
93
  it "should not raise error when not a match" do
94
- lambda {response.should_not have_cacheable_flash('notice','not message')}.should_not raise_exception
94
+ expect { expect(response).to_not have_cacheable_flash('notice','not message')}.to_not raise_error
95
95
  end
96
96
 
97
97
  end
@@ -102,18 +102,18 @@ describe ComparisonController do
102
102
  end
103
103
  context "#should" do
104
104
  it "raises error when not a match" do
105
- lambda {response.should have_cacheable_flash('notice','not message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
105
+ expect { expect(response).to have_cacheable_flash('notice','not message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
106
106
  end
107
107
  it "should not raise error when a match" do
108
- lambda {response.should have_cacheable_flash('notice','message')}.should_not raise_exception
108
+ expect { expect(response).to have_cacheable_flash('notice','message')}.to_not raise_error
109
109
  end
110
110
  end
111
111
  context "#should_not" do
112
112
  it "raises error when a match" do
113
- lambda {response.should_not have_cacheable_flash('notice','message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
113
+ expect { expect(response).to_not have_cacheable_flash('notice','message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
114
114
  end
115
115
  it "should not raise error when not a match" do
116
- lambda {response.should_not have_cacheable_flash('notice','not message')}.should_not raise_exception
116
+ expect { expect(response).to_not have_cacheable_flash('notice','not message')}.to_not raise_error
117
117
  end
118
118
  end
119
119
  end
@@ -123,18 +123,18 @@ describe ComparisonController do
123
123
  end
124
124
  context "#should" do
125
125
  it "raises error when not a match" do
126
- lambda {response.should have_cacheable_flash('notice','not message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
126
+ expect { expect(response).to have_cacheable_flash('notice','not message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
127
127
  end
128
128
  it "should not raise error when a match" do
129
- lambda {response.should have_cacheable_flash('notice',{'hello' => 'asdf'})}.should_not raise_exception
129
+ expect { expect(response).to have_cacheable_flash('notice',{'hello' => 'asdf'})}.to_not raise_error
130
130
  end
131
131
  end
132
132
  context "#should_not" do
133
133
  it "raises error when a match" do
134
- lambda {response.should_not have_cacheable_flash('notice',{'hello' => 'asdf'})}.should raise_error RSpec::Expectations::ExpectationNotMetError
134
+ expect { expect(response).to_not have_cacheable_flash('notice',{'hello' => 'asdf'})}.to raise_error RSpec::Expectations::ExpectationNotMetError
135
135
  end
136
136
  it "should not raise error when not a match" do
137
- lambda {response.should_not have_cacheable_flash('notice','not message')}.should_not raise_exception
137
+ expect { expect(response).to_not have_cacheable_flash('notice','not message')}.to_not raise_error
138
138
  end
139
139
 
140
140
  end
@@ -145,18 +145,18 @@ describe ComparisonController do
145
145
  end
146
146
  context "#should" do
147
147
  it "raises error when not a match" do
148
- lambda {response.should have_cacheable_flash('notice',2)}.should raise_error RSpec::Expectations::ExpectationNotMetError
148
+ expect { expect(response).to have_cacheable_flash('notice',2)}.to raise_error RSpec::Expectations::ExpectationNotMetError
149
149
  end
150
150
  it "should not raise error when a match" do
151
- lambda {response.should have_cacheable_flash('notice',1)}.should_not raise_exception
151
+ expect { expect(response).to have_cacheable_flash('notice',1)}.to_not raise_error
152
152
  end
153
153
  end
154
154
  context "#should_not" do
155
155
  it "raises error when a match" do
156
- lambda {response.should_not have_cacheable_flash('notice',1)}.should raise_error RSpec::Expectations::ExpectationNotMetError
156
+ expect { expect(response).to_not have_cacheable_flash('notice',1)}.to raise_error RSpec::Expectations::ExpectationNotMetError
157
157
  end
158
158
  it "should not raise error when not a match" do
159
- lambda {response.should_not have_cacheable_flash('notice',2)}.should_not raise_exception
159
+ expect { expect(response).to_not have_cacheable_flash('notice',2)}.to_not raise_error
160
160
  end
161
161
  end
162
162
  end
@@ -177,20 +177,20 @@ describe ComparisonController do
177
177
  end
178
178
  context "#should" do
179
179
  it "raises error when not a match" do
180
- lambda {response.should have_cacheable_flash('notice','not message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
180
+ expect { expect(response).to have_cacheable_flash('notice','not message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
181
181
  end
182
182
  it "should not raise error when a match" do
183
- lambda {response.should have_cacheable_flash('notice','message')}.should_not raise_exception
184
- lambda {response.should have_cacheable_flash('notice',['message'])}.should_not raise_exception
183
+ expect { expect(response).to have_cacheable_flash('notice','message')}.to_not raise_error
184
+ expect { expect(response).to have_cacheable_flash('notice',['message'])}.to_not raise_error
185
185
  end
186
186
  end
187
187
  context "#should_not" do
188
188
  it "raises error when a match" do
189
- lambda {response.should_not have_cacheable_flash('notice','message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
190
- lambda {response.should_not have_cacheable_flash('notice',['message'])}.should raise_error RSpec::Expectations::ExpectationNotMetError
189
+ expect { expect(response).to_not have_cacheable_flash('notice','message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
190
+ expect { expect(response).to_not have_cacheable_flash('notice',['message'])}.to raise_error RSpec::Expectations::ExpectationNotMetError
191
191
  end
192
192
  it "should not raise error when not a match" do
193
- lambda {response.should_not have_cacheable_flash('notice','not message')}.should_not raise_exception
193
+ expect { expect(response).to_not have_cacheable_flash('notice','not message')}.to_not raise_error
194
194
  end
195
195
 
196
196
  end
@@ -201,20 +201,20 @@ describe ComparisonController do
201
201
  end
202
202
  context "#should" do
203
203
  it "raises error when not a match" do
204
- lambda {response.should have_cacheable_flash('notice',['not message'])}.should raise_error RSpec::Expectations::ExpectationNotMetError
204
+ expect { expect(response).to have_cacheable_flash('notice',['not message'])}.to raise_error RSpec::Expectations::ExpectationNotMetError
205
205
  end
206
206
  it "should not raise error when a match" do
207
- lambda {response.should have_cacheable_flash('notice','message')}.should_not raise_exception
208
- lambda {response.should have_cacheable_flash('notice',['message'])}.should_not raise_exception
207
+ expect { expect(response).to have_cacheable_flash('notice','message')}.to_not raise_error
208
+ expect { expect(response).to have_cacheable_flash('notice',['message'])}.to_not raise_error
209
209
  end
210
210
  end
211
211
  context "#should_not" do
212
212
  it "raises error when a match" do
213
- lambda {response.should_not have_cacheable_flash('notice','message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
214
- lambda {response.should_not have_cacheable_flash('notice',['message'])}.should raise_error RSpec::Expectations::ExpectationNotMetError
213
+ expect { expect(response).to_not have_cacheable_flash('notice','message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
214
+ expect { expect(response).to_not have_cacheable_flash('notice',['message'])}.to raise_error RSpec::Expectations::ExpectationNotMetError
215
215
  end
216
216
  it "should not raise error when not a match" do
217
- lambda {response.should_not have_cacheable_flash('notice','not message')}.should_not raise_exception
217
+ expect { expect(response).to_not have_cacheable_flash('notice','not message')}.to_not raise_error
218
218
  end
219
219
  end
220
220
  end
@@ -224,20 +224,20 @@ describe ComparisonController do
224
224
  end
225
225
  context "#should" do
226
226
  it "raises error when not a match" do
227
- lambda {response.should have_cacheable_flash('notice','not message')}.should raise_error RSpec::Expectations::ExpectationNotMetError
227
+ expect { expect(response).to have_cacheable_flash('notice','not message')}.to raise_error RSpec::Expectations::ExpectationNotMetError
228
228
  end
229
229
  it "should not raise error when a match" do
230
- lambda {response.should have_cacheable_flash('notice',{'hello' => 'asdf'})}.should_not raise_exception
231
- lambda {response.should have_cacheable_flash('notice',[{'hello' => 'asdf'}])}.should_not raise_exception
230
+ expect { expect(response).to have_cacheable_flash('notice',{'hello' => 'asdf'})}.to_not raise_error
231
+ expect { expect(response).to have_cacheable_flash('notice',[{'hello' => 'asdf'}])}.to_not raise_error
232
232
  end
233
233
  end
234
234
  context "#should_not" do
235
235
  it "raises error when a match" do
236
- lambda {response.should_not have_cacheable_flash('notice',{'hello' => 'asdf'})}.should raise_error RSpec::Expectations::ExpectationNotMetError
237
- lambda {response.should_not have_cacheable_flash('notice',[{'hello' => 'asdf'}])}.should raise_error RSpec::Expectations::ExpectationNotMetError
236
+ expect { expect(response).to_not have_cacheable_flash('notice',{'hello' => 'asdf'})}.to raise_error RSpec::Expectations::ExpectationNotMetError
237
+ expect { expect(response).to_not have_cacheable_flash('notice',[{'hello' => 'asdf'}])}.to raise_error RSpec::Expectations::ExpectationNotMetError
238
238
  end
239
239
  it "should not raise error when not a match" do
240
- lambda {response.should_not have_cacheable_flash('notice','not message')}.should_not raise_exception
240
+ expect { expect(response).to_not have_cacheable_flash('notice','not message')}.to_not raise_error
241
241
  end
242
242
 
243
243
  end
@@ -248,20 +248,20 @@ describe ComparisonController do
248
248
  end
249
249
  context "#should" do
250
250
  it "raises error when not a match" do
251
- lambda {response.should have_cacheable_flash('notice',2)}.should raise_error RSpec::Expectations::ExpectationNotMetError
251
+ expect { expect(response).to have_cacheable_flash('notice',2)}.to raise_error RSpec::Expectations::ExpectationNotMetError
252
252
  end
253
253
  it "should not raise error when a match" do
254
- lambda {response.should have_cacheable_flash('notice',1)}.should_not raise_exception
255
- lambda {response.should have_cacheable_flash('notice',[1])}.should_not raise_exception
254
+ expect { expect(response).to have_cacheable_flash('notice',1)}.to_not raise_error
255
+ expect { expect(response).to have_cacheable_flash('notice',[1])}.to_not raise_error
256
256
  end
257
257
  end
258
258
  context "#should_not" do
259
259
  it "raises error when a match" do
260
- lambda {response.should_not have_cacheable_flash('notice',1)}.should raise_error RSpec::Expectations::ExpectationNotMetError
261
- lambda {response.should_not have_cacheable_flash('notice',[1])}.should raise_error RSpec::Expectations::ExpectationNotMetError
260
+ expect { expect(response).to_not have_cacheable_flash('notice',1)}.to raise_error RSpec::Expectations::ExpectationNotMetError
261
+ expect { expect(response).to_not have_cacheable_flash('notice',[1])}.to raise_error RSpec::Expectations::ExpectationNotMetError
262
262
  end
263
263
  it "should not raise error when not a match" do
264
- lambda {response.should_not have_cacheable_flash('notice',2)}.should_not raise_exception
264
+ expect { expect(response).to_not have_cacheable_flash('notice',2)}.to_not raise_error
265
265
  end
266
266
  end
267
267
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  # even if you are actually using the Middleware in your actual app
6
6
  # The DummyController in the dummy app includes CacheableFlash to make the helpers testable as a controller spec.
7
7
 
8
- describe DummyController do
8
+ describe DummyController, type: :controller do
9
9
 
10
10
  render_views
11
11
 
@@ -20,20 +20,20 @@ describe DummyController do
20
20
  #end
21
21
  it "should handle multiple keys" do
22
22
  get :multiple_keys
23
- flash_cookie['errors'].should == "This is an Error"
24
- flash_cookie['notice'].should == "This is a Notice"
23
+ expect(flash_cookie['errors']).to eq("This is an Error")
24
+ expect(flash_cookie['notice']).to eq("This is a Notice")
25
25
  end
26
26
  it "should handle overriding values" do
27
27
  get :override
28
- flash_cookie['notice'].should_not == "original"
29
- flash_cookie['notice'].should == "message"
28
+ expect(flash_cookie['notice']).to_not eq("original")
29
+ expect(flash_cookie['notice']).to eq("message")
30
30
  end
31
31
  it "should handle stacking values as concatenations" do
32
32
  get :stack
33
- flash_cookie['notice'].should == "originalmessageanother"
33
+ expect(flash_cookie['notice']).to eq("originalmessageanother")
34
34
  end
35
35
  it "should raise exception when cold booting the flash" do
36
- lambda { get :cold_boot }.should raise_exception
36
+ expect { get :cold_boot }.to raise_error NoMethodError, /undefined method `<<' for nil:NilClass/
37
37
  end
38
38
  end
39
39
  describe "stacking" do
@@ -48,21 +48,21 @@ describe DummyController do
48
48
  end
49
49
  it "should handle multiple keys" do
50
50
  get :multiple_keys
51
- flash_cookie['errors'].should == ["This is an Error"]
52
- flash_cookie['notice'].should == ["This is a Notice"]
51
+ expect(flash_cookie['errors']).to eq(["This is an Error"])
52
+ expect(flash_cookie['notice']).to eq(["This is a Notice"])
53
53
  end
54
54
  it "should handle overriding values" do
55
55
  get :override
56
- flash_cookie['notice'].should_not == ["original"]
57
- flash_cookie['notice'].should == ["message"]
56
+ expect(flash_cookie['notice']).to_not eq(["original"])
57
+ expect(flash_cookie['notice']).to eq(["message"])
58
58
  end
59
59
  it "should handle stacking values" do
60
60
  get :stack
61
- flash_cookie['notice'].should == ["original","message","another"]
61
+ expect(flash_cookie['notice']).to eq(["original","message","another"])
62
62
  end
63
63
  it "should handle cold booting the flash" do
64
64
  get :cold_boot
65
- flash_cookie['notice'].should == ["original","message","another"]
65
+ expect(flash_cookie['notice']).to eq(["original","message","another"])
66
66
  end
67
67
  end
68
68
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe DummyController do
3
+ describe DummyController, type: :request do
4
4
  before(:each) do
5
5
  CacheableFlash::Config.configure do |config|
6
6
  config[:stacking] = true
@@ -14,12 +14,12 @@ describe DummyController do
14
14
  describe "cookie flash is sticky" do
15
15
  it "should not clear after request" do # because they are only cleared out by javascripts
16
16
  get "/dummy/index"
17
- response.should have_flash_cookie('errors', "This is an Error")
18
- response.should have_flash_cookie('notice', "This is a Notice")
17
+ expect(response).to have_flash_cookie('errors', "This is an Error")
18
+ expect(response).to have_flash_cookie('notice', "This is a Notice")
19
19
 
20
20
  get "/dummy/no_flash"
21
- response.should have_flash_cookie('errors', "This is an Error")
22
- response.should have_flash_cookie('notice', "This is a Notice")
21
+ expect(response).to have_flash_cookie('errors', "This is an Error")
22
+ expect(response).to have_flash_cookie('notice', "This is a Notice")
23
23
 
24
24
  end
25
25
  end
@@ -27,17 +27,17 @@ describe DummyController do
27
27
  describe "cookie flash is stackable" do
28
28
  it "should not overwrite when new flash added" do # because they are only cleared out by javascripts
29
29
  get "/dummy/index"
30
- response.should have_flash_cookie('errors', "This is an Error")
31
- response.should have_flash_cookie('notice', "This is a Notice")
30
+ expect(response).to have_flash_cookie('errors', "This is an Error")
31
+ expect(response).to have_flash_cookie('notice', "This is a Notice")
32
32
 
33
33
  get "/dummy/error?id=1"
34
- response.should have_flash_cookie('errors', "This is an Error")
35
- response.should have_flash_cookie('errors', "Error #1")
34
+ expect(response).to have_flash_cookie('errors', "This is an Error")
35
+ expect(response).to have_flash_cookie('errors', "Error #1")
36
36
 
37
37
  get "/dummy/error?id=2"
38
- response.should have_flash_cookie('errors', "This is an Error")
39
- response.should have_flash_cookie('errors', "Error #1")
40
- response.should have_flash_cookie('errors', "Error #2")
38
+ expect(response).to have_flash_cookie('errors', "This is an Error")
39
+ expect(response).to have_flash_cookie('errors', "Error #1")
40
+ expect(response).to have_flash_cookie('errors', "Error #2")
41
41
  end
42
42
  end
43
43
 
@@ -45,29 +45,29 @@ describe DummyController do
45
45
  # https://github.com/pboling/stackable_flash/blob/master/spec/controllers/dummy_controller_spec.rb
46
46
  it "should handle multiple keys" do
47
47
  get "/dummy/multiple_keys"
48
- response.should have_flash_cookie('notice', 'This is a Notice')
49
- response.should have_flash_cookie('errors', 'This is an Error')
48
+ expect(response).to have_flash_cookie('notice', 'This is a Notice')
49
+ expect(response).to have_flash_cookie('errors', 'This is an Error')
50
50
  end
51
51
 
52
52
  it "should override" do
53
53
  get "/dummy/override"
54
- response.should_not have_flash_cookie('notice','original')
55
- response.should have_flash_cookie('notice','message')
54
+ expect(response).to_not have_flash_cookie('notice','original')
55
+ expect(response).to have_flash_cookie('notice','message')
56
56
  end
57
57
 
58
58
  it "should stack" do
59
59
  get "/dummy/stack"
60
- response.should have_flash_cookie('notice',['original','message','another'])
60
+ expect(response).to have_flash_cookie('notice',['original','message','another'])
61
61
  end
62
62
 
63
63
  it "should cold boot" do
64
64
  get "/dummy/cold_boot"
65
- response.should have_flash_cookie('notice',['original','message','another'])
65
+ expect(response).to have_flash_cookie('notice',['original','message','another'])
66
66
  end
67
67
 
68
68
  it "should allow use of have_cacheable_flash matcher" do
69
69
  get "/dummy/cold_boot"
70
- lambda {response.should have_cacheable_flash('notice',['original','message','another'])}.should_not raise_exception
70
+ expect {expect(response).to have_cacheable_flash('notice',['original','message','another'])}.to_not raise_exception
71
71
  end
72
72
 
73
73
  end
@@ -2,19 +2,18 @@
2
2
  ENV["RAILS_ENV"] = "test"
3
3
  require File.expand_path("../dummy/config/environment", __FILE__)
4
4
 
5
- require 'rspec/rails'
5
+ require "rspec/rails"
6
6
  require "json"
7
- require 'cacheable_flash'
8
- require 'cacheable_flash/rspec_matchers'
7
+ require "cacheable_flash"
8
+ require "cacheable_flash/rspec_matchers"
9
9
 
10
- ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
10
+ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), "../")
11
11
 
12
12
  # Requires supporting ruby files with custom matchers and macros, etc,
13
13
  # in spec/support/ and its subdirectories.
14
14
  Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
15
15
 
16
16
  RSpec.configure do |config|
17
- config.treat_symbols_as_metadata_keys_with_true_values = true
18
17
  config.run_all_when_everything_filtered = true
19
18
  config.filter_run :focus
20
19
 
@@ -22,7 +21,7 @@ RSpec.configure do |config|
22
21
  # order dependency and want to debug it, you can fix the order by providing
23
22
  # the seed, which is printed after each run.
24
23
  # --seed 1234
25
- config.order = 'random'
24
+ config.order = "random"
26
25
 
27
26
  config.include CacheableFlash::RspecMatchers
28
27
  end
@@ -4,7 +4,7 @@ var Flash = new Object();
4
4
  Flash.data = {};
5
5
 
6
6
  Flash.transferFromCookies = function() {
7
- var data = JSON.parse(unescape($.cookie("flash")));
7
+ var data = JSON.parse(unescape($.cookie("flash") || '{}'));
8
8
  if(!data) data = {};
9
9
  Flash.data = data;
10
10
  $.cookie('flash', null, {path: '/', domain: '<%=CacheableFlash::Config.config[:domain]%>'});
@@ -15,7 +15,7 @@ Flash.writeDataTo = function(name, element, callback) {
15
15
  var message = "";
16
16
  if (Flash.data[name]) {
17
17
  message = Flash.data[name].toString().replace(/\+/g, ' ');
18
- element.html(message);
18
+ element.text(message);
19
19
  if (callback && typeof(callback) === 'function') {
20
20
  callback(element);
21
21
  } else {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cacheable_flash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -9,132 +9,132 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-13 00:00:00.000000000 Z
12
+ date: 2015-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stackable_flash
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.0.7
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.0.7
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: json
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rails
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 3.1.3
48
+ version: 3.1.12
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 3.1.3
55
+ version: 3.1.12
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: jquery-rails
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-rails
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: 2.11.0
76
+ version: 3.3.3
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 2.11.0
83
+ version: 3.3.3
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rdoc
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '3.12'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '3.12'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: reek
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: 1.2.8
104
+ version: 3.5.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: 1.2.8
111
+ version: 3.5.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: roodi
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: 2.1.0
118
+ version: 5.0.0
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 2.1.0
125
+ version: 5.0.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rake
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - '>='
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - '>='
137
+ - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  description: |-
@@ -149,9 +149,9 @@ extra_rdoc_files:
149
149
  - LICENSE
150
150
  - README.rdoc
151
151
  files:
152
- - .document
153
- - .gitignore
154
- - .travis.yml
152
+ - ".document"
153
+ - ".gitignore"
154
+ - ".travis.yml"
155
155
  - CHANGELOG
156
156
  - Gemfile
157
157
  - LICENSE
@@ -230,17 +230,17 @@ require_paths:
230
230
  - lib
231
231
  required_ruby_version: !ruby/object:Gem::Requirement
232
232
  requirements:
233
- - - '>='
233
+ - - ">="
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  requirements:
238
- - - '>='
238
+ - - ">="
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
242
  rubyforge_project:
243
- rubygems_version: 2.0.3
243
+ rubygems_version: 2.4.8
244
244
  signing_key:
245
245
  specification_version: 4
246
246
  summary: Render flash messages from a cookie using JavaScript, instead of in your
@@ -292,3 +292,4 @@ test_files:
292
292
  - spec/js_unit/flash_test.html
293
293
  - spec/requests/integration_spec.rb
294
294
  - spec/spec_helper.rb
295
+ has_rdoc: