Method: StubBuilder#build

Defined in:
lib/brine/test_steps.rb

#build(stubs) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/brine/test_steps.rb', line 59

def build(stubs)
  # Currently the Faraday stub code provides one method per HTTP method (which then
  # calls a generalized protected method), so this block grabs the method to use
  # and passes the right args based on the signature. The last arg is normally a block
  # but we're using the make_response method to avoid duplication and allow overriding.
  m = stubs.method(@request.method)
  case m.parameters.length
    when 3
      m.call(@request.path, @request.headers, &method(:make_response))
    when 4
      m.call(@request.path, @request.body, @request.headers, &method(:make_response))
    else
      raise "I don't know how to call #{m}"
  end
end