Parent

Class Index [+]

Quicksearch

Merb::Test::Rspec::RouteMatchers::ParameterMatcher

Attributes

expected[RW]
actual[RW]

Public Class Methods

new(hash_or_object) click to toggle source

Parameters

hash_or_object<Hash, ~to_param>

The parameters to match.

Alternatives

If hash_or_object is an object, then a new expected hash will be constructed with the key :id set to hash_or_object.to_param.

    # File lib/merb-core/test/matchers/route_matchers.rb, line 86
86:     def initialize(hash_or_object)
87:       @expected = {}
88:       case hash_or_object
89:       when Hash then @expected = hash_or_object
90:       else @expected[:id] = hash_or_object.to_param
91:       end
92:     end

Public Instance Methods

failure_message() click to toggle source

Returns

String

The failure message.

     # File lib/merb-core/test/matchers/route_matchers.rb, line 108
108:     def failure_message
109:       "expected the route to contain parameters #{@expected.inspect}, but instead contained #{@actual.inspect}"
110:     end
matches?(parameter_hash) click to toggle source

Parameters

parameter_hash

The route parameters to match.

Returns

Boolean

True if the route parameters match the expected ones.

     # File lib/merb-core/test/matchers/route_matchers.rb, line 99
 99:     def matches?(parameter_hash)
100:       @actual = parameter_hash.dup.except(:controller, :action)
101: 
102:       return @actual.empty? if @expected.empty?
103:       @expected.all? {|(k, v)| @actual.has_key?(k) && @actual[k] == v}
104:     end
negative_failure_message() click to toggle source

Returns

String

The failure message to be displayed in negative matches.

     # File lib/merb-core/test/matchers/route_matchers.rb, line 114
114:     def negative_failure_message
115:       "expected the route not to contain parameters #{@expected.inspect}, but it did"
116:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.