Class: Capybara::RSpecMatchers::HaveText
- Inherits:
-
Matcher
- Object
- Matcher
- Capybara::RSpecMatchers::HaveText
- Defined in:
- lib/capybara/rspec/matchers.rb
Instance Attribute Summary (collapse)
-
- (Object) content
readonly
Returns the value of attribute content.
-
- (Object) options
readonly
Returns the value of attribute options.
-
- (Object) type
readonly
Returns the value of attribute type.
Instance Method Summary (collapse)
- - (Object) description
- - (Boolean) does_not_match?(actual)
- - (Object) failure_message_for_should
- - (Object) failure_message_for_should_not
- - (Object) format(content)
-
- (HaveText) initialize(*args)
constructor
A new instance of HaveText.
- - (Boolean) matches?(actual)
Methods inherited from Matcher
Constructor Details
- (HaveText) initialize(*args)
A new instance of HaveText
38 39 40 41 42 |
# File 'lib/capybara/rspec/matchers.rb', line 38 def initialize(*args) @type = args.shift if args.first.is_a?(Symbol) @content = args.shift @options = (args.first.is_a?(Hash))? args.first : {} end |
Instance Attribute Details
- (Object) content (readonly)
Returns the value of attribute content
36 37 38 |
# File 'lib/capybara/rspec/matchers.rb', line 36 def content @content end |
- (Object) options (readonly)
Returns the value of attribute options
36 37 38 |
# File 'lib/capybara/rspec/matchers.rb', line 36 def @options end |
- (Object) type (readonly)
Returns the value of attribute type
36 37 38 |
# File 'lib/capybara/rspec/matchers.rb', line 36 def type @type end |
Instance Method Details
- (Object) description
64 65 66 |
# File 'lib/capybara/rspec/matchers.rb', line 64 def description "text #{format(content)}" end |
- (Boolean) does_not_match?(actual)
49 50 51 52 |
# File 'lib/capybara/rspec/matchers.rb', line 49 def does_not_match?(actual) @actual = wrap(actual) @actual.has_no_text?(type, content, ) end |
- (Object) failure_message_for_should
54 55 56 57 58 |
# File 'lib/capybara/rspec/matchers.rb', line 54 def = Capybara::Helpers.(description, ) << " in #{format(@actual.text(type))}" end |
- (Object) failure_message_for_should_not
60 61 62 |
# File 'lib/capybara/rspec/matchers.rb', line 60 def .sub(/(to find)/, 'not \1') end |
- (Object) format(content)
68 69 70 71 |
# File 'lib/capybara/rspec/matchers.rb', line 68 def format(content) content = Capybara::Helpers.normalize_whitespace(content) unless content.is_a? Regexp content.inspect end |
- (Boolean) matches?(actual)
44 45 46 47 |
# File 'lib/capybara/rspec/matchers.rb', line 44 def matches?(actual) @actual = wrap(actual) @actual.has_text?(type, content, ) end |