Class: Amfetamine::FakeResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/amfetamine/helpers/test_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(method, code2, block) ⇒ FakeResponse

Returns a new instance of FakeResponse.



89
90
91
92
93
# File 'lib/amfetamine/helpers/test_helpers.rb', line 89

def initialize(method, code2, block)
  @method = method
  @response_code = code2 || 200
  @inner_body = block.call || {}
end

Instance Method Details

#bodyObject



99
100
101
# File 'lib/amfetamine/helpers/test_helpers.rb', line 99

def body
  MultiJson.encode(@inner_body) if @inner_body
end

#codeObject



95
96
97
# File 'lib/amfetamine/helpers/test_helpers.rb', line 95

def code
  @response_code
end

#parsed_responseObject



103
104
105
106
107
108
109
# File 'lib/amfetamine/helpers/test_helpers.rb', line 103

def parsed_response
  if body
    MultiJson.decode(body)
  else
    {}
  end
end