lib/webmock-rspec-helper.rb in webmock-rspec-helper-0.0.1 vs lib/webmock-rspec-helper.rb in webmock-rspec-helper-0.0.3
- old
+ new
@@ -7,10 +7,13 @@
def webmock(method, mocks = {})
mocks.each do |regex, filename|
status = filename[/\.(\d+)\./, 1] || 200
body = File.read Rails.root.join('spec', 'support', 'stubs', filename)
- WebMock.stub_request(method, regex).to_return status: status.to_i, body: body
+
+ stub = WebMock.stub_request(method, regex)
+ stub.with(yield) if block_given?
+ stub.to_return status: status.to_i, body: body
end
end
end
end
\ No newline at end of file