Class: Mock5::Api
- Inherits:
-
Object
- Object
- Mock5::Api
- Defined in:
- lib/mock5/api.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#initialize(endpoint = nil, &block) ⇒ Api
constructor
A new instance of Api.
- #request_stub ⇒ Object
Constructor Details
#initialize(endpoint = nil, &block) ⇒ Api
Returns a new instance of Api.
9 10 11 12 |
# File 'lib/mock5/api.rb', line 9 def initialize(endpoint=nil, &block) @app = Sinatra.new(&block) @endpoint = normalize_endpoint(endpoint) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/mock5/api.rb', line 7 def app @app end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
7 8 9 |
# File 'lib/mock5/api.rb', line 7 def endpoint @endpoint end |
Instance Method Details
#request_stub ⇒ Object
14 15 16 |
# File 'lib/mock5/api.rb', line 14 def request_stub @request_stub ||= WebMock::RequestStub.new(:any, endpoint).tap{ |s| s.to_rack(app) } end |