Module: HttpDecoy
- Defined in:
- lib/http_decoy.rb,
lib/http_decoy/route.rb,
lib/http_decoy/rspec.rb,
lib/http_decoy/router.rb,
lib/http_decoy/server.rb,
lib/http_decoy/version.rb,
lib/http_decoy/route_map.rb,
lib/http_decoy/request_log.rb,
lib/http_decoy/configuration.rb,
lib/http_decoy/handler_context.rb,
lib/http_decoy/webmock_integration.rb
Defined Under Namespace
Modules: RSpec, WebMockIntegration Classes: Configuration, Definition, HandlerContext, RequestLog, Route, RouteMap, Router, Server
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
- .configuration ⇒ Object
-
.configure {|configuration| ... } ⇒ Object
Global configuration.
-
.define(name = :default) ⇒ Object
Define a named fake service.
Class Method Details
.configuration ⇒ Object
24 25 26 |
# File 'lib/http_decoy.rb', line 24 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Global configuration.
HttpDecoy.configure do |c|
c.auto_intercept = false # opt out of WebMock auto-interception
end
20 21 22 |
# File 'lib/http_decoy.rb', line 20 def configure yield configuration end |
.define(name = :default) ⇒ Object
Define a named fake service.
FakeStripe = HttpDecoy.define(:stripe) do
base_url "https://api.stripe.com"
post "/v1/charges" do
requires_body :amount, :currency, :payment_method
respond 200, json: { id: -> { "ch_#{SecureRandom.hex(8)}" } }
end
end
RSpec.configure { |c| c.include FakeStripe.rspec_helpers }
41 42 43 44 45 46 |
# File 'lib/http_decoy.rb', line 41 def define(name = :default, &) require_relative "http_decoy/rspec" route_map = RouteMap.new route_map.instance_eval(&) Definition.new(name, route_map) end |