Class: Capybara::RSpecMatchers::HaveText
- Inherits:
-
Object
- Object
- Capybara::RSpecMatchers::HaveText
- Defined in:
- lib/capybara/rspec/matchers.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
- #format(text) ⇒ Object
-
#initialize(text) ⇒ HaveText
constructor
A new instance of HaveText.
- #matches?(actual) ⇒ Boolean
- #wrap(actual) ⇒ Object
Constructor Details
#initialize(text) ⇒ HaveText
Returns a new instance of HaveText.
36 37 38 |
# File 'lib/capybara/rspec/matchers.rb', line 36 def initialize(text) @text = text end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
34 35 36 |
# File 'lib/capybara/rspec/matchers.rb', line 34 def text @text end |
Instance Method Details
#description ⇒ Object
58 59 60 |
# File 'lib/capybara/rspec/matchers.rb', line 58 def description "have text #{format(text)}" end |
#does_not_match?(actual) ⇒ Boolean
45 46 47 48 |
# File 'lib/capybara/rspec/matchers.rb', line 45 def does_not_match?(actual) @actual = wrap(actual) @actual.has_no_text?(text) end |
#failure_message_for_should ⇒ Object
50 51 52 |
# File 'lib/capybara/rspec/matchers.rb', line 50 def "expected there to be text #{format(text)} in #{format(@actual.text)}" end |
#failure_message_for_should_not ⇒ Object
54 55 56 |
# File 'lib/capybara/rspec/matchers.rb', line 54 def "expected there not to be text #{format(text)} in #{format(@actual.text)}" end |
#format(text) ⇒ Object
70 71 72 73 |
# File 'lib/capybara/rspec/matchers.rb', line 70 def format(text) text = Capybara::Helpers.normalize_whitespace(text) unless text.is_a? Regexp text.inspect end |
#matches?(actual) ⇒ Boolean
40 41 42 43 |
# File 'lib/capybara/rspec/matchers.rb', line 40 def matches?(actual) @actual = wrap(actual) @actual.has_text?(text) end |