http_stub 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e6b513e163138fb09f45fcd3ad25690c0e49720
4
- data.tar.gz: d01a275fbc644b47ca4c13f38082112ad99d9810
3
+ metadata.gz: 75535217ff4857d46b0848a19809db63b7bfecbe
4
+ data.tar.gz: ce77b9eb4347fe6713abdfd6d346aad8a81ac371
5
5
  SHA512:
6
- metadata.gz: c73d28013f716113eeda47db419e4e4b7bd6c2c25152369ec9d9570c388e4fa7f3a8585b64314be7cca267aba2bdb11b73be2a29d492e9ab816a69544740cbd3
7
- data.tar.gz: 4ee8e85dd25bd6c87ae6b501e6d4f9012d49d036c43c84897779e33725db7dc7eee9b71b1bd650cc01935d1665fd6029595f1784f1169baed93a292cdc27a66a
6
+ metadata.gz: c00f25eafc1aa46f84266e399d759c301d37937c07b6cadeef9cc70b7ac3d43ff4a87ac5c53d9ed3049f755f60da51839f164bcf1f890a4126da00574f553378
7
+ data.tar.gz: 834af43f6a410d5b1e441e6fe80d0f10bfb517645534883cd5e9b8cbddc72251279052e279919bc91060c2c009a6915ae23a995302a0f1f0f9a30d36a6ead2d9
@@ -15,7 +15,7 @@ module HttpStub
15
15
  @server.add_one_stub_scenario!(name) do |stub_builder|
16
16
  stub_builder.merge!(@default_stub_builder)
17
17
  stub_builder.respond_with(response_overrides)
18
- stub_builder.invoke(&block)
18
+ stub_builder.invoke(&block) if block_given?
19
19
  end
20
20
  end
21
21
 
@@ -1,3 +1,3 @@
1
1
  module HttpStub
2
- VERSION = "0.18.0".freeze
2
+ VERSION = "0.18.1".freeze
3
3
  end
@@ -90,16 +90,12 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
90
90
 
91
91
  describe "#add_scenario!" do
92
92
 
93
- let(:name) { "some_scenario_name" }
94
- let(:response_overrides) { {} }
95
- let(:block_verifier) { double("BlockVerifier") }
96
- let(:block) { lambda { block_verifier.verify } }
97
-
98
- let(:stub_builder) { instance_double(HttpStub::Configurer::DSL::StubBuilder).as_null_object }
93
+ let(:name) { "some_scenario_name" }
94
+ let(:stub_builder) { instance_double(HttpStub::Configurer::DSL::StubBuilder).as_null_object }
99
95
 
100
96
  before(:example) { allow(server).to receive(:add_one_stub_scenario!).and_yield(stub_builder) }
101
97
 
102
- subject { endpoint_template.add_scenario!(name, response_overrides, &block) }
98
+ subject { endpoint_template.add_scenario!(name) }
103
99
 
104
100
  it "add a one stub scenario to the server" do
105
101
  expect(server).to receive(:add_one_stub_scenario!).with(name)
@@ -117,6 +113,8 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
117
113
 
118
114
  let(:response_overrides) { { status: 302 } }
119
115
 
116
+ subject { endpoint_template.add_scenario!(name, response_overrides) }
117
+
120
118
  it "informs the stub builder to respond with the response overrides" do
121
119
  expect(stub_builder).to receive(:respond_with).with(response_overrides)
122
120
 
@@ -127,7 +125,7 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
127
125
 
128
126
  context "when response overrides are not provided" do
129
127
 
130
- subject { endpoint_template.add_scenario!(name, &block) }
128
+ subject { endpoint_template.add_scenario!(name) }
131
129
 
132
130
  it "does not change the stub builder by requesting it respond with an empty hash" do
133
131
  expect(stub_builder).to receive(:respond_with).with({})
@@ -144,18 +142,39 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
144
142
  subject
145
143
  end
146
144
 
147
- it "requests the added stub builder invoke the provided block" do
148
- expect(stub_builder).to receive(:invoke).and_yield
149
- expect(block_verifier).to receive(:verify)
145
+ context "when a block is provided" do
146
+
147
+ let(:block_verifier) { double("BlockVerifier") }
148
+ let(:block) { lambda { block_verifier.verify } }
149
+
150
+ subject { endpoint_template.add_scenario!(name, &block) }
151
+
152
+ it "requests the added stub builder invoke the provided block" do
153
+ expect(stub_builder).to receive(:invoke).and_yield
154
+ expect(block_verifier).to receive(:verify)
155
+
156
+ subject
157
+ end
158
+
159
+ it "applies the response overrides before invoking the provided block" do
160
+ expect(stub_builder).to receive(:respond_with).ordered
161
+ expect(stub_builder).to receive(:invoke).ordered
162
+
163
+ subject
164
+ end
150
165
 
151
- subject
152
166
  end
153
167
 
154
- it "applies the response overrides before invoking the provided block" do
155
- expect(stub_builder).to receive(:respond_with).ordered
156
- expect(stub_builder).to receive(:invoke).ordered
168
+ context "when a block is not provided" do
169
+
170
+ subject { endpoint_template.add_scenario!(name) }
171
+
172
+ it "does not requests the added stub builder invoke a block" do
173
+ expect(stub_builder).not_to receive(:invoke)
174
+
175
+ subject
176
+ end
157
177
 
158
- subject
159
178
  end
160
179
 
161
180
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_stub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ueckerman