Class: Capybara::RSpecMatchers::HaveText
- Defined in:
- lib/capybara/rspec/matchers.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#failure_message ⇒ Object
(also: #failure_message_for_should)
readonly
Returns the value of attribute failure_message.
-
#failure_message_when_negated ⇒ Object
(also: #failure_message_for_should_not)
readonly
Returns the value of attribute failure_message_when_negated.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #format(content) ⇒ Object
-
#initialize(*args) ⇒ HaveText
constructor
A new instance of HaveText.
- #matches?(actual) ⇒ Boolean
Methods inherited from Matcher
Constructor Details
#initialize(*args) ⇒ HaveText
Returns a new instance of HaveText.
54 55 56 57 58 59 60 61 |
# File 'lib/capybara/rspec/matchers.rb', line 54 def initialize(*args) @args = args.dup # are set just for backwards compatability @type = args.shift if args.first.is_a?(Symbol) @content = args.shift @options = (args.first.is_a?(Hash))? args.first : {} end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
50 51 52 |
# File 'lib/capybara/rspec/matchers.rb', line 50 def content @content end |
#failure_message ⇒ Object (readonly) Also known as: failure_message_for_should
Returns the value of attribute failure_message.
52 53 54 |
# File 'lib/capybara/rspec/matchers.rb', line 52 def @failure_message end |
#failure_message_when_negated ⇒ Object (readonly) Also known as: failure_message_for_should_not
Returns the value of attribute failure_message_when_negated.
52 53 54 |
# File 'lib/capybara/rspec/matchers.rb', line 52 def @failure_message_when_negated end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
50 51 52 |
# File 'lib/capybara/rspec/matchers.rb', line 50 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
50 51 52 |
# File 'lib/capybara/rspec/matchers.rb', line 50 def type @type end |
Instance Method Details
#description ⇒ Object
77 78 79 |
# File 'lib/capybara/rspec/matchers.rb', line 77 def description "text #{format(content)}" end |
#does_not_match?(actual) ⇒ Boolean
70 71 72 73 74 75 |
# File 'lib/capybara/rspec/matchers.rb', line 70 def does_not_match?(actual) wrap(actual).assert_no_text(*@args) rescue Capybara::ExpectationNotMet => e @failure_message_when_negated = e. return false end |
#format(content) ⇒ Object
81 82 83 84 |
# File 'lib/capybara/rspec/matchers.rb', line 81 def format(content) content = Capybara::Helpers.normalize_whitespace(content) unless content.is_a? Regexp content.inspect end |
#matches?(actual) ⇒ Boolean
63 64 65 66 67 68 |
# File 'lib/capybara/rspec/matchers.rb', line 63 def matches?(actual) wrap(actual).assert_text(*@args) rescue Capybara::ExpectationNotMet => e @failure_message = e. return false end |