Class: Capybara::RSpecMatchers::HaveMatcher
- Inherits:
-
Object
- Object
- Capybara::RSpecMatchers::HaveMatcher
- Defined in:
- lib/capybara/rspec/matchers.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
-
#locator ⇒ Object
readonly
Returns the value of attribute locator.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #arguments ⇒ Object
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(name, locator, options = {}, &block) ⇒ HaveMatcher
constructor
A new instance of HaveMatcher.
- #matches?(actual) ⇒ Boolean
- #selector_name ⇒ Object
- #wrap(actual) ⇒ Object
Constructor Details
#initialize(name, locator, options = {}, &block) ⇒ HaveMatcher
Returns a new instance of HaveMatcher.
46 47 48 49 50 51 |
# File 'lib/capybara/rspec/matchers.rb', line 46 def initialize(name, locator, ={}, &block) @name = name @locator = locator @options = @failure_message = block end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
44 45 46 |
# File 'lib/capybara/rspec/matchers.rb', line 44 def actual @actual end |
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
44 45 46 |
# File 'lib/capybara/rspec/matchers.rb', line 44 def @failure_message end |
#locator ⇒ Object (readonly)
Returns the value of attribute locator.
44 45 46 |
# File 'lib/capybara/rspec/matchers.rb', line 44 def locator @locator end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
44 45 46 |
# File 'lib/capybara/rspec/matchers.rb', line 44 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
44 45 46 |
# File 'lib/capybara/rspec/matchers.rb', line 44 def @options end |
Instance Method Details
#arguments ⇒ Object
53 54 55 |
# File 'lib/capybara/rspec/matchers.rb', line 53 def arguments if .empty? then [locator] else [locator, ] end end |
#description ⇒ Object
81 82 83 |
# File 'lib/capybara/rspec/matchers.rb', line 81 def description "has #{selector_name}" end |
#does_not_match?(actual) ⇒ Boolean
62 63 64 65 |
# File 'lib/capybara/rspec/matchers.rb', line 62 def does_not_match?(actual) @actual = wrap(actual) @actual.send(:"has_no_#{name}?", *arguments) end |
#failure_message_for_should ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/capybara/rspec/matchers.rb', line 67 def if .call(actual, self) elsif(@options[:count]) "expected #{selector_name} to be returned #{@options[:count]} times" else "expected #{selector_name} to return something" end end |
#failure_message_for_should_not ⇒ Object
77 78 79 |
# File 'lib/capybara/rspec/matchers.rb', line 77 def "expected #{selector_name} not to return anything" end |
#matches?(actual) ⇒ Boolean
57 58 59 60 |
# File 'lib/capybara/rspec/matchers.rb', line 57 def matches?(actual) @actual = wrap(actual) @actual.send(:"has_#{name}?", *arguments) end |
#selector_name ⇒ Object
85 86 87 88 89 |
# File 'lib/capybara/rspec/matchers.rb', line 85 def selector_name selector_name = "#{name} #{locator.inspect}" selector_name << " with text #{[:text].inspect}" if [:text] selector_name end |