Class: Spec::Rails::Matchers::HaveText
- Defined in:
- lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(expected) ⇒ HaveText
constructor
A new instance of HaveText.
- #matches?(response_or_text) ⇒ Boolean
Constructor Details
#initialize(expected) ⇒ HaveText
Returns a new instance of HaveText.
7 8 9 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb', line 7 def initialize(expected) @expected = expected end |
Instance Method Details
#description ⇒ Object
25 26 27 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb', line 25 def description "have text #{expected.inspect}" end |
#failure_message_for_should ⇒ Object
17 18 19 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb', line 17 def "expected #{expected.inspect}, got #{actual.inspect}" end |
#failure_message_for_should_not ⇒ Object
21 22 23 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb', line 21 def "expected not to have text #{expected.inspect}" end |
#matches?(response_or_text) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb', line 11 def matches?(response_or_text) @actual = response_or_text.respond_to?(:body) ? response_or_text.body : response_or_text return actual =~ expected if Regexp === expected return actual == expected unless Regexp === expected end |