Skip to content

Commit 5dba17e

Browse files
author
Dorian Marié
committed
Fix RSpec block syntax warnings
There were warnings on RSpec 3.11 about the block syntax --- Deprecation Warnings: The implicit block expectation syntax is deprecated, you should pass a block rather than an argument to `expect` to use the provided block expectation matcher or the matcher must implement `supports_value_expectations?`. e.g `expect { value }.to raise CookieJar::InvalidCookieError` not `expect(value).to raise CookieJar::InvalidCookieError` The implicit block expectation syntax is deprecated, you should pass a block rather than an argument to `expect` to use the provided block expectation matcher or the matcher must implement `supports_value_expectations?`. e.g `expect { value }.to raise CookieJar::InvalidCookieError` not `expect(value).to raise CookieJar::InvalidCookieError` The implicit block expectation syntax is deprecated, you should pass a block rather than an argument to `expect` to use the provided block expectation matcher or the matcher must implement `supports_value_expectations?`. e.g `expect { value }.to raise CookieJar::InvalidCookieError` not `expect(value).to raise CookieJar::InvalidCookieError` Too many similar deprecation messages reported, disregarding further reports. Pass `--deprecation-out` or set `config.deprecation_stream` to a file for full output. If you need more of the backtrace for any of these deprecations to identify where to make the necessary changes, you can configure `config.raise_errors_for_deprecations!`, and it will turn the deprecation warnings into errors, giving you the full backtrace. 9 deprecation warnings total
1 parent c3e610c commit 5dba17e

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

spec/cookie_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
expect(cookie.secure).to be_truthy
6666
end
6767
it 'should fail on unquoted paths' do
68-
expect(lambda do
68+
expect {
6969
Cookie.from_set_cookie2 'https://www.google.com/a/blah',
7070
'GALX=RgmSftjnbPM;Path=/a/;Secure;Version=1'
71-
end).to raise_error InvalidCookieError
71+
}.to raise_error InvalidCookieError
7272
end
7373
it 'should accept quoted values' do
7474
cookie = Cookie.from_set_cookie2 'http://localhost/', 'foo="bar";Version=1'

spec/cookie_validation_spec.rb

+16-16
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,46 @@
55
describe '#validate_cookie' do
66
localaddr = 'http://localhost/foo/bar/'
77
it 'should fail if version unset' do
8-
expect(lambda do
8+
expect {
99
unversioned = Cookie.from_set_cookie localaddr, 'foo=bar'
1010
unversioned.instance_variable_set :@version, nil
1111
CookieValidation.validate_cookie localaddr, unversioned
12-
end).to raise_error InvalidCookieError
12+
}.to raise_error InvalidCookieError
1313
end
1414
it 'should fail if the path is more specific' do
15-
expect(lambda do
15+
expect {
1616
Cookie.from_set_cookie localaddr, 'foo=bar;path=/foo/bar/baz'
17-
end).to raise_error InvalidCookieError
17+
}.to raise_error InvalidCookieError
1818
end
1919
it 'should fail if the path is different than the request' do
20-
expect(lambda do
20+
expect {
2121
Cookie.from_set_cookie localaddr, 'foo=bar;path=/baz/'
22-
end).to raise_error InvalidCookieError
22+
}.to raise_error InvalidCookieError
2323
end
2424
it 'should fail if the domain has no dots' do
25-
expect(lambda do
25+
expect {
2626
Cookie.from_set_cookie 'http://zero/', 'foo=bar;domain=zero'
27-
end).to raise_error InvalidCookieError
27+
}.to raise_error InvalidCookieError
2828
end
2929
it 'should fail for explicit localhost' do
30-
expect(lambda do
30+
expect {
3131
Cookie.from_set_cookie localaddr, 'foo=bar;domain=localhost'
32-
end).to raise_error InvalidCookieError
32+
}.to raise_error InvalidCookieError
3333
end
3434
it 'should fail for mismatched domains' do
35-
expect(lambda do
35+
expect {
3636
Cookie.from_set_cookie 'http://www.foo.com/', 'foo=bar;domain=bar.com'
37-
end).to raise_error InvalidCookieError
37+
}.to raise_error InvalidCookieError
3838
end
3939
it 'should fail for domains more than one level up' do
40-
expect(lambda do
40+
expect {
4141
Cookie.from_set_cookie 'http://x.y.z.com/', 'foo=bar;domain=z.com'
42-
end).to raise_error InvalidCookieError
42+
}.to raise_error InvalidCookieError
4343
end
4444
it 'should fail for setting subdomain cookies' do
45-
expect(lambda do
45+
expect {
4646
Cookie.from_set_cookie 'http://foo.com/', 'foo=bar;domain=auth.foo.com'
47-
end).to raise_error InvalidCookieError
47+
}.to raise_error InvalidCookieError
4848
end
4949
it 'should handle a normal implicit internet cookie' do
5050
normal = Cookie.from_set_cookie 'http://foo.com/', 'foo=bar'

spec/spec_helper.rb

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
require 'rspec'
44
require 'rspec/collection_matchers'
55
require 'yaml'
6+
7+
RSpec.configure do |config|
8+
config.raise_errors_for_deprecations!
9+
end

0 commit comments

Comments
 (0)