Class: Merb::Test::Rspec::ViewMatchers::NotMatchTag

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

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ NotMatchTag

Parameters

attrs<Hash>

A set of attributes that must not be matched.



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

def initialize(attrs)
  @attrs = attrs
end

Instance Method Details

#failure_messageObject

Returns

String

The failure message.



114
115
116
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 114

def failure_message
  @errors[0]
end

#matches?(target) ⇒ Boolean

Parameters

target<String>

The target to look for the match in.

Returns

Boolean

True if none of the attributes were matched.

Returns:

  • (Boolean)


102
103
104
105
106
107
108
109
110
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 102

def matches?(target)
  @errors = []
  @attrs.each do |attr, val|
    if target.include?("#{attr}=\"#{val}\"")
      @errors << "Should not include #{attr}=\"#{val}\", but was #{target}"
    end
  end
  @errors.size == 0
end