klass_or_name<Class, String> |
The controller class or class name to match routes for. |
action<~to_s> |
The name of the action to match routes for. |
# File lib/merb-core/test/matchers/route_matchers.rb, line 9 def initialize(klass_or_name, action) @expected_controller = Class === klass_or_name ? klass_or_name.name : klass_or_name @expected_action = action.to_s end
# File lib/merb-core/test/matchers/route_matchers.rb, line 72 def actual_parameters_message " with #{(@parameter_matcher.actual || {}).inspect}" if @parameter_matcher end
# File lib/merb-core/test/matchers/route_matchers.rb, line 68 def expected_parameters_message " with #{@parameter_matcher.expected.inspect}" if @parameter_matcher end
The failure message. |
# File lib/merb-core/test/matchers/route_matchers.rb, line 58 def failure_message "expected the request to route to #{@expected_controller.to_const_string}##{@expected_action}#{expected_parameters_message}, but was #{@target_controller.to_const_string}##{@target_action}#{actual_parameters_message}" end
target<Hash> |
The route parameters to match. |
Boolean |
True if the parameter matcher created with with matches or if no parameter matcher exists. |
# File lib/merb-core/test/matchers/route_matchers.rb, line 35 def match_parameters(target) @parameter_matcher.nil? ? true : @parameter_matcher.matches?(target) end
target<Hash> |
The route parameters to match. |
Boolean |
True if the controller action and parameters match. |
# File lib/merb-core/test/matchers/route_matchers.rb, line 19 def matches?(target) @target_env = target.dup @target_controller, @target_action = @target_env.delete(:controller).to_s, @target_env.delete(:action).to_s @target_controller = "#{target.delete(:namespace)}::#{@target_controller}" if target.has_key?(:namespace) @expected_controller.snake_case == @target_controller.snake_case && @expected_action == @target_action && match_parameters(@target_env) end
The failure message to be displayed in negative matches. |
# File lib/merb-core/test/matchers/route_matchers.rb, line 64 def negative_failure_message "expected the request not to route to #{@expected_controller.camel_case}##{@expected_action}#{expected_parameters_message}, but it did" end
Creates a new paramter matcher.
parameters<Hash, ~to_param> |
The parameters to match. |
This matcher. |
If parameters is an object, then a new expected hash will be constructed with the key :id set to parameters.to_param.
# File lib/merb-core/test/matchers/route_matchers.rb, line 50 def with(parameters) @parameter_matcher = ParameterMatcher.new(parameters) self end
Generated with the Darkfish Rdoc Generator 2.