Class: Merb::Test::Rspec::ControllerMatchers::BeSuccess

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-core/test/matchers/controller_matchers.rb

Instance Method Summary collapse

Instance Method Details

#failure_messageObject

Returns

String

The failure message.



100
101
102
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 100

def failure_message
  "expected#{inspect_target} to be successful but was #{status_code}"
end

#inspect_targetObject

Returns

String

The controller and action name.



112
113
114
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 112

def inspect_target
  " #{@target.controller_name}##{@target.action_name}" if @target.respond_to?(:controller_name) && @target.respond_to?(:action_name)
end

#matches?(target) ⇒ Boolean

Parameters

target<Fixnum, ~status>

Either the status code or a controller with a status code.

Returns

Boolean

True if the status code is in the range 200..207.

Returns:

  • (Boolean)


93
94
95
96
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 93

def matches?(target)
  @target = target
  (200..207).include?(status_code)
end

#negative_failure_messageObject

Returns

String

The failure message to be displayed in negative matches.



106
107
108
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 106

def negative_failure_message
  "expected#{inspect_target} not to be successful but it was #{status_code}"
end

#status_codeObject

Returns

Fixnum

Either the target’s status or the target itself.



118
119
120
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 118

def status_code
  @target.respond_to?(:status) ? @target.status : @target
end