Class: Capybara::RSpecMatchers::HaveSelector
- Inherits:
-
Object
- Object
- Capybara::RSpecMatchers::HaveSelector
- Defined in:
- lib/capybara/rspec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(*args) ⇒ HaveSelector
constructor
A new instance of HaveSelector.
- #matches?(actual) ⇒ Boolean
- #normalized ⇒ Object
- #selector_name ⇒ Object
- #wrap(actual) ⇒ Object
Constructor Details
#initialize(*args) ⇒ HaveSelector
Returns a new instance of HaveSelector.
4 5 6 |
# File 'lib/capybara/rspec/matchers.rb', line 4 def initialize(*args) @args = args end |
Instance Method Details
#description ⇒ Object
30 31 32 |
# File 'lib/capybara/rspec/matchers.rb', line 30 def description "has #{selector_name}" end |
#does_not_match?(actual) ⇒ Boolean
13 14 15 16 |
# File 'lib/capybara/rspec/matchers.rb', line 13 def does_not_match?(actual) @actual = wrap(actual) @actual.has_no_selector?(*@args) end |
#failure_message_for_should ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/capybara/rspec/matchers.rb', line 18 def if normalized. normalized..call(@actual, normalized) else "expected #{selector_name} to return something" end end |
#failure_message_for_should_not ⇒ Object
26 27 28 |
# File 'lib/capybara/rspec/matchers.rb', line 26 def "expected #{selector_name} not to return anything" end |
#matches?(actual) ⇒ Boolean
8 9 10 11 |
# File 'lib/capybara/rspec/matchers.rb', line 8 def matches?(actual) @actual = wrap(actual) @actual.has_selector?(*@args) end |
#normalized ⇒ Object
48 49 50 |
# File 'lib/capybara/rspec/matchers.rb', line 48 def normalized @normalized ||= Capybara::Selector.normalize(*@args) end |
#selector_name ⇒ Object
34 35 36 37 38 |
# File 'lib/capybara/rspec/matchers.rb', line 34 def selector_name name = "#{normalized.name} #{normalized.locator.inspect}" name << " with text #{normalized.[:text].inspect}" if normalized.[:text] name end |