webmock 1.20.3 → 1.20.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/README.md +21 -22
  3. data/lib/webmock/matchers/hash_including_matcher.rb +1 -1
  4. data/lib/webmock/version.rb +1 -1
  5. data/spec/acceptance/curb/curb_spec.rb +36 -36
  6. data/spec/acceptance/em_http_request/em_http_request_spec.rb +24 -24
  7. data/spec/acceptance/excon/excon_spec.rb +11 -11
  8. data/spec/acceptance/httpclient/httpclient_spec.rb +9 -9
  9. data/spec/acceptance/net_http/net_http_shared.rb +23 -23
  10. data/spec/acceptance/net_http/net_http_spec.rb +29 -29
  11. data/spec/acceptance/patron/patron_spec.rb +11 -11
  12. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +29 -29
  13. data/spec/acceptance/shared/callbacks.rb +18 -18
  14. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +3 -3
  15. data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +10 -10
  16. data/spec/acceptance/shared/precedence_of_stubs.rb +2 -2
  17. data/spec/acceptance/shared/request_expectations.rb +302 -302
  18. data/spec/acceptance/shared/returning_declared_responses.rb +92 -92
  19. data/spec/acceptance/shared/stubbing_requests.rb +103 -103
  20. data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +8 -8
  21. data/spec/quality_spec.rb +3 -3
  22. data/spec/spec_helper.rb +0 -6
  23. data/spec/unit/errors_spec.rb +16 -16
  24. data/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +1 -1
  25. data/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +2 -2
  26. data/spec/unit/rack_response_spec.rb +14 -14
  27. data/spec/unit/request_execution_verifier_spec.rb +31 -31
  28. data/spec/unit/request_pattern_spec.rb +202 -197
  29. data/spec/unit/request_registry_spec.rb +10 -9
  30. data/spec/unit/request_signature_spec.rb +21 -20
  31. data/spec/unit/request_stub_spec.rb +54 -53
  32. data/spec/unit/response_spec.rb +44 -44
  33. data/spec/unit/stub_registry_spec.rb +15 -15
  34. data/spec/unit/stub_request_snippet_spec.rb +8 -8
  35. data/spec/unit/util/hash_counter_spec.rb +6 -6
  36. data/spec/unit/util/hash_keys_stringifier_spec.rb +1 -1
  37. data/spec/unit/util/headers_spec.rb +4 -4
  38. data/spec/unit/util/json_spec.rb +1 -1
  39. data/spec/unit/util/uri_spec.rb +30 -30
  40. data/spec/unit/util/version_checker_spec.rb +9 -9
  41. data/spec/unit/webmock_spec.rb +1 -1
  42. data/webmock.gemspec +1 -1
  43. metadata +10 -9
@@ -12,9 +12,9 @@ describe WebMock::StubRegistry do
12
12
  describe "remove_request_stub" do
13
13
  it "should remove stub from registry" do
14
14
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
15
- WebMock::StubRegistry.instance.registered_request?(@request_signature).should == @request_stub
15
+ expect(WebMock::StubRegistry.instance.registered_request?(@request_signature)).to eq(@request_stub)
16
16
  WebMock::StubRegistry.instance.remove_request_stub(@request_stub)
17
- WebMock::StubRegistry.instance.registered_request?(@request_signature).should == nil
17
+ expect(WebMock::StubRegistry.instance.registered_request?(@request_signature)).to eq(nil)
18
18
  end
19
19
  end
20
20
 
@@ -24,25 +24,25 @@ describe WebMock::StubRegistry do
24
24
  end
25
25
 
26
26
  it "should clean request stubs" do
27
- WebMock::StubRegistry.instance.registered_request?(@request_signature).should == @request_stub
27
+ expect(WebMock::StubRegistry.instance.registered_request?(@request_signature)).to eq(@request_stub)
28
28
  WebMock::StubRegistry.instance.reset!
29
- WebMock::StubRegistry.instance.registered_request?(@request_signature).should == nil
29
+ expect(WebMock::StubRegistry.instance.registered_request?(@request_signature)).to eq(nil)
30
30
  end
31
31
  end
32
32
 
33
33
  describe "registering and reporting registered requests" do
34
34
 
35
35
  it "should return registered stub" do
36
- WebMock::StubRegistry.instance.register_request_stub(@request_stub).should == @request_stub
36
+ expect(WebMock::StubRegistry.instance.register_request_stub(@request_stub)).to eq(@request_stub)
37
37
  end
38
38
 
39
39
  it "should report if request stub is not registered" do
40
- WebMock::StubRegistry.instance.registered_request?(@request_signature).should == nil
40
+ expect(WebMock::StubRegistry.instance.registered_request?(@request_signature)).to eq(nil)
41
41
  end
42
42
 
43
43
  it "should register and report registered stib" do
44
44
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
45
- WebMock::StubRegistry.instance.registered_request?(@request_signature).should == @request_stub
45
+ expect(WebMock::StubRegistry.instance.registered_request?(@request_signature)).to eq(@request_stub)
46
46
  end
47
47
 
48
48
 
@@ -53,15 +53,15 @@ describe WebMock::StubRegistry do
53
53
  it "should report registered evaluated response for request pattern" do
54
54
  @request_stub.to_return(:body => "abc")
55
55
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
56
- WebMock::StubRegistry.instance.response_for_request(@request_signature).
57
- should == WebMock::Response.new(:body => "abc")
56
+ expect(WebMock::StubRegistry.instance.response_for_request(@request_signature)).
57
+ to eq(WebMock::Response.new(:body => "abc"))
58
58
  end
59
59
 
60
60
  it "should report evaluated response" do
61
61
  @request_stub.to_return {|request| {:body => request.method.to_s} }
62
62
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
63
63
  response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
64
- response1.should == WebMock::Response.new(:body => "get")
64
+ expect(response1).to eq(WebMock::Response.new(:body => "get"))
65
65
  end
66
66
 
67
67
  it "should report clone of the response" do
@@ -69,7 +69,7 @@ describe WebMock::StubRegistry do
69
69
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
70
70
  response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
71
71
  response2 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
72
- response1.should_not be(response2)
72
+ expect(response1).not_to be(response2)
73
73
  end
74
74
 
75
75
  it "should report clone of the dynamic response" do
@@ -77,11 +77,11 @@ describe WebMock::StubRegistry do
77
77
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
78
78
  response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
79
79
  response2 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
80
- response1.should_not be(response2)
80
+ expect(response1).not_to be(response2)
81
81
  end
82
82
 
83
83
  it "should report nothing if no response for request is registered" do
84
- WebMock::StubRegistry.instance.response_for_request(@request_signature).should == nil
84
+ expect(WebMock::StubRegistry.instance.response_for_request(@request_signature)).to eq(nil)
85
85
  end
86
86
 
87
87
  it "should always return last registered matching response" do
@@ -94,8 +94,8 @@ describe WebMock::StubRegistry do
94
94
  WebMock::StubRegistry.instance.register_request_stub(@request_stub1)
95
95
  WebMock::StubRegistry.instance.register_request_stub(@request_stub2)
96
96
  WebMock::StubRegistry.instance.register_request_stub(@request_stub3)
97
- WebMock::StubRegistry.instance.response_for_request(@request_signature).
98
- should == WebMock::Response.new(:body => "def")
97
+ expect(WebMock::StubRegistry.instance.response_for_request(@request_signature)).
98
+ to eq(WebMock::Response.new(:body => "def"))
99
99
  end
100
100
 
101
101
  end
@@ -10,7 +10,7 @@ describe WebMock::StubRequestSnippet do
10
10
  it "should print stub request snippet with url with params and method and empty successful response" do
11
11
  expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").\n to_return(:status => 200, :body => "", :headers => {}))
12
12
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
13
- WebMock::StubRequestSnippet.new(@request_stub).to_s.should == expected
13
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
14
14
  end
15
15
 
16
16
  it "should print stub request snippet with body if available" do
@@ -19,7 +19,7 @@ describe WebMock::StubRequestSnippet do
19
19
  "\n with(:body => \"abcdef\")." +
20
20
  "\n to_return(:status => 200, :body => \"\", :headers => {})"
21
21
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
22
- WebMock::StubRequestSnippet.new(@request_stub).to_s.should == expected
22
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
23
23
  end
24
24
 
25
25
  it "should print stub request snippet with multiline body" do
@@ -28,7 +28,7 @@ describe WebMock::StubRequestSnippet do
28
28
  "\n with(:body => \"abc\\ndef\")." +
29
29
  "\n to_return(:status => 200, :body => \"\", :headers => {})"
30
30
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
31
- WebMock::StubRequestSnippet.new(@request_stub).to_s.should == expected
31
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
32
32
  end
33
33
 
34
34
  it "should print stub request snippet with headers if any" do
@@ -37,7 +37,7 @@ describe WebMock::StubRequestSnippet do
37
37
  "\n with(:headers => {\'A\'=>\'a\', \'B\'=>\'b\'})." +
38
38
  "\n to_return(:status => 200, :body => \"\", :headers => {})"
39
39
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
40
- WebMock::StubRequestSnippet.new(@request_stub).to_s.should == expected
40
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
41
41
  end
42
42
 
43
43
  it "should print stub request snippet with body and headers" do
@@ -47,14 +47,14 @@ describe WebMock::StubRequestSnippet do
47
47
  "\n with(:body => \"abcdef\",\n :headers => {\'A\'=>\'a\', \'B\'=>\'b\'})." +
48
48
  "\n to_return(:status => 200, :body => \"\", :headers => {})"
49
49
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
50
- WebMock::StubRequestSnippet.new(@request_stub).to_s.should == expected
50
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
51
51
  end
52
52
 
53
53
  it "should not print to_return part if not wanted" do
54
54
  expected = 'stub_request(:get, "http://www.example.com/").'+
55
55
  "\n with(:body => \"abcdef\")"
56
56
  stub = WebMock::RequestStub.new(:get, "www.example.com").with(:body => "abcdef").to_return(:body => "hello")
57
- WebMock::StubRequestSnippet.new(stub).to_s(false).should == expected
57
+ expect(WebMock::StubRequestSnippet.new(stub).to_s(false)).to eq(expected)
58
58
  end
59
59
  end
60
60
 
@@ -72,7 +72,7 @@ stub_request(:post, "http://www.example.com/").
72
72
  :headers => {'Content-Type'=>'application/x-www-form-urlencoded'}).
73
73
  to_return(:status => 200, :body => \"\", :headers => {})
74
74
  STUB
75
- WebMock::StubRequestSnippet.new(@request_stub).to_s.should == expected.strip
75
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
76
76
  end
77
77
 
78
78
  it "should print stub request snippet leaving body as string when not a urlencoded form" do
@@ -86,7 +86,7 @@ stub_request(:post, "http://www.example.com/").
86
86
  :headers => {'Content-Type'=>'multipart/form-data; boundary=ABC123'}).
87
87
  to_return(:status => 200, :body => \"\", :headers => {})
88
88
  STUB
89
- WebMock::StubRequestSnippet.new(@request_stub).to_s.should == expected.strip
89
+ expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
90
90
  end
91
91
  end
92
92
 
@@ -3,22 +3,22 @@ require 'spec_helper'
3
3
  describe WebMock::Util::HashCounter do
4
4
 
5
5
  it "should return 0 for non existing key" do
6
- WebMock::Util::HashCounter.new.get(:abc).should == 0
6
+ expect(WebMock::Util::HashCounter.new.get(:abc)).to eq(0)
7
7
  end
8
8
 
9
9
  it "should increase the returned value on every put with the same key" do
10
10
  counter = WebMock::Util::HashCounter.new
11
11
  counter.put(:abc)
12
- counter.get(:abc).should == 1
12
+ expect(counter.get(:abc)).to eq(1)
13
13
  counter.put(:abc)
14
- counter.get(:abc).should == 2
14
+ expect(counter.get(:abc)).to eq(2)
15
15
  end
16
16
 
17
17
  it "should only increase value for given key provided to put" do
18
18
  counter = WebMock::Util::HashCounter.new
19
19
  counter.put(:abc)
20
- counter.get(:abc).should == 1
21
- counter.get(:def).should == 0
20
+ expect(counter.get(:abc)).to eq(1)
21
+ expect(counter.get(:def)).to eq(0)
22
22
  end
23
23
 
24
24
  describe "each" do
@@ -33,7 +33,7 @@ describe WebMock::Util::HashCounter do
33
33
 
34
34
  elements = []
35
35
  counter.each {|k,v| elements << [k,v]}
36
- elements.should == [[:c, 1], [:b, 2], [:a, 2], [:d, 1]]
36
+ expect(elements).to eq([[:c, 1], [:b, 2], [:a, 2], [:d, 1]])
37
37
  end
38
38
  end
39
39
  end
@@ -21,7 +21,7 @@ describe WebMock::Util::HashKeysStringifier do
21
21
  ]
22
22
  }
23
23
  }
24
- WebMock::Util::HashKeysStringifier.stringify_keys!(hash, :deep => true).should == stringified
24
+ expect(WebMock::Util::HashKeysStringifier.stringify_keys!(hash, :deep => true)).to eq(stringified)
25
25
  end
26
26
 
27
27
  end
@@ -5,21 +5,21 @@ describe WebMock::Util::Headers do
5
5
  it "should decode_userinfo_from_header handles basic auth" do
6
6
  authorization_header = "Basic dXNlcm5hbWU6c2VjcmV0"
7
7
  userinfo = WebMock::Util::Headers.decode_userinfo_from_header(authorization_header)
8
- userinfo.should == "username:secret"
8
+ expect(userinfo).to eq("username:secret")
9
9
  end
10
10
 
11
11
  describe "sorted_headers_string" do
12
12
 
13
13
  it "should return nice string for hash with string values" do
14
- WebMock::Util::Headers.sorted_headers_string({"a" => "b"}).should == "{'A'=>'b'}"
14
+ expect(WebMock::Util::Headers.sorted_headers_string({"a" => "b"})).to eq("{'A'=>'b'}")
15
15
  end
16
16
 
17
17
  it "should return nice string for hash with array values" do
18
- WebMock::Util::Headers.sorted_headers_string({"a" => ["b", "c"]}).should == "{'A'=>['b', 'c']}"
18
+ expect(WebMock::Util::Headers.sorted_headers_string({"a" => ["b", "c"]})).to eq("{'A'=>['b', 'c']}")
19
19
  end
20
20
 
21
21
  it "should return nice string for hash with array values and string values" do
22
- WebMock::Util::Headers.sorted_headers_string({"a" => ["b", "c"], "d" => "e"}).should == "{'A'=>['b', 'c'], 'D'=>'e'}"
22
+ expect(WebMock::Util::Headers.sorted_headers_string({"a" => ["b", "c"], "d" => "e"})).to eq("{'A'=>['b', 'c'], 'D'=>'e'}")
23
23
  end
24
24
 
25
25
 
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe WebMock::Util::JSON do
4
4
  it "should parse json without parsing dates" do
5
- WebMock::Util::JSON.parse("\"a\":\"2011-01-01\"").should == {"a" => "2011-01-01"}
5
+ expect(WebMock::Util::JSON.parse("\"a\":\"2011-01-01\"")).to eq({"a" => "2011-01-01"})
6
6
  end
7
7
  end
@@ -81,37 +81,37 @@ describe WebMock::Util::URI do
81
81
 
82
82
  it "should find all variations of the same uri for all variations of uri with params and path" do
83
83
  URIS_WITH_PATH_AND_PARAMS.each do |uri|
84
- WebMock::Util::URI.variations_of_uri_as_strings(uri).sort.should == URIS_WITH_PATH_AND_PARAMS
84
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_WITH_PATH_AND_PARAMS)
85
85
  end
86
86
  end
87
87
 
88
88
  it "should find all variations of the same uri for all variations of uri with params but without path" do
89
89
  URIS_WITHOUT_PATH_BUT_WITH_PARAMS.each do |uri|
90
- WebMock::Util::URI.variations_of_uri_as_strings(uri).sort.should == URIS_WITHOUT_PATH_BUT_WITH_PARAMS
90
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_WITHOUT_PATH_BUT_WITH_PARAMS)
91
91
  end
92
92
  end
93
93
 
94
94
  it "should find all variations of the same uri for all variations of uri without params or path" do
95
95
  URIS_WITHOUT_PATH_OR_PARAMS.each do |uri|
96
- WebMock::Util::URI.variations_of_uri_as_strings(uri).sort.should == URIS_WITHOUT_PATH_OR_PARAMS
96
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_WITHOUT_PATH_OR_PARAMS)
97
97
  end
98
98
  end
99
99
 
100
100
  it "should find all variations of the same uri for all variations of uri with auth" do
101
101
  URIS_WITH_AUTH.each do |uri|
102
- WebMock::Util::URI.variations_of_uri_as_strings(uri).sort.should == URIS_WITH_AUTH
102
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_WITH_AUTH)
103
103
  end
104
104
  end
105
105
 
106
106
  it "should find all variations of the same uri for all variations of uri with different port" do
107
107
  URIS_WITH_DIFFERENT_PORT.each do |uri|
108
- WebMock::Util::URI.variations_of_uri_as_strings(uri).sort.should == URIS_WITH_DIFFERENT_PORT
108
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_WITH_DIFFERENT_PORT)
109
109
  end
110
110
  end
111
111
 
112
112
  it "should find all variations of the same uri for all variations of https uris" do
113
113
  URIS_FOR_HTTPS.each do |uri|
114
- WebMock::Util::URI.variations_of_uri_as_strings(uri).sort.should == URIS_FOR_HTTPS
114
+ expect(WebMock::Util::URI.variations_of_uri_as_strings(uri).sort).to eq(URIS_FOR_HTTPS)
115
115
  end
116
116
  end
117
117
 
@@ -122,7 +122,7 @@ describe WebMock::Util::URI do
122
122
  it "should successfully compare all variations of the same uri with path and params" do
123
123
  URIS_WITH_PATH_AND_PARAMS.each do |uri_a|
124
124
  URIS_WITH_PATH_AND_PARAMS.each do |uri_b|
125
- WebMock::Util::URI.normalize_uri(uri_a).should === WebMock::Util::URI.normalize_uri(uri_b)
125
+ expect(WebMock::Util::URI.normalize_uri(uri_a)).to be === WebMock::Util::URI.normalize_uri(uri_b)
126
126
  end
127
127
  end
128
128
  end
@@ -130,7 +130,7 @@ describe WebMock::Util::URI do
130
130
  it "should successfully compare all variations of the same uri with path but with params" do
131
131
  URIS_WITHOUT_PATH_BUT_WITH_PARAMS.each do |uri_a|
132
132
  URIS_WITHOUT_PATH_BUT_WITH_PARAMS.each do |uri_b|
133
- WebMock::Util::URI.normalize_uri(uri_a).should === WebMock::Util::URI.normalize_uri(uri_b)
133
+ expect(WebMock::Util::URI.normalize_uri(uri_a)).to be === WebMock::Util::URI.normalize_uri(uri_b)
134
134
  end
135
135
  end
136
136
  end
@@ -138,7 +138,7 @@ describe WebMock::Util::URI do
138
138
  it "should successfully compare all variations of the same uri without path or params" do
139
139
  URIS_WITHOUT_PATH_OR_PARAMS.each do |uri_a|
140
140
  URIS_WITHOUT_PATH_OR_PARAMS.each do |uri_b|
141
- WebMock::Util::URI.normalize_uri(uri_a).should === WebMock::Util::URI.normalize_uri(uri_b)
141
+ expect(WebMock::Util::URI.normalize_uri(uri_a)).to be === WebMock::Util::URI.normalize_uri(uri_b)
142
142
  end
143
143
  end
144
144
  end
@@ -146,7 +146,7 @@ describe WebMock::Util::URI do
146
146
  it "should successfully compare all variations of the same uri with authority" do
147
147
  URIS_WITH_AUTH.each do |uri_a|
148
148
  URIS_WITH_AUTH.each do |uri_b|
149
- WebMock::Util::URI.normalize_uri(uri_a).should === WebMock::Util::URI.normalize_uri(uri_b)
149
+ expect(WebMock::Util::URI.normalize_uri(uri_a)).to be === WebMock::Util::URI.normalize_uri(uri_b)
150
150
  end
151
151
  end
152
152
  end
@@ -154,7 +154,7 @@ describe WebMock::Util::URI do
154
154
  it "should successfully compare all variations of the same uri custom port" do
155
155
  URIS_WITH_DIFFERENT_PORT.each do |uri_a|
156
156
  URIS_WITH_DIFFERENT_PORT.each do |uri_b|
157
- WebMock::Util::URI.normalize_uri(uri_a).should === WebMock::Util::URI.normalize_uri(uri_b)
157
+ expect(WebMock::Util::URI.normalize_uri(uri_a)).to be === WebMock::Util::URI.normalize_uri(uri_b)
158
158
  end
159
159
  end
160
160
  end
@@ -162,7 +162,7 @@ describe WebMock::Util::URI do
162
162
  it "should successfully compare all variations of the same https uri" do
163
163
  URIS_FOR_HTTPS.each do |uri_a|
164
164
  URIS_FOR_HTTPS.each do |uri_b|
165
- WebMock::Util::URI.normalize_uri(uri_a).should === WebMock::Util::URI.normalize_uri(uri_b)
165
+ expect(WebMock::Util::URI.normalize_uri(uri_a)).to be === WebMock::Util::URI.normalize_uri(uri_b)
166
166
  end
167
167
  end
168
168
  end
@@ -170,19 +170,19 @@ describe WebMock::Util::URI do
170
170
  it "should successfully handle array parameters" do
171
171
  uri_string = 'http://www.example.com:80/path?a[]=b&a[]=c'
172
172
  uri = WebMock::Util::URI.normalize_uri(uri_string)
173
- WebMock::Util::QueryMapper.query_to_values(uri.query).should == {"a"=>["b", "c"]}
173
+ expect(WebMock::Util::QueryMapper.query_to_values(uri.query)).to eq({"a"=>["b", "c"]})
174
174
  end
175
175
 
176
176
  it "should successfully handle hash parameters" do
177
177
  uri_string = 'http://www.example.com:80/path?a[d]=b&a[e]=c&a[b][c]=1'
178
178
  uri = WebMock::Util::URI.normalize_uri(uri_string)
179
- WebMock::Util::QueryMapper.query_to_values(uri.query).should == {"a"=>{"d"=>"b", "e"=>"c", "b"=>{"c"=>"1"}}}
179
+ expect(WebMock::Util::QueryMapper.query_to_values(uri.query)).to eq({"a"=>{"d"=>"b", "e"=>"c", "b"=>{"c"=>"1"}}})
180
180
  end
181
181
 
182
182
  it "should successfully handle nested hash parameters" do
183
183
  uri_string = 'http://www.example.com:80/path?one[two][three][]=four&one[two][three][]=five'
184
184
  uri = WebMock::Util::URI.normalize_uri(uri_string)
185
- WebMock::Util::QueryMapper.query_to_values(uri.query).should == {"one"=>{"two"=>{"three" => ["four", "five"]}}}
185
+ expect(WebMock::Util::QueryMapper.query_to_values(uri.query)).to eq({"one"=>{"two"=>{"three" => ["four", "five"]}}})
186
186
  end
187
187
 
188
188
  it "should successfully handle mixed array and hash parameters" do
@@ -195,7 +195,7 @@ describe WebMock::Util::URI do
195
195
  # }
196
196
  uri_string = "http://www.example.com:80/path?load[include][][staff]=email&load[include][]=business_name"
197
197
  uri = WebMock::Util::URI.normalize_uri(uri_string)
198
- WebMock::Util::QueryMapper.query_to_values(uri.query).should == {"load"=>{"include"=>[{"staff"=>"email"},"business_name"]}}
198
+ expect(WebMock::Util::QueryMapper.query_to_values(uri.query)).to eq({"load"=>{"include"=>[{"staff"=>"email"},"business_name"]}})
199
199
  end
200
200
 
201
201
  context "when query notation is set to :flat_array" do
@@ -206,7 +206,7 @@ describe WebMock::Util::URI do
206
206
  it "should successfully handle repeated paramters" do
207
207
  uri_string = "http://www.example.com:80/path?target=host1&target=host2"
208
208
  uri = WebMock::Util::URI.normalize_uri(uri_string)
209
- WebMock::Util::QueryMapper.query_to_values(uri.query, :notation => WebMock::Config.instance.query_values_notation).should == [['target', 'host1'], ['target', 'host2']]
209
+ expect(WebMock::Util::QueryMapper.query_to_values(uri.query, :notation => WebMock::Config.instance.query_values_notation)).to eq([['target', 'host1'], ['target', 'host2']])
210
210
  end
211
211
  end
212
212
  end
@@ -216,14 +216,14 @@ describe WebMock::Util::URI do
216
216
  context "when query values is a Hash" do
217
217
  it "returns an alphabetically sorted hash" do
218
218
  sorted_query = WebMock::Util::URI.sort_query_values({"b"=>"one", "a"=>"two"})
219
- sorted_query.should == {"a"=>"two", "b"=>"one"}
219
+ expect(sorted_query).to eq({"a"=>"two", "b"=>"one"})
220
220
  end
221
221
  end
222
222
 
223
223
  context "when query values is an Array" do
224
224
  it "returns an alphabetically sorted array" do
225
225
  sorted_query = WebMock::Util::URI.sort_query_values([["b","two"],["a","one_b"],["a","one_a"]])
226
- sorted_query.should == [["a","one_a"],["a","one_b"],["b","two"]]
226
+ expect(sorted_query).to eq([["a","one_a"],["a","one_b"],["b","two"]])
227
227
  end
228
228
  end
229
229
  end
@@ -233,45 +233,45 @@ describe WebMock::Util::URI do
233
233
  it "should strip_default_port_from_uri strips 80 from http with path" do
234
234
  uri = "http://example.com:80/foo/bar"
235
235
  stripped_uri = WebMock::Util::URI.strip_default_port_from_uri_string(uri)
236
- stripped_uri.should == "http://example.com/foo/bar"
236
+ expect(stripped_uri).to eq("http://example.com/foo/bar")
237
237
  end
238
238
 
239
239
  it "should strip_default_port_from_uri strips 80 from http without path" do
240
240
  uri = "http://example.com:80"
241
241
  stripped_uri = WebMock::Util::URI.strip_default_port_from_uri_string(uri)
242
- stripped_uri.should == "http://example.com"
242
+ expect(stripped_uri).to eq("http://example.com")
243
243
  end
244
244
 
245
245
  it "should strip_default_port_from_uri strips 443 from https without path" do
246
246
  uri = "https://example.com:443"
247
247
  stripped_uri = WebMock::Util::URI.strip_default_port_from_uri_string(uri)
248
- stripped_uri.should == "https://example.com"
248
+ expect(stripped_uri).to eq("https://example.com")
249
249
  end
250
250
 
251
251
  it "should strip_default_port_from_uri strips 443 from https" do
252
252
  uri = "https://example.com:443/foo/bar"
253
253
  stripped_uri = WebMock::Util::URI.strip_default_port_from_uri_string(uri)
254
- stripped_uri.should == "https://example.com/foo/bar"
254
+ expect(stripped_uri).to eq("https://example.com/foo/bar")
255
255
  end
256
256
 
257
257
  it "should strip_default_port_from_uri does not strip 8080 from http" do
258
258
  uri = "http://example.com:8080/foo/bar"
259
- WebMock::Util::URI.strip_default_port_from_uri_string(uri).should == uri
259
+ expect(WebMock::Util::URI.strip_default_port_from_uri_string(uri)).to eq(uri)
260
260
  end
261
261
 
262
262
  it "should strip_default_port_from_uri does not strip 443 from http" do
263
263
  uri = "http://example.com:443/foo/bar"
264
- WebMock::Util::URI.strip_default_port_from_uri_string(uri).should == uri
264
+ expect(WebMock::Util::URI.strip_default_port_from_uri_string(uri)).to eq(uri)
265
265
  end
266
266
 
267
267
  it "should strip_default_port_from_uri does not strip 80 from query string" do
268
268
  uri = "http://example.com/?a=:80&b=c"
269
- WebMock::Util::URI.strip_default_port_from_uri_string(uri).should == uri
269
+ expect(WebMock::Util::URI.strip_default_port_from_uri_string(uri)).to eq(uri)
270
270
  end
271
271
 
272
272
  it "should strip_default_port_from_uri does not modify strings that do not start with http or https" do
273
273
  uri = "httpz://example.com:80/"
274
- WebMock::Util::URI.strip_default_port_from_uri_string(uri).should == uri
274
+ expect(WebMock::Util::URI.strip_default_port_from_uri_string(uri)).to eq(uri)
275
275
  end
276
276
 
277
277
  end
@@ -281,17 +281,17 @@ describe WebMock::Util::URI do
281
281
 
282
282
  it "should encode unsafe chars in userinfo does not encode userinfo safe punctuation" do
283
283
  userinfo = "user;&=+$,:secret"
284
- WebMock::Util::URI.encode_unsafe_chars_in_userinfo(userinfo).should == userinfo
284
+ expect(WebMock::Util::URI.encode_unsafe_chars_in_userinfo(userinfo)).to eq(userinfo)
285
285
  end
286
286
 
287
287
  it "should encode unsafe chars in userinfo does not encode rfc 3986 unreserved characters" do
288
288
  userinfo = "-.!~*'()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:secret"
289
- WebMock::Util::URI.encode_unsafe_chars_in_userinfo(userinfo).should == userinfo
289
+ expect(WebMock::Util::URI.encode_unsafe_chars_in_userinfo(userinfo)).to eq(userinfo)
290
290
  end
291
291
 
292
292
  it "should encode unsafe chars in userinfo does encode other characters" do
293
293
  userinfo, safe_userinfo = 'us#rn@me:sec//ret?"', 'us%23rn%40me:sec%2F%2Fret%3F%22'
294
- WebMock::Util::URI.encode_unsafe_chars_in_userinfo(userinfo).should == safe_userinfo
294
+ expect(WebMock::Util::URI.encode_unsafe_chars_in_userinfo(userinfo)).to eq(safe_userinfo)
295
295
  end
296
296
 
297
297
  end