Class: Capybara::RSpecMatchers::HaveText

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

Instance Attribute Summary

Attributes inherited from Matcher

#failure_message, #failure_message_when_negated

Instance Method Summary collapse

Methods inherited from Matcher

#wrap

Methods included from Compound

#and, #and_then, #or

Constructor Details

#initialize(*args) ⇒ HaveText

Returns a new instance of HaveText.



138
139
140
141
# File 'lib/capybara/rspec/matchers.rb', line 138

def initialize(*args)
  @args = args.dup
  @content = args[0].is_a?(Symbol) ? args[1] : args[0]
end

Instance Method Details

#descriptionObject



151
152
153
# File 'lib/capybara/rspec/matchers.rb', line 151

def description
  "text #{format(@content)}"
end

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/capybara/rspec/matchers.rb', line 147

def does_not_match?(actual)
  wrap_does_not_match?(actual) { |el| el.assert_no_text(*@args) }
end

#format(content) ⇒ Object



155
156
157
# File 'lib/capybara/rspec/matchers.rb', line 155

def format(content)
  content.inspect
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/capybara/rspec/matchers.rb', line 143

def matches?(actual)
  wrap_matches?(actual) { |el| el.assert_text(*@args) }
end