Class: Capybara::RSpecMatchers::MatchSelector

Inherits:
Matcher
  • Object
show all
Defined in:
lib/capybara/rspec/matchers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#wrap

Constructor Details

#initialize(*args) ⇒ MatchSelector

Returns a new instance of MatchSelector



193
194
195
# File 'lib/capybara/rspec/matchers.rb', line 193

def initialize(*args)
  @args = args
end

Instance Attribute Details

#failure_messageObject (readonly) Also known as: failure_message_for_should

Returns the value of attribute failure_message



191
192
193
# File 'lib/capybara/rspec/matchers.rb', line 191

def failure_message
  @failure_message
end

#failure_message_when_negatedObject (readonly) Also known as: failure_message_for_should_not

Returns the value of attribute failure_message_when_negated



191
192
193
# File 'lib/capybara/rspec/matchers.rb', line 191

def failure_message_when_negated
  @failure_message_when_negated
end

Instance Method Details

#descriptionObject



211
212
213
# File 'lib/capybara/rspec/matchers.rb', line 211

def description
  "match #{query.description}"
end

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


204
205
206
207
208
209
# File 'lib/capybara/rspec/matchers.rb', line 204

def does_not_match?(actual)
  actual.assert_not_matches_selector(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message_when_negated = e.message
  return false
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


197
198
199
200
201
202
# File 'lib/capybara/rspec/matchers.rb', line 197

def matches?(actual)
  actual.assert_matches_selector(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message = e.message
  return false
end

#queryObject



215
216
217
# File 'lib/capybara/rspec/matchers.rb', line 215

def query
  @query ||= Capybara::Queries::MatchQuery.new(*@args)
end