Module: Capybara::SessionMatchers
- Included in:
- Session
- Defined in:
- lib/capybara/session/matchers.rb
Instance Method Summary collapse
-
#assert_current_path(path, options = {}) ⇒ true
Asserts that the page has the given path.
-
#assert_no_current_path(path, options = {}) ⇒ true
Asserts that the page doesn’t have the given path.
-
#has_current_path?(path, options = {}) ⇒ Boolean
Checks if the page has the given path.
-
#has_no_current_path?(path, options = {}) ⇒ Boolean
Checks if the page doesn’t have the given path.
Instance Method Details
#assert_current_path(string, options = {}) ⇒ true #assert_current_path(regexp, options = {}) ⇒ true
Asserts that the page has the given path. By default this will compare against the path+query portion of the full url
18 19 20 21 22 23 24 25 26 |
# File 'lib/capybara/session/matchers.rb', line 18 def assert_current_path(path, ={}) query = Capybara::Queries::CurrentPathQuery.new(path, ) document.synchronize(query.wait) do unless query.resolves_for?(self) raise Capybara::ExpectationNotMet, query. end end return true end |
#assert_no_current_path(string, options = {}) ⇒ true #assert_no_current_path(regexp, options = {}) ⇒ true
Asserts that the page doesn’t have the given path.
35 36 37 38 39 40 41 42 43 |
# File 'lib/capybara/session/matchers.rb', line 35 def assert_no_current_path(path, ={}) query = Capybara::Queries::CurrentPathQuery.new(path, ) document.synchronize(query.wait) do if query.resolves_for?(self) raise Capybara::ExpectationNotMet, query. end end return true end |
#has_current_path?(string, options = {}) ⇒ Boolean #has_current_path?(regexp, options = {}) ⇒ Boolean
Checks if the page has the given path.
51 52 53 54 55 |
# File 'lib/capybara/session/matchers.rb', line 51 def has_current_path?(path, ={}) assert_current_path(path, ) rescue Capybara::ExpectationNotMet return false end |
#has_no_current_path?(string, options = {}) ⇒ Boolean #has_no_current_path?(regexp, options = {}) ⇒ Boolean
Checks if the page doesn’t have the given path.
63 64 65 66 67 |
# File 'lib/capybara/session/matchers.rb', line 63 def has_no_current_path?(path, ={}) assert_no_current_path(path, ) rescue Capybara::ExpectationNotMet return false end |