Class: Mimic::FakeHost::StubbedRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/mimic/fake_host.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, method, path) ⇒ StubbedRequest

Returns a new instance of StubbedRequest.



85
86
87
88
89
90
91
# File 'lib/mimic/fake_host.rb', line 85

def initialize(app, method, path)
  @method, @path = method, path
  @code = 200
  @headers = {}
  @body = ""
  @app = app
end

Instance Method Details

#buildObject



101
102
103
104
# File 'lib/mimic/fake_host.rb', line 101

def build
  response = [@code, @headers, @body]
  @app.send(@method.downcase, @path) { response }
end

#returning(body, code = 200, headers = {}) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/mimic/fake_host.rb', line 93

def returning(body, code = 200, headers = {})
  tap do
    @body = body
    @code = code
    @headers = headers
  end
end