http_stub 0.19.1 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +13 -5
  2. data/lib/http_stub.rb +26 -21
  3. data/lib/http_stub/configurer/server/command_processor.rb +1 -0
  4. data/lib/http_stub/server/application.rb +24 -46
  5. data/lib/http_stub/server/formatted_hash.rb +18 -0
  6. data/lib/http_stub/server/header_parser.rb +17 -0
  7. data/lib/http_stub/server/registry.rb +9 -9
  8. data/lib/http_stub/server/request.rb +19 -0
  9. data/lib/http_stub/server/request_pipeline.rb +27 -0
  10. data/lib/http_stub/server/response.rb +7 -3
  11. data/lib/http_stub/server/scenario.rb +1 -1
  12. data/lib/http_stub/server/scenario/activator.rb +4 -4
  13. data/lib/http_stub/server/scenario/controller.rb +8 -8
  14. data/lib/http_stub/server/scenario/{request_parser.rb → parser.rb} +2 -2
  15. data/lib/http_stub/server/scenario/{instance.rb → scenario.rb} +2 -2
  16. data/lib/http_stub/server/stub.rb +1 -1
  17. data/lib/http_stub/server/stub/controller.rb +8 -8
  18. data/lib/http_stub/server/stub/empty.rb +34 -0
  19. data/lib/http_stub/server/stub/match/exact_value_matcher.rb +17 -0
  20. data/lib/http_stub/server/stub/match/hash_with_string_value_matchers.rb +26 -0
  21. data/lib/http_stub/server/stub/match/match.rb +20 -0
  22. data/lib/http_stub/server/stub/match/omitted_value_matcher.rb +23 -0
  23. data/lib/http_stub/server/stub/match/regexp_value_matcher.rb +18 -0
  24. data/lib/http_stub/server/stub/match/rule/body.rb +49 -0
  25. data/lib/http_stub/server/stub/match/rule/headers.rb +31 -0
  26. data/lib/http_stub/server/stub/match/rule/json_body.rb +39 -0
  27. data/lib/http_stub/server/stub/match/rule/method.rb +27 -0
  28. data/lib/http_stub/server/stub/match/rule/parameters.rb +27 -0
  29. data/lib/http_stub/server/stub/match/rule/simple_body.rb +27 -0
  30. data/lib/http_stub/server/stub/match/rule/uri.rb +27 -0
  31. data/lib/http_stub/server/stub/match/string_value_matcher.rb +33 -0
  32. data/lib/http_stub/server/stub/match/truthy_matcher.rb +25 -0
  33. data/lib/http_stub/server/stub/{request_parser.rb → parser.rb} +2 -2
  34. data/lib/http_stub/server/stub/payload_file_consolidator.rb +1 -1
  35. data/lib/http_stub/server/stub/registry.rb +16 -8
  36. data/lib/http_stub/server/stub/response/base.rb +2 -2
  37. data/lib/http_stub/server/stub/stub.rb +44 -0
  38. data/lib/http_stub/server/stub/triggers.rb +2 -2
  39. data/lib/http_stub/server/views/_match.haml +20 -0
  40. data/lib/http_stub/server/views/matches.haml +3 -0
  41. data/lib/http_stub/server/views/stub.haml +1 -0
  42. data/lib/http_stub/version.rb +1 -1
  43. data/spec/acceptance/stub_control_values_spec.rb +6 -3
  44. data/spec/acceptance/stub_match_spec.rb +142 -0
  45. data/spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb +4 -0
  46. data/spec/lib/http_stub/server/application_integration_spec.rb +17 -18
  47. data/spec/lib/http_stub/server/application_spec.rb +81 -53
  48. data/spec/lib/http_stub/server/formatted_hash_spec.rb +54 -0
  49. data/spec/lib/http_stub/server/{stub/request_header_parser_spec.rb → header_parser_spec.rb} +9 -9
  50. data/spec/lib/http_stub/server/{request_file_consolidator_spec.rb → payload_file_consolidator_spec.rb} +4 -4
  51. data/spec/lib/http_stub/server/registry_spec.rb +13 -14
  52. data/spec/lib/http_stub/server/request_pipeline_spec.rb +80 -0
  53. data/spec/lib/http_stub/server/request_spec.rb +113 -0
  54. data/spec/lib/http_stub/server/response_spec.rb +46 -12
  55. data/spec/lib/http_stub/server/scenario/activator_spec.rb +18 -18
  56. data/spec/lib/http_stub/server/scenario/controller_spec.rb +18 -15
  57. data/spec/lib/http_stub/server/scenario/{request_parser_spec.rb → parser_spec.rb} +8 -8
  58. data/spec/lib/http_stub/server/scenario/{instance_spec.rb → scenario_spec.rb} +7 -5
  59. data/spec/lib/http_stub/server/scenario_spec.rb +3 -3
  60. data/spec/lib/http_stub/server/stub/controller_spec.rb +29 -14
  61. data/spec/lib/http_stub/server/stub/empty_spec.rb +68 -0
  62. data/spec/lib/http_stub/server/stub/{exact_value_matcher_spec.rb → match/exact_value_matcher_spec.rb} +2 -2
  63. data/spec/lib/http_stub/server/stub/{hash_with_string_value_matchers_spec.rb → match/hash_with_string_value_matchers_spec.rb} +27 -19
  64. data/spec/lib/http_stub/server/stub/match/match_spec.rb +40 -0
  65. data/spec/lib/http_stub/server/stub/{omitted_value_matcher_spec.rb → match/omitted_value_matcher_spec.rb} +2 -2
  66. data/spec/lib/http_stub/server/stub/{regexp_value_matcher_spec.rb → match/regexp_value_matcher_spec.rb} +2 -2
  67. data/spec/lib/http_stub/server/stub/{request_body_spec.rb → match/rule/body_spec.rb} +12 -12
  68. data/spec/lib/http_stub/server/stub/match/rule/headers_spec.rb +90 -0
  69. data/spec/lib/http_stub/server/stub/{json_request_body_spec.rb → match/rule/json_body_spec.rb} +9 -10
  70. data/spec/lib/http_stub/server/stub/{method_spec.rb → match/rule/method_spec.rb} +6 -5
  71. data/spec/lib/http_stub/server/stub/{request_parameters_spec.rb → match/rule/parameters_spec.rb} +16 -10
  72. data/spec/lib/http_stub/server/stub/match/rule/simple_body_spec.rb +46 -0
  73. data/spec/lib/http_stub/server/stub/match/rule/uri_spec.rb +46 -0
  74. data/spec/lib/http_stub/server/stub/{string_value_matcher_spec.rb → match/string_value_matcher_spec.rb} +30 -26
  75. data/spec/lib/http_stub/server/stub/match/truthy_matcher_spec.rb +24 -0
  76. data/spec/lib/http_stub/server/stub/{request_parser_spec.rb → parser_spec.rb} +7 -7
  77. data/spec/lib/http_stub/server/stub/registry_integration_spec.rb +5 -5
  78. data/spec/lib/http_stub/server/stub/registry_spec.rb +114 -43
  79. data/spec/lib/http_stub/server/stub/response/base_spec.rb +8 -2
  80. data/spec/lib/http_stub/server/stub/stub_spec.rb +294 -0
  81. data/spec/lib/http_stub/server/stub/triggers_spec.rb +4 -4
  82. data/spec/lib/http_stub/server/stub_spec.rb +3 -3
  83. data/spec/spec_helper.rb +7 -3
  84. data/spec/support/configurer_integration.rb +1 -0
  85. data/spec/support/http_stub/empty_configurer.rb +7 -0
  86. data/spec/support/{scenario_fixture.rb → http_stub/scenario_fixture.rb} +0 -0
  87. data/spec/support/http_stub/server/request_fixture.rb +25 -0
  88. data/spec/support/http_stub/server/scenario/scenario_fixture.rb +15 -0
  89. data/spec/support/http_stub/server/stub/match/match_fixture.rb +17 -0
  90. data/spec/support/{stub_fixture.rb → http_stub/stub_fixture.rb} +0 -0
  91. data/spec/support/server_integration.rb +1 -0
  92. metadata +315 -290
  93. data/lib/http_stub/server/stub/exact_value_matcher.rb +0 -15
  94. data/lib/http_stub/server/stub/hash_with_string_value_matchers.rb +0 -22
  95. data/lib/http_stub/server/stub/headers.rb +0 -19
  96. data/lib/http_stub/server/stub/instance.rb +0 -32
  97. data/lib/http_stub/server/stub/json_request_body.rb +0 -35
  98. data/lib/http_stub/server/stub/method.rb +0 -23
  99. data/lib/http_stub/server/stub/omitted_value_matcher.rb +0 -21
  100. data/lib/http_stub/server/stub/regexp_value_matcher.rb +0 -16
  101. data/lib/http_stub/server/stub/request_body.rb +0 -44
  102. data/lib/http_stub/server/stub/request_header_parser.rb +0 -19
  103. data/lib/http_stub/server/stub/request_headers.rb +0 -28
  104. data/lib/http_stub/server/stub/request_parameters.rb +0 -23
  105. data/lib/http_stub/server/stub/simple_request_body.rb +0 -23
  106. data/lib/http_stub/server/stub/string_value_matcher.rb +0 -31
  107. data/lib/http_stub/server/stub/truthy_request_matcher.rb +0 -23
  108. data/lib/http_stub/server/stub/uri.rb +0 -23
  109. data/spec/lib/http_stub/server/stub/headers_spec.rb +0 -51
  110. data/spec/lib/http_stub/server/stub/instance_spec.rb +0 -235
  111. data/spec/lib/http_stub/server/stub/request_headers_spec.rb +0 -68
  112. data/spec/lib/http_stub/server/stub/simple_request_body_spec.rb +0 -43
  113. data/spec/lib/http_stub/server/stub/truthy_request_matcher_spec.rb +0 -23
  114. data/spec/lib/http_stub/server/stub/uri_spec.rb +0 -43
@@ -1,24 +1,26 @@
1
1
  describe HttpStub::Server::Stub::Controller do
2
2
 
3
- let(:request) { instance_double(Rack::Request) }
3
+ let(:request) { instance_double(HttpStub::Server::Request) }
4
+ let(:logger) { instance_double(Logger) }
4
5
  let(:payload) { HttpStub::StubFixture.new.server_payload }
5
6
  let(:response) { instance_double(HttpStub::Server::Stub::Response::Base) }
6
- let(:the_stub) { instance_double(HttpStub::Server::Stub::Instance, response: response) }
7
+ let(:stub_uri) { "/some/stub/uri" }
8
+ let(:the_stub) { instance_double(HttpStub::Server::Stub::Stub, response: response, stub_uri: stub_uri) }
7
9
  let(:registry) { instance_double(HttpStub::Server::Stub::Registry).as_null_object }
8
10
 
9
11
  let(:controller) { HttpStub::Server::Stub::Controller.new(registry) }
10
12
 
11
13
  before(:example) do
12
- allow(HttpStub::Server::Stub::RequestParser).to receive(:parse).and_return(payload)
14
+ allow(HttpStub::Server::Stub::Parser).to receive(:parse).and_return(payload)
13
15
  allow(HttpStub::Server::Stub).to receive(:create).and_return(the_stub)
14
16
  end
15
17
 
16
18
  describe "#register" do
17
19
 
18
- subject { controller.register(request) }
20
+ subject { controller.register(request, logger) }
19
21
 
20
22
  it "parses the payload from the request" do
21
- expect(HttpStub::Server::Stub::RequestParser).to receive(:parse).with(request).and_return(payload)
23
+ expect(HttpStub::Server::Stub::Parser).to receive(:parse).with(request).and_return(payload)
22
24
 
23
25
  subject
24
26
  end
@@ -30,37 +32,48 @@ describe HttpStub::Server::Stub::Controller do
30
32
  end
31
33
 
32
34
  it "adds the stub to the stub registry" do
33
- expect(registry).to receive(:add).with(the_stub, request)
35
+ expect(registry).to receive(:add).with(the_stub, logger)
34
36
 
35
37
  subject
36
38
  end
37
39
 
38
- it "returns a success response" do
39
- expect(subject).to eql(HttpStub::Server::Response::SUCCESS)
40
+ it "creates a success response with a location header containing the stubs uri" do
41
+ expect(HttpStub::Server::Response).to receive(:success).with("location" => stub_uri)
42
+
43
+ subject
44
+ end
45
+
46
+ it "returns the success response" do
47
+ response = double("HttpStub::Server::Response")
48
+ allow(HttpStub::Server::Response).to receive(:success).and_return(response)
49
+
50
+ expect(subject).to eql(response)
40
51
  end
41
52
 
42
53
  end
43
54
 
44
55
  describe "#replay" do
45
56
 
57
+ subject { controller.replay(request, logger) }
58
+
46
59
  describe "when a stub has been registered that should be replayed for the request" do
47
60
 
48
- before(:example) { allow(registry).to receive(:find_for).with(request).and_return(the_stub) }
61
+ before(:example) { allow(registry).to receive(:find).with(request, logger).and_return(the_stub) }
49
62
 
50
63
  it "returns the stubs response" do
51
64
  expect(the_stub).to receive(:response).and_return(response)
52
65
 
53
- expect(controller.replay(request)).to eql(response)
66
+ expect(subject).to eql(response)
54
67
  end
55
68
 
56
69
  end
57
70
 
58
71
  describe "when no stub should be replayed for the request" do
59
72
 
60
- before(:example) { allow(registry).to receive(:find_for).with(request).and_return(nil) }
73
+ before(:example) { allow(registry).to receive(:find).with(request, logger).and_return(nil) }
61
74
 
62
75
  it "returns an empty response" do
63
- expect(controller.replay(request)).to eql(HttpStub::Server::Response::EMPTY)
76
+ expect(subject).to eql(HttpStub::Server::Response::EMPTY)
64
77
  end
65
78
 
66
79
  end
@@ -69,10 +82,12 @@ describe HttpStub::Server::Stub::Controller do
69
82
 
70
83
  describe "#clear" do
71
84
 
85
+ subject { controller.clear(logger) }
86
+
72
87
  it "clears the stub registry" do
73
- expect(registry).to receive(:clear).with(request)
88
+ expect(registry).to receive(:clear).with(logger)
74
89
 
75
- controller.clear(request)
90
+ subject
76
91
  end
77
92
 
78
93
  end
@@ -0,0 +1,68 @@
1
+ describe HttpStub::Server::Stub::Empty do
2
+
3
+ let(:empty_stub) { HttpStub::Server::Stub::Empty::INSTANCE }
4
+
5
+ %w{ uri method stub_uri body }.each do |empty_string_attribute|
6
+
7
+ describe "##{empty_string_attribute}" do
8
+
9
+ it "is an empty string" do
10
+ expect(empty_stub.send(empty_string_attribute.to_sym)).to eql("")
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ %w{ headers parameters }.each do |empty_hash_attribute|
18
+
19
+ describe "##{empty_hash_attribute}" do
20
+
21
+ it "is an empty hash" do
22
+ expect(empty_stub.send(empty_hash_attribute.to_sym)).to eql({})
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ describe "#triggers" do
30
+
31
+ it "is an empty array" do
32
+ expect(empty_stub.triggers).to eql([])
33
+ end
34
+
35
+ end
36
+
37
+ describe "#response" do
38
+
39
+ it "is empty" do
40
+ expect(empty_stub.response).to eql(HttpStub::Server::Response::EMPTY)
41
+ end
42
+
43
+ end
44
+
45
+ describe "#matches?" do
46
+
47
+ let(:criteria) { double("MatchCriteria") }
48
+ let(:logger) { instance_double(Logger) }
49
+
50
+ it "returns false" do
51
+ expect(empty_stub.matches?(criteria, logger)).to eql(false)
52
+ end
53
+
54
+ end
55
+
56
+ describe "#to_s" do
57
+
58
+ it "returns an empty string" do
59
+ expect(empty_stub.to_s).to eql("")
60
+ end
61
+
62
+ end
63
+
64
+ it "defines all the methods on a convetional Stub" do
65
+ expect(HttpStub::Server::Stub::Empty.instance_methods).to include(*HttpStub::Server::Stub::Stub.instance_methods)
66
+ end
67
+
68
+ end
@@ -1,4 +1,4 @@
1
- describe HttpStub::Server::Stub::ExactValueMatcher do
1
+ describe HttpStub::Server::Stub::Match::ExactValueMatcher do
2
2
 
3
3
  describe "::match?" do
4
4
 
@@ -25,7 +25,7 @@ describe HttpStub::Server::Stub::ExactValueMatcher do
25
25
  end
26
26
 
27
27
  def perform_match
28
- HttpStub::Server::Stub::ExactValueMatcher.match?(stub_value, actual_value)
28
+ HttpStub::Server::Stub::Match::ExactValueMatcher.match?(stub_value, actual_value)
29
29
  end
30
30
 
31
31
  end
@@ -1,4 +1,4 @@
1
- describe HttpStub::Server::Stub::HashWithStringValueMatchers do
1
+ describe HttpStub::Server::Stub::Match::HashWithStringValueMatchers do
2
2
 
3
3
  let(:stubbed_hash) do
4
4
  (1..3).reduce({}) do |result, i|
@@ -8,14 +8,16 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
8
8
  end
9
9
 
10
10
  let(:value_matchers) do
11
- stubbed_hash.values.map { |value| double(HttpStub::Server::Stub::StringValueMatcher, to_s: value).as_null_object }
11
+ stubbed_hash.values.map do |value|
12
+ double(HttpStub::Server::Stub::Match::StringValueMatcher, to_s: value).as_null_object
13
+ end
12
14
  end
13
15
 
14
- let(:value_matcher_hash) { HttpStub::Server::Stub::HashWithStringValueMatchers.new(stubbed_hash) }
16
+ let(:value_matcher_hash) { HttpStub::Server::Stub::Match::HashWithStringValueMatchers.new(stubbed_hash) }
15
17
 
16
18
  before(:example) do
17
19
  value_matchers.each do |value|
18
- allow(HttpStub::Server::Stub::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value)
20
+ allow(HttpStub::Server::Stub::Match::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value)
19
21
  end
20
22
  end
21
23
 
@@ -27,7 +29,7 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
27
29
 
28
30
  it "creates a value matcher representation of each value in the hash" do
29
31
  value_matchers.each do |value|
30
- expect(HttpStub::Server::Stub::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value)
32
+ expect(HttpStub::Server::Stub::Match::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value)
31
33
  end
32
34
 
33
35
  expect(value_matcher_hash.values).to eql(value_matchers)
@@ -35,7 +37,9 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
35
37
 
36
38
  end
37
39
 
38
- describe "#match?" do
40
+ describe "#matches?" do
41
+
42
+ subject { value_matcher_hash.matches?(provided_hash) }
39
43
 
40
44
  context "when the stubbed hash contains multiple entries" do
41
45
 
@@ -53,11 +57,13 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
53
57
  context "and the values match" do
54
58
 
55
59
  before(:example) do
56
- value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
60
+ value_matchers.each do |value|
61
+ allow(value).to receive(:matches?).with("another #{value}").and_return(true)
62
+ end
57
63
  end
58
64
 
59
65
  it "returns true" do
60
- expect(value_matcher_hash.match?(provided_hash)).to be_truthy
66
+ expect(subject).to be(true)
61
67
  end
62
68
 
63
69
  end
@@ -65,14 +71,16 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
65
71
  context "and a value does not match" do
66
72
 
67
73
  before(:example) do
68
- value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
74
+ value_matchers.each do |value|
75
+ allow(value).to receive(:matches?).with("another #{value}").and_return(true)
76
+ end
69
77
 
70
78
  non_matching_value = value_matchers[1]
71
- allow(non_matching_value).to receive(:match?).with("another #{non_matching_value}").and_return(false)
79
+ allow(non_matching_value).to receive(:matches?).with("another #{non_matching_value}").and_return(false)
72
80
  end
73
81
 
74
82
  it "returns false" do
75
- expect(value_matcher_hash.match?(provided_hash)).to be_falsey
83
+ expect(subject).to be(false)
76
84
  end
77
85
 
78
86
  end
@@ -86,16 +94,16 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
86
94
  it "determines if the corresponding value matches nil" do
87
95
  expected_values = [ "value1", nil, "value3" ]
88
96
  value_matchers.zip(expected_values).each do |value_matcher, expected_value|
89
- allow(value_matcher).to receive(:match?).with(expected_value)
97
+ allow(value_matcher).to receive(:matches?).with(expected_value)
90
98
  end
91
99
 
92
- value_matcher_hash.match?(provided_hash)
100
+ subject
93
101
  end
94
102
 
95
103
  it "returns the result of evaluating the value matchers" do
96
- value_matchers.each { |value| allow(value).to receive(:match?).and_return(true) }
104
+ value_matchers.each { |value| allow(value).to receive(:matches?).and_return(true) }
97
105
 
98
- expect(value_matcher_hash.match?(provided_hash)).to be_truthy
106
+ expect(subject).to be(true)
99
107
  end
100
108
 
101
109
  end
@@ -114,11 +122,11 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
114
122
  context "and it has matching keys and values" do
115
123
 
116
124
  before(:example) do
117
- value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
125
+ value_matchers.each { |value| allow(value).to receive(:matches?).with("another #{value}").and_return(true) }
118
126
  end
119
127
 
120
128
  it "returns true" do
121
- expect(value_matcher_hash.match?(provided_hash)).to be_truthy
129
+ expect(subject).to be(true)
122
130
  end
123
131
 
124
132
  end
@@ -136,7 +144,7 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
136
144
  let(:provided_hash) { { "key" => "value" } }
137
145
 
138
146
  it "returns true" do
139
- expect(value_matcher_hash.match?(provided_hash)).to be_truthy
147
+ expect(subject).to be(true)
140
148
  end
141
149
 
142
150
  end
@@ -146,7 +154,7 @@ describe HttpStub::Server::Stub::HashWithStringValueMatchers do
146
154
  let(:provided_hash) { {} }
147
155
 
148
156
  it "returns true" do
149
- expect(value_matcher_hash.match?(provided_hash)).to be_truthy
157
+ expect(subject).to be(true)
150
158
  end
151
159
 
152
160
  end
@@ -0,0 +1,40 @@
1
+ describe HttpStub::Server::Stub::Match::Match do
2
+
3
+ let(:stub) { instance_double(HttpStub::Server::Stub::Stub) }
4
+ let(:request) { instance_double(HttpStub::Server::Request) }
5
+
6
+ let(:stub_match) { HttpStub::Server::Stub::Match::Match.new(stub, request) }
7
+
8
+ describe "#stub" do
9
+
10
+ subject { stub_match.stub }
11
+
12
+ context "when a stub is provided" do
13
+
14
+ it "exposes the provided value" do
15
+ expect(subject).to eql(stub)
16
+ end
17
+
18
+ end
19
+
20
+ context "when a stub is not provided" do
21
+
22
+ let(:stub_match) { HttpStub::Server::Stub::Match::Match.new(nil, request) }
23
+
24
+ it "returns the empty stub" do
25
+ expect(subject).to eql(HttpStub::Server::Stub::Empty::INSTANCE)
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ describe "#request" do
33
+
34
+ it "exposes the provided value" do
35
+ expect(stub_match.request).to eql(request)
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -1,4 +1,4 @@
1
- describe HttpStub::Server::Stub::OmittedValueMatcher do
1
+ describe HttpStub::Server::Stub::Match::OmittedValueMatcher do
2
2
 
3
3
  describe "::match?" do
4
4
 
@@ -50,7 +50,7 @@ describe HttpStub::Server::Stub::OmittedValueMatcher do
50
50
  end
51
51
 
52
52
  def perform_match
53
- HttpStub::Server::Stub::OmittedValueMatcher.match?(stub_value, actual_value)
53
+ HttpStub::Server::Stub::Match::OmittedValueMatcher.match?(stub_value, actual_value)
54
54
  end
55
55
 
56
56
  end
@@ -1,4 +1,4 @@
1
- describe HttpStub::Server::Stub::RegexpValueMatcher do
1
+ describe HttpStub::Server::Stub::Match::RegexpValueMatcher do
2
2
 
3
3
  describe "::match?" do
4
4
 
@@ -40,7 +40,7 @@ describe HttpStub::Server::Stub::RegexpValueMatcher do
40
40
  end
41
41
 
42
42
  def perform_match
43
- HttpStub::Server::Stub::RegexpValueMatcher.match?(stub_value, actual_value)
43
+ HttpStub::Server::Stub::Match::RegexpValueMatcher.match?(stub_value, actual_value)
44
44
  end
45
45
 
46
46
  end
@@ -1,22 +1,22 @@
1
- describe HttpStub::Server::Stub::RequestBody do
1
+ describe HttpStub::Server::Stub::Match::Rule::Body do
2
2
 
3
3
  describe "::create" do
4
4
 
5
- subject { HttpStub::Server::Stub::RequestBody.create(stubbed_body) }
5
+ subject { described_class.create(stubbed_body) }
6
6
 
7
7
  shared_context "a raw request body that causes a simple request body to be created" do
8
8
 
9
9
  it "creates a simple request body with the body" do
10
- expect(HttpStub::Server::Stub::SimpleRequestBody).to receive(:new).with(stubbed_body)
10
+ expect(HttpStub::Server::Stub::Match::Rule::SimpleBody).to receive(:new).with(stubbed_body)
11
11
 
12
12
  subject
13
13
  end
14
14
 
15
15
  it "returns the created request body" do
16
- simple_request_body = instance_double(HttpStub::Server::Stub::SimpleRequestBody)
17
- allow(HttpStub::Server::Stub::SimpleRequestBody).to receive(:new).and_return(simple_request_body)
16
+ simple_body = instance_double(HttpStub::Server::Stub::Match::Rule::SimpleBody)
17
+ allow(HttpStub::Server::Stub::Match::Rule::SimpleBody).to receive(:new).and_return(simple_body)
18
18
 
19
- expect(subject).to eql(simple_request_body)
19
+ expect(subject).to eql(simple_body)
20
20
  end
21
21
 
22
22
  end
@@ -31,16 +31,16 @@ describe HttpStub::Server::Stub::RequestBody do
31
31
  let(:raw_schema) { { "type" => "json", "definition" => json_schema } }
32
32
 
33
33
  it "creates a JSON request body with the schema" do
34
- expect(HttpStub::Server::Stub::JsonRequestBody).to receive(:new).with(json_schema)
34
+ expect(HttpStub::Server::Stub::Match::Rule::JsonBody).to receive(:new).with(json_schema)
35
35
 
36
36
  subject
37
37
  end
38
38
 
39
39
  it "returns the created request body" do
40
- json_request_body = instance_double(HttpStub::Server::Stub::JsonRequestBody)
41
- allow(HttpStub::Server::Stub::JsonRequestBody).to receive(:new).and_return(json_request_body)
40
+ json_body = instance_double(HttpStub::Server::Stub::Match::Rule::JsonBody)
41
+ allow(HttpStub::Server::Stub::Match::Rule::JsonBody).to receive(:new).and_return(json_body)
42
42
 
43
- expect(subject).to eql(json_request_body)
43
+ expect(subject).to eql(json_body)
44
44
  end
45
45
 
46
46
  end
@@ -100,7 +100,7 @@ describe HttpStub::Server::Stub::RequestBody do
100
100
  let(:stubbed_body) { "" }
101
101
 
102
102
  it "returns a truthy request matcher" do
103
- expect(subject).to eql(HttpStub::Server::Stub::TruthyRequestMatcher)
103
+ expect(subject).to eql(HttpStub::Server::Stub::Match::TruthyMatcher)
104
104
  end
105
105
 
106
106
  end
@@ -110,7 +110,7 @@ describe HttpStub::Server::Stub::RequestBody do
110
110
  let(:stubbed_body) { nil }
111
111
 
112
112
  it "returns a truthy request matcher" do
113
- expect(subject).to eql(HttpStub::Server::Stub::TruthyRequestMatcher)
113
+ expect(subject).to eql(HttpStub::Server::Stub::Match::TruthyMatcher)
114
114
  end
115
115
 
116
116
  end