Class Merb::Test::Rspec::RouteMatchers::ParameterMatcher
In: merb-core/lib/merb-core/test/matchers/route_matchers.rb
Parent: Object

Methods

Attributes

actual  [RW] 
expected  [RW] 

Public Class methods

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.

[Source]

    # File merb-core/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

Returns

String:The failure message.

[Source]

     # File merb-core/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

Parameters

parameter_hash<Hash>:The route parameters to match.

Returns

Boolean:True if the route parameters match the expected ones.

[Source]

     # File merb-core/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

Returns

String:The failure message to be displayed in negative matches.

[Source]

     # File merb-core/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

[Validate]