Class: Mack::Testing::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/mack/testing/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(responses) ⇒ Response

Returns a new instance of Response.



7
8
9
# File 'lib/mack/testing/response.rb', line 7

def initialize(responses)
  self.responses = [responses].flatten
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



11
12
13
# File 'lib/mack/testing/response.rb', line 11

def method_missing(sym, *args)
  self.responses.last.send(sym, *args)
end

Instance Attribute Details

#responsesObject

Returns the value of attribute responses.



5
6
7
# File 'lib/mack/testing/response.rb', line 5

def responses
  @responses
end

Instance Method Details

#forbidden?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/mack/testing/response.rb', line 31

def forbidden?
  self.responses.first.forbidden?
end

#locationObject



43
44
45
# File 'lib/mack/testing/response.rb', line 43

def location
  self.responses.first.location
end

#not_found?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/mack/testing/response.rb', line 23

def not_found?
  self.responses.first.not_found?
end

#redirect?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/mack/testing/response.rb', line 19

def redirect?
  self.responses.first.redirect?
end

#redirected_to?(loc) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/mack/testing/response.rb', line 39

def redirected_to?(loc)
  self.location == loc
end

#server_error?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/mack/testing/response.rb', line 27

def server_error?
  self.responses.first.server_error?
end

#statusObject



35
36
37
# File 'lib/mack/testing/response.rb', line 35

def status
  self.responses.first.status
end

#successful?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/mack/testing/response.rb', line 15

def successful?
  self.responses.first.successful?
end