Class: Alice::Adapter::Test
- Inherits:
-
Middleware
- Object
- Middleware
- Alice::Adapter::Test
- Defined in:
- lib/alice/adapter/test.rb
Overview
Defined Under Namespace
Instance Attribute Summary collapse
-
#stubs ⇒ Object
Returns the value of attribute stubs.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #configure {|stubs| ... } ⇒ Object
-
#initialize(app, stubs = nil, &block) ⇒ Test
constructor
A new instance of Test.
Methods inherited from Middleware
#create_form_params, #full_path_for, #process_body_for_request, setup_parallel_manager
Constructor Details
Instance Attribute Details
#stubs ⇒ Object
Returns the value of attribute stubs.
15 16 17 |
# File 'lib/alice/adapter/test.rb', line 15 def stubs @stubs end |
Class Method Details
.loaded? ⇒ Boolean
17 |
# File 'lib/alice/adapter/test.rb', line 17 def self.loaded?() false end |
Instance Method Details
#call(env) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/alice/adapter/test.rb', line 77 def call(env) if stub = stubs.match(env[:method], env[:url].path, env[:body]) status, headers, body = stub.block.call(env) env.update \ :status => status, :response_headers => headers, :body => body else raise "no stubbed request for #{env[:method]} #{env[:url].path} with #{env[:body]}" end @app.call(env) end |
#configure {|stubs| ... } ⇒ Object
73 74 75 |
# File 'lib/alice/adapter/test.rb', line 73 def configure yield stubs end |