http_stub 0.13.5 → 0.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/lib/http_stub.rb +13 -4
  3. data/lib/http_stub/configurer.rb +9 -63
  4. data/lib/http_stub/configurer/deprecated_dsl.rb +57 -0
  5. data/lib/http_stub/configurer/request/stub.rb +7 -13
  6. data/lib/http_stub/configurer/request/stub_activator.rb +8 -4
  7. data/lib/http_stub/configurer/request/stub_activator_payload_builder.rb +25 -0
  8. data/lib/http_stub/configurer/request/stub_payload_builder.rb +44 -0
  9. data/lib/http_stub/configurer/server/buffered_command_processor.rb +24 -0
  10. data/lib/http_stub/configurer/server/command.rb +18 -0
  11. data/lib/http_stub/configurer/server/command_processor.rb +38 -0
  12. data/lib/http_stub/configurer/server/dsl.rb +56 -0
  13. data/lib/http_stub/configurer/server/facade.rb +57 -0
  14. data/lib/http_stub/configurer/server/request_processor.rb +30 -0
  15. data/lib/http_stub/models/registry.rb +4 -0
  16. data/lib/http_stub/models/stub.rb +2 -1
  17. data/lib/http_stub/models/stub_registry.rb +29 -0
  18. data/lib/http_stub/models/stub_triggers.rb +23 -0
  19. data/lib/http_stub/rake/server_tasks.rb +2 -5
  20. data/lib/http_stub/server.rb +14 -4
  21. data/lib/http_stub/version.rb +1 -1
  22. data/lib/http_stub/views/_stub.haml +7 -0
  23. data/spec/lib/http_stub/configurer/deprecated_dsl_spec.rb +232 -0
  24. data/spec/lib/http_stub/configurer/request/controllable_value_spec.rb +8 -8
  25. data/spec/lib/http_stub/configurer/request/omittable_spec.rb +8 -8
  26. data/spec/lib/http_stub/configurer/request/regexpable_spec.rb +14 -14
  27. data/spec/lib/http_stub/configurer/request/stub_activator_payload_builder_spec.rb +74 -0
  28. data/spec/lib/http_stub/configurer/request/stub_activator_spec.rb +19 -26
  29. data/spec/lib/http_stub/configurer/request/stub_payload_builder_spec.rb +203 -0
  30. data/spec/lib/http_stub/configurer/request/stub_spec.rb +18 -157
  31. data/spec/lib/http_stub/configurer/server/buffered_command_processor_spec.rb +35 -0
  32. data/spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb +62 -0
  33. data/spec/lib/http_stub/configurer/server/command_spec.rb +25 -0
  34. data/spec/lib/http_stub/configurer/server/dsl_spec.rb +241 -0
  35. data/spec/lib/http_stub/configurer/server/facade_spec.rb +253 -0
  36. data/spec/lib/http_stub/configurer/server/request_processor_spec.rb +99 -0
  37. data/spec/lib/http_stub/configurer_integration_spec.rb +172 -122
  38. data/spec/lib/http_stub/configurer_spec.rb +4 -4
  39. data/spec/lib/http_stub/controllers/stub_activator_controller_spec.rb +25 -25
  40. data/spec/lib/http_stub/controllers/stub_controller_spec.rb +22 -22
  41. data/spec/lib/http_stub/hash_extensions_spec.rb +24 -24
  42. data/spec/lib/http_stub/models/exact_value_matcher_spec.rb +4 -4
  43. data/spec/lib/http_stub/models/hash_with_string_value_matchers_spec.rb +29 -29
  44. data/spec/lib/http_stub/models/headers_spec.rb +10 -10
  45. data/spec/lib/http_stub/models/omitted_value_matcher_spec.rb +8 -8
  46. data/spec/lib/http_stub/models/regexp_value_matcher_spec.rb +6 -6
  47. data/spec/lib/http_stub/models/registry_spec.rb +71 -28
  48. data/spec/lib/http_stub/models/request_header_parser_spec.rb +4 -4
  49. data/spec/lib/http_stub/models/request_pipeline_spec.rb +2 -2
  50. data/spec/lib/http_stub/models/response_spec.rb +38 -38
  51. data/spec/lib/http_stub/models/string_value_matcher_spec.rb +25 -25
  52. data/spec/lib/http_stub/models/stub_activator_spec.rb +15 -15
  53. data/spec/lib/http_stub/models/stub_headers_spec.rb +18 -18
  54. data/spec/lib/http_stub/models/stub_parameters_spec.rb +16 -16
  55. data/spec/lib/http_stub/models/stub_registry_integration_spec.rb +62 -0
  56. data/spec/lib/http_stub/models/stub_registry_spec.rb +152 -0
  57. data/spec/lib/http_stub/models/stub_spec.rb +67 -43
  58. data/spec/lib/http_stub/models/stub_triggers_spec.rb +64 -0
  59. data/spec/lib/http_stub/models/stub_uri_spec.rb +9 -9
  60. data/spec/lib/http_stub/rake/server_daemon_tasks_smoke_spec.rb +7 -7
  61. data/spec/lib/http_stub/rake/server_tasks_smoke_spec.rb +5 -5
  62. data/spec/lib/http_stub/rake/server_tasks_spec.rb +17 -15
  63. data/spec/lib/http_stub/server_daemon_spec.rb +16 -16
  64. data/spec/lib/http_stub/server_integration_spec.rb +112 -65
  65. data/spec/lib/http_stub/server_spec.rb +134 -96
  66. data/spec/spec_helper.rb +1 -1
  67. data/spec/support/http_stub/configurer/request/stub_payload_builder_shared_context.rb +27 -0
  68. data/spec/support/server_integration.rb +2 -2
  69. metadata +69 -30
  70. data/lib/http_stub/configurer/command.rb +0 -26
  71. data/lib/http_stub/configurer/command_processor.rb +0 -36
  72. data/lib/http_stub/configurer/impatient_command_chain.rb +0 -13
  73. data/lib/http_stub/configurer/patient_command_chain.rb +0 -25
  74. data/spec/lib/http_stub/configurer/command_processor_integration_spec.rb +0 -63
  75. data/spec/lib/http_stub/configurer/command_spec.rb +0 -40
  76. data/spec/lib/http_stub/configurer/impatient_command_chain_spec.rb +0 -17
  77. data/spec/lib/http_stub/configurer/patient_command_chain_spec.rb +0 -73
@@ -9,12 +9,12 @@ describe HttpStub::Configurer do
9
9
 
10
10
  describe ".get_base_uri" do
11
11
 
12
- it "should return a uri that combines the provided host and port" do
13
- TestableConfigurer.get_base_uri.should include("some_host:8888")
12
+ it "returns a uri that combines the provided host and port" do
13
+ expect(TestableConfigurer.get_base_uri).to include("some_host:8888")
14
14
  end
15
15
 
16
- it "should return a uri accessed via http" do
17
- TestableConfigurer.get_base_uri.should match(/^http:\/\//)
16
+ it "returns a uri accessed via http" do
17
+ expect(TestableConfigurer.get_base_uri).to match(/^http:\/\//)
18
18
  end
19
19
 
20
20
  end
@@ -9,34 +9,34 @@ describe HttpStub::Controllers::StubActivatorController do
9
9
  let(:stub_registry) { double("HttpStub::Models::StubRegistry").as_null_object }
10
10
  let(:controller) { HttpStub::Controllers::StubActivatorController.new(stub_activator_registry, stub_registry) }
11
11
 
12
- before(:each) { JSON.stub(:parse).and_return(stub_activator_options) }
12
+ before(:example) { allow(JSON).to receive(:parse).and_return(stub_activator_options) }
13
13
 
14
14
  describe "#register" do
15
15
 
16
- before(:each) do
17
- HttpStub::Models::StubActivator.stub(:new).and_return(stub_activator)
16
+ before(:example) do
17
+ allow(HttpStub::Models::StubActivator).to receive(:new).and_return(stub_activator)
18
18
  end
19
19
 
20
- it "should parse an options hash from the JSON request body" do
21
- JSON.should_receive(:parse).with(request_body).and_return(stub_activator_options)
20
+ it "parses an options hash from the JSON request body" do
21
+ expect(JSON).to receive(:parse).with(request_body).and_return(stub_activator_options)
22
22
 
23
23
  controller.register(request)
24
24
  end
25
25
 
26
- it "should create a stub activator from the parsed options" do
27
- HttpStub::Models::StubActivator.should_receive(:new).with(stub_activator_options).and_return(stub_activator)
26
+ it "creates a stub activator from the parsed options" do
27
+ expect(HttpStub::Models::StubActivator).to receive(:new).with(stub_activator_options).and_return(stub_activator)
28
28
 
29
29
  controller.register(request)
30
30
  end
31
31
 
32
- it "should add the created activator to the activator registry" do
33
- stub_activator_registry.should_receive(:add).with(stub_activator, request)
32
+ it "adds the created activator to the activator registry" do
33
+ expect(stub_activator_registry).to receive(:add).with(stub_activator, request)
34
34
 
35
35
  controller.register(request)
36
36
  end
37
37
 
38
- it "should return a success response" do
39
- controller.register(request).should eql(HttpStub::Models::Response::SUCCESS)
38
+ it "returns a success response" do
39
+ expect(controller.register(request)).to eql(HttpStub::Models::Response::SUCCESS)
40
40
  end
41
41
 
42
42
  end
@@ -45,36 +45,36 @@ describe HttpStub::Controllers::StubActivatorController do
45
45
 
46
46
  describe "when a stub activator has been registered that is activated by the request" do
47
47
 
48
- before(:each) do
49
- stub_activator_registry.stub(:find_for).with(request).and_return(stub_activator)
48
+ before(:example) do
49
+ allow(stub_activator_registry).to receive(:find_for).with(request).and_return(stub_activator)
50
50
  end
51
51
 
52
- it "should add the activators stub to the stub registry" do
53
- stub_registry.should_receive(:add).with(the_stub, request)
52
+ it "adds the activators stub to the stub registry" do
53
+ expect(stub_registry).to receive(:add).with(the_stub, request)
54
54
 
55
55
  controller.activate(request)
56
56
  end
57
57
 
58
- it "should return a success response" do
59
- controller.activate(request).should eql(HttpStub::Models::Response::SUCCESS)
58
+ it "returns a success response" do
59
+ expect(controller.activate(request)).to eql(HttpStub::Models::Response::SUCCESS)
60
60
  end
61
61
 
62
62
  end
63
63
 
64
64
  describe "when no stub activator is activated by the request" do
65
65
 
66
- before(:each) do
67
- stub_activator_registry.stub(:find_for).with(request).and_return(nil)
66
+ before(:example) do
67
+ allow(stub_activator_registry).to receive(:find_for).with(request).and_return(nil)
68
68
  end
69
69
 
70
- it "should not add a stub to the registry" do
71
- stub_registry.should_not_receive(:add)
70
+ it "does not add a stub to the registry" do
71
+ expect(stub_registry).not_to receive(:add)
72
72
 
73
73
  controller.activate(request)
74
74
  end
75
75
 
76
- it "should return an empty response" do
77
- controller.activate(request).should eql(HttpStub::Models::Response::EMPTY)
76
+ it "returns an empty response" do
77
+ expect(controller.activate(request)).to eql(HttpStub::Models::Response::EMPTY)
78
78
  end
79
79
 
80
80
  end
@@ -83,8 +83,8 @@ describe HttpStub::Controllers::StubActivatorController do
83
83
 
84
84
  describe "#clear" do
85
85
 
86
- it "should clear the activator registry" do
87
- stub_activator_registry.should_receive(:clear).with(request)
86
+ it "clears the activator registry" do
87
+ expect(stub_activator_registry).to receive(:clear).with(request)
88
88
 
89
89
  controller.clear(request)
90
90
  end
@@ -8,34 +8,34 @@ describe HttpStub::Controllers::StubController do
8
8
  let(:registry) { double(HttpStub::Models::Registry).as_null_object }
9
9
  let(:controller) { HttpStub::Controllers::StubController.new(registry) }
10
10
 
11
- before(:each) { JSON.stub(:parse).and_return(stub_options) }
11
+ before(:example) { allow(JSON).to receive(:parse).and_return(stub_options) }
12
12
 
13
13
  describe "#register" do
14
14
 
15
- before(:each) do
16
- HttpStub::Models::Stub.stub(:new).and_return(the_stub)
15
+ before(:example) do
16
+ allow(HttpStub::Models::Stub).to receive(:new).and_return(the_stub)
17
17
  end
18
18
 
19
- it "should parse an options hash from the JSON request body" do
20
- JSON.should_receive(:parse).with(request_body).and_return(stub_options)
19
+ it "parses an options hash from the JSON request body" do
20
+ expect(JSON).to receive(:parse).with(request_body).and_return(stub_options)
21
21
 
22
22
  controller.register(request)
23
23
  end
24
24
 
25
- it "should create a stub from the parsed options" do
26
- HttpStub::Models::Stub.should_receive(:new).with(stub_options).and_return(the_stub)
25
+ it "creates a stub from the parsed options" do
26
+ expect(HttpStub::Models::Stub).to receive(:new).with(stub_options).and_return(the_stub)
27
27
 
28
28
  controller.register(request)
29
29
  end
30
30
 
31
- it "should add the stub to the stub registry" do
32
- registry.should_receive(:add).with(the_stub, request)
31
+ it "adds the stub to the stub registry" do
32
+ expect(registry).to receive(:add).with(the_stub, request)
33
33
 
34
34
  controller.register(request)
35
35
  end
36
36
 
37
- it "should return a success response" do
38
- controller.register(request).should eql(HttpStub::Models::Response::SUCCESS)
37
+ it "returns a success response" do
38
+ expect(controller.register(request)).to eql(HttpStub::Models::Response::SUCCESS)
39
39
  end
40
40
 
41
41
  end
@@ -44,26 +44,26 @@ describe HttpStub::Controllers::StubController do
44
44
 
45
45
  describe "when a stub has been registered that should be replayed for the request" do
46
46
 
47
- before(:each) do
48
- registry.stub(:find_for).with(request).and_return(the_stub)
47
+ before(:example) do
48
+ allow(registry).to receive(:find_for).with(request).and_return(the_stub)
49
49
  end
50
50
 
51
- it "should return the stubs response" do
52
- the_stub.should_receive(:response).and_return(response)
51
+ it "returns the stubs response" do
52
+ expect(the_stub).to receive(:response).and_return(response)
53
53
 
54
- controller.replay(request).should eql(response)
54
+ expect(controller.replay(request)).to eql(response)
55
55
  end
56
56
 
57
57
  end
58
58
 
59
59
  describe "when no stub should be replayed for the request" do
60
60
 
61
- before(:each) do
62
- registry.stub(:find_for).with(request).and_return(nil)
61
+ before(:example) do
62
+ allow(registry).to receive(:find_for).with(request).and_return(nil)
63
63
  end
64
64
 
65
- it "should return an empty response" do
66
- controller.replay(request).should eql(HttpStub::Models::Response::EMPTY)
65
+ it "returns an empty response" do
66
+ expect(controller.replay(request)).to eql(HttpStub::Models::Response::EMPTY)
67
67
  end
68
68
 
69
69
  end
@@ -72,8 +72,8 @@ describe HttpStub::Controllers::StubController do
72
72
 
73
73
  describe "#clear" do
74
74
 
75
- it "should clear the stub registry" do
76
- registry.should_receive(:clear).with(request)
75
+ it "clears the stub registry" do
76
+ expect(registry).to receive(:clear).with(request)
77
77
 
78
78
  controller.clear(request)
79
79
  end
@@ -8,8 +8,8 @@ describe HttpStub::HashExtensions do
8
8
  { "lower" => 1, "UPPER" => 2, "MiXeDcAsE" => 3 }
9
9
  end
10
10
 
11
- it "should downcase the string keys" do
12
- hash.downcase_and_underscore_keys.should eql({ "lower" => 1, "upper" => 2, "mixedcase" => 3 })
11
+ it "downcases the string keys" do
12
+ expect(hash.downcase_and_underscore_keys).to eql({ "lower" => 1, "upper" => 2, "mixedcase" => 3 })
13
13
  end
14
14
 
15
15
  describe "and keys contain underscores and hyphens" do
@@ -18,8 +18,8 @@ describe HttpStub::HashExtensions do
18
18
  { "has_underscore" => 1, "has-hypen" => 2, "has_underscore_and-hypen" => 3 }
19
19
  end
20
20
 
21
- it "should downcase the string keys" do
22
- hash.downcase_and_underscore_keys.should eql({ "has_underscore" => 1,
21
+ it "downcases the string keys" do
22
+ expect(hash.downcase_and_underscore_keys).to eql({ "has_underscore" => 1,
23
23
  "has_hypen" => 2,
24
24
  "has_underscore_and_hypen" => 3 })
25
25
  end
@@ -34,8 +34,8 @@ describe HttpStub::HashExtensions do
34
34
  { 1 => 2, :symbol => 3, nil => 4 }
35
35
  end
36
36
 
37
- it "should not alter a hash" do
38
- hash.downcase_and_underscore_keys.should eql({ 1 => 2, :symbol => 3, nil => 4 })
37
+ it "does not alter a hash" do
38
+ expect(hash.downcase_and_underscore_keys).to eql({ 1 => 2, :symbol => 3, nil => 4 })
39
39
  end
40
40
 
41
41
  end
@@ -52,8 +52,8 @@ describe HttpStub::HashExtensions do
52
52
 
53
53
  let(:hash) { hash_parameter }
54
54
 
55
- it "should return true" do
56
- hash.has_hash?(hash_parameter).should be(true)
55
+ it "returns true" do
56
+ expect(hash.has_hash?(hash_parameter)).to be(true)
57
57
  end
58
58
 
59
59
  end
@@ -62,8 +62,8 @@ describe HttpStub::HashExtensions do
62
62
 
63
63
  let(:hash) { hash_parameter.merge("key4" => "value4") }
64
64
 
65
- it "should return true" do
66
- hash.has_hash?(hash_parameter).should be(true)
65
+ it "returns true" do
66
+ expect(hash.has_hash?(hash_parameter)).to be(true)
67
67
  end
68
68
 
69
69
  end
@@ -72,8 +72,8 @@ describe HttpStub::HashExtensions do
72
72
 
73
73
  let(:hash) { { "key1" => "value1", "key2" => "nonMatchingValue", "key3" => "value3" } }
74
74
 
75
- it "should return false" do
76
- hash.has_hash?(hash_parameter).should be(false)
75
+ it "returns false" do
76
+ expect(hash.has_hash?(hash_parameter)).to be(false)
77
77
  end
78
78
 
79
79
  end
@@ -82,8 +82,8 @@ describe HttpStub::HashExtensions do
82
82
 
83
83
  let(:hash) { { "key1" => "value1", "key3" => "value3" } }
84
84
 
85
- it "should return false" do
86
- hash.has_hash?(hash_parameter).should be(false)
85
+ it "returns false" do
86
+ expect(hash.has_hash?(hash_parameter)).to be(false)
87
87
  end
88
88
 
89
89
  end
@@ -92,8 +92,8 @@ describe HttpStub::HashExtensions do
92
92
 
93
93
  let(:hash) { {} }
94
94
 
95
- it "should return false" do
96
- hash.has_hash?(hash_parameter).should be(false)
95
+ it "returns false" do
96
+ expect(hash.has_hash?(hash_parameter)).to be(false)
97
97
  end
98
98
 
99
99
  end
@@ -108,8 +108,8 @@ describe HttpStub::HashExtensions do
108
108
 
109
109
  let(:hash) { {} }
110
110
 
111
- it "should return true" do
112
- hash.has_hash?(hash_parameter).should be(true)
111
+ it "returns true" do
112
+ expect(hash.has_hash?(hash_parameter)).to be(true)
113
113
  end
114
114
 
115
115
  end
@@ -118,8 +118,8 @@ describe HttpStub::HashExtensions do
118
118
 
119
119
  let(:hash) { { "key" => "value" } }
120
120
 
121
- it "should return true" do
122
- hash.has_hash?(hash_parameter).should be(true)
121
+ it "returns true" do
122
+ expect(hash.has_hash?(hash_parameter)).to be(true)
123
123
  end
124
124
 
125
125
  end
@@ -134,8 +134,8 @@ describe HttpStub::HashExtensions do
134
134
 
135
135
  let(:hash) { {} }
136
136
 
137
- it "should return true" do
138
- hash.has_hash?(hash_parameter).should be(true)
137
+ it "returns true" do
138
+ expect(hash.has_hash?(hash_parameter)).to be(true)
139
139
  end
140
140
 
141
141
  end
@@ -144,8 +144,8 @@ describe HttpStub::HashExtensions do
144
144
 
145
145
  let(:hash) { { "key" => "value" } }
146
146
 
147
- it "should return true" do
148
- hash.has_hash?(hash_parameter).should be(true)
147
+ it "returns true" do
148
+ expect(hash.has_hash?(hash_parameter)).to be(true)
149
149
  end
150
150
 
151
151
  end
@@ -8,8 +8,8 @@ describe HttpStub::Models::ExactValueMatcher do
8
8
 
9
9
  let(:actual_value) { stub_value }
10
10
 
11
- it "should return true" do
12
- perform_match.should be_true
11
+ it "returns true" do
12
+ expect(perform_match).to be_truthy
13
13
  end
14
14
 
15
15
  end
@@ -18,8 +18,8 @@ describe HttpStub::Models::ExactValueMatcher do
18
18
 
19
19
  let(:actual_value) { "not equal to stub value" }
20
20
 
21
- it "should return false" do
22
- perform_match.should be_false
21
+ it "returns false" do
22
+ expect(perform_match).to be_falsey
23
23
  end
24
24
 
25
25
  end
@@ -13,22 +13,22 @@ describe HttpStub::Models::HashWithStringValueMatchers do
13
13
 
14
14
  let(:value_matcher_hash) { HttpStub::Models::HashWithStringValueMatchers.new(stubbed_hash) }
15
15
 
16
- before(:each) do
17
- value_matchers.each { |value| HttpStub::Models::StringValueMatcher.stub(:new).with(value.to_s).and_return(value) }
16
+ before(:example) do
17
+ value_matchers.each { |value| allow(HttpStub::Models::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value) }
18
18
  end
19
19
 
20
- it "should be hash" do
21
- value_matcher_hash.should be_a(Hash)
20
+ it "is a hash" do
21
+ expect(value_matcher_hash).to be_a(Hash)
22
22
  end
23
23
 
24
24
  describe "constructor" do
25
25
 
26
- it "should create a value matcher representation of each value in the hash" do
26
+ it "creates a value matcher representation of each value in the hash" do
27
27
  value_matchers.each do |value|
28
- HttpStub::Models::StringValueMatcher.should_receive(:new).with(value.to_s).and_return(value)
28
+ expect(HttpStub::Models::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value)
29
29
  end
30
30
 
31
- value_matcher_hash.values.should eql(value_matchers)
31
+ expect(value_matcher_hash.values).to eql(value_matchers)
32
32
  end
33
33
 
34
34
  end
@@ -50,27 +50,27 @@ describe HttpStub::Models::HashWithStringValueMatchers do
50
50
 
51
51
  context "and the values match" do
52
52
 
53
- before(:each) do
54
- value_matchers.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
53
+ before(:example) do
54
+ value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
55
55
  end
56
56
 
57
- it "should return true" do
58
- value_matcher_hash.match?(provided_hash).should be_true
57
+ it "returns true" do
58
+ expect(value_matcher_hash.match?(provided_hash)).to be_truthy
59
59
  end
60
60
 
61
61
  end
62
62
 
63
63
  context "and a value does not match" do
64
64
 
65
- before(:each) do
66
- value_matchers.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
65
+ before(:example) do
66
+ value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
67
67
 
68
68
  non_matching_value = value_matchers[1]
69
- non_matching_value.stub(:match?).with("another #{non_matching_value}").and_return(false)
69
+ allow(non_matching_value).to receive(:match?).with("another #{non_matching_value}").and_return(false)
70
70
  end
71
71
 
72
- it "should return false" do
73
- value_matcher_hash.match?(provided_hash).should be_false
72
+ it "returns false" do
73
+ expect(value_matcher_hash.match?(provided_hash)).to be_falsey
74
74
  end
75
75
 
76
76
  end
@@ -81,19 +81,19 @@ describe HttpStub::Models::HashWithStringValueMatchers do
81
81
 
82
82
  let(:provided_hash) { { "key1" => "value1", "differentkey2" => "another value2", "key3" => "value3" } }
83
83
 
84
- it "should determine if the corresponding value matches nil" do
84
+ it "determines if the corresponding value matches nil" do
85
85
  expected_values = [ "value1", nil, "value3" ]
86
86
  value_matchers.zip(expected_values).each do |value_matcher, expected_value|
87
- value_matcher.stub(:match?).with(expected_value)
87
+ allow(value_matcher).to receive(:match?).with(expected_value)
88
88
  end
89
89
 
90
90
  value_matcher_hash.match?(provided_hash)
91
91
  end
92
92
 
93
- it "should return the result of evaluating the value matchers" do
94
- value_matchers.each { |value| value.stub(:match?).and_return(true) }
93
+ it "returns the result of evaluating the value matchers" do
94
+ value_matchers.each { |value| allow(value).to receive(:match?).and_return(true) }
95
95
 
96
- value_matcher_hash.match?(provided_hash).should be_true
96
+ expect(value_matcher_hash.match?(provided_hash)).to be_truthy
97
97
  end
98
98
 
99
99
  end
@@ -111,12 +111,12 @@ describe HttpStub::Models::HashWithStringValueMatchers do
111
111
 
112
112
  context "and it has matching keys and values" do
113
113
 
114
- before(:each) do
115
- value_matchers.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
114
+ before(:example) do
115
+ value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
116
116
  end
117
117
 
118
- it "should return true" do
119
- value_matcher_hash.match?(provided_hash).should be_true
118
+ it "returns true" do
119
+ expect(value_matcher_hash.match?(provided_hash)).to be_truthy
120
120
  end
121
121
 
122
122
  end
@@ -133,8 +133,8 @@ describe HttpStub::Models::HashWithStringValueMatchers do
133
133
 
134
134
  let(:provided_hash) { { "key" => "value" } }
135
135
 
136
- it "should return true" do
137
- value_matcher_hash.match?(provided_hash).should be_true
136
+ it "returns true" do
137
+ expect(value_matcher_hash.match?(provided_hash)).to be_truthy
138
138
  end
139
139
 
140
140
  end
@@ -143,8 +143,8 @@ describe HttpStub::Models::HashWithStringValueMatchers do
143
143
 
144
144
  let(:provided_hash) { {} }
145
145
 
146
- it "should return true" do
147
- value_matcher_hash.match?(provided_hash).should be_true
146
+ it "returns true" do
147
+ expect(value_matcher_hash.match?(provided_hash)).to be_truthy
148
148
  end
149
149
 
150
150
  end