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 (also: #has_content?)
- #has_title?(title, options = {}) ⇒ Boolean
- #match_or_error(matcher) ⇒ Object
Instance Method Details
#handle_failure(matcher) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/capybara_error_intel/dsl.rb', line 23 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 Also known as: has_content?
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
14 15 16 17 |
# File 'lib/capybara_error_intel/dsl.rb', line 14 def has_title?(title, = {}) matcher = ::RSpecMatchers::HaveTitle.new(title, ) match_or_error(matcher) end |
#match_or_error(matcher) ⇒ Object
19 20 21 |
# File 'lib/capybara_error_intel/dsl.rb', line 19 def match_or_error(matcher) matcher.matches?(.current_session) || handle_failure(matcher) end |