Class: Capybara::RSpecMatchers::HaveSelector

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

- (HaveSelector) initialize(*args)



18
19
20
# File 'lib/capybara/rspec/matchers.rb', line 18

def initialize(*args)
  @args = args
end

Instance Attribute Details

- (Object) failure_message (readonly) Also known as: failure_message_for_should

Returns the value of attribute failure_message



16
17
18
# File 'lib/capybara/rspec/matchers.rb', line 16

def failure_message
  @failure_message
end

- (Object) failure_message_when_negated (readonly) Also known as: failure_message_for_should_not

Returns the value of attribute failure_message_when_negated



16
17
18
# File 'lib/capybara/rspec/matchers.rb', line 16

def failure_message_when_negated
  @failure_message_when_negated
end

Instance Method Details

- (Object) description



36
37
38
# File 'lib/capybara/rspec/matchers.rb', line 36

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

- (Boolean) does_not_match?(actual)



29
30
31
32
33
34
# File 'lib/capybara/rspec/matchers.rb', line 29

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

- (Boolean) matches?(actual)



22
23
24
25
26
27
# File 'lib/capybara/rspec/matchers.rb', line 22

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

- (Object) query



40
41
42
# File 'lib/capybara/rspec/matchers.rb', line 40

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