Class: Test::Spec::Rails::DummyResponse

Inherits:
TestDummy
  • Object
show all
Defined in:
lib/test/spec/rails/dummy_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TestDummy

#inspect, #method_missing, #real_controller, #real_request, #real_response

Constructor Details

#initialize(body, headers = nil) ⇒ DummyResponse

Returns a new instance of DummyResponse.



6
7
8
9
10
11
12
13
14
# File 'lib/test/spec/rails/dummy_response.rb', line 6

def initialize(body, headers=nil)
  if headers.nil?
    response = body.instance_variable_get('@response')
    @body, @headers = response.body, response.headers
  else
    @body, @headers = body, headers
  end
  @response = self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Test::Spec::Rails::TestDummy

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/test/spec/rails/dummy_response.rb', line 4

def body
  @body
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



4
5
6
# File 'lib/test/spec/rails/dummy_response.rb', line 4

def content_type
  @content_type
end

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/test/spec/rails/dummy_response.rb', line 4

def headers
  @headers
end

Instance Method Details

#html_documentObject



16
17
18
# File 'lib/test/spec/rails/dummy_response.rb', line 16

def html_document
  @html_document ||= HTML::Document.new(@body)
end