Class: MockedHttpResponse

Inherits:
Object
  • Object
show all
Includes:
HttpServletResponse
Defined in:
lib/spec/vraptor/mocked_http_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMockedHttpResponse

Returns a new instance of MockedHttpResponse.



5
6
7
8
9
# File 'lib/spec/vraptor/mocked_http_response.rb', line 5

def initialize
  @status = 200
  @headers = {}
  @cookies = Array.new
end

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



3
4
5
# File 'lib/spec/vraptor/mocked_http_response.rb', line 3

def cookies
  @cookies
end

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/spec/vraptor/mocked_http_response.rb', line 3

def error
  @error
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/spec/vraptor/mocked_http_response.rb', line 3

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/spec/vraptor/mocked_http_response.rb', line 3

def status
  @status
end

#targetObject

Returns the value of attribute target.



3
4
5
# File 'lib/spec/vraptor/mocked_http_response.rb', line 3

def target
  @target
end

Instance Method Details



31
32
33
# File 'lib/spec/vraptor/mocked_http_response.rb', line 31

def add_cookie(cookie)
  @cookies << cookie
end

#add_header(name, value) ⇒ Object



27
28
29
# File 'lib/spec/vraptor/mocked_http_response.rb', line 27

def add_header(name, value)
  @headers[name] = value
end

#destinationObject



23
24
25
# File 'lib/spec/vraptor/mocked_http_response.rb', line 23

def destination
  @target
end

#send_error(code, msg = '') ⇒ Object



15
16
17
# File 'lib/spec/vraptor/mocked_http_response.rb', line 15

def send_error(code, msg = '')
  @error = {:code => code, :msg => msg}
end

#send_redirect(path) ⇒ Object



19
20
21
# File 'lib/spec/vraptor/mocked_http_response.rb', line 19

def send_redirect(path)
  @target = path
end

#set_status(x) ⇒ Object



11
12
13
# File 'lib/spec/vraptor/mocked_http_response.rb', line 11

def set_status(x)
  @status = x
end