Module: CapybaraErrorIntel::DSL
- Defined in:
- lib/capybara_error_intel/dsl.rb
Instance Method Summary collapse
- #handle_failure(matcher) ⇒ Object
- #has_selector?(*args) ⇒ Boolean
- #has_text?(*args) ⇒ Boolean
- #has_title?(title, options = {}) ⇒ Boolean
- #match_or_error(matcher) ⇒ Object
Instance Method Details
#handle_failure(matcher) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/capybara_error_intel/dsl.rb', line 22 def handle_failure(matcher) = matcher. if matcher.respond_to?(:diffable?) && matcher.diffable? RSpec::Expectations.fail_with , matcher.expected, matcher.actual else RSpec::Expectations.fail_with end end |
#has_selector?(*args) ⇒ Boolean
3 4 5 6 |
# File 'lib/capybara_error_intel/dsl.rb', line 3 def has_selector?(*args) matcher = ::RSpecMatchers::HaveSelector.new(*args) match_or_error(matcher) end |
#has_text?(*args) ⇒ Boolean
8 9 10 11 |
# File 'lib/capybara_error_intel/dsl.rb', line 8 def has_text?(*args) matcher = ::RSpecMatchers::HaveText.new(*args) match_or_error(matcher) end |
#has_title?(title, options = {}) ⇒ Boolean
13 14 15 16 |
# File 'lib/capybara_error_intel/dsl.rb', line 13 def has_title?(title, = {}) matcher = ::RSpecMatchers::HaveTitle.new(title, ) match_or_error(matcher) end |
#match_or_error(matcher) ⇒ Object
18 19 20 |
# File 'lib/capybara_error_intel/dsl.rb', line 18 def match_or_error(matcher) matcher.matches?(.current_session) || handle_failure(matcher) end |