diff --git a/lib/capybara.rb b/lib/capybara.rb index dee0bda5..1f63efa1 100644 --- a/lib/capybara.rb +++ b/lib/capybara.rb @@ -27,32 +27,32 @@ module Capybara # DelegateCapybara global configurations # @!method app - # See {Capybara#configure} + # See {Capybara.configure} # @!method reuse_server - # See {Capybara#configure} + # See {Capybara.configure} # @!method threadsafe - # See {Capybara#configure} + # See {Capybara.configure} # @!method server - # See {Capybara#configure} + # See {Capybara.configure} # @!method default_driver - # See {Capybara#configure} + # See {Capybara.configure} # @!method javascript_driver - # See {Capybara#configure} + # See {Capybara.configure} Config::OPTIONS.each do |method| def_delegators :config, method, "#{method}=" end # Delegate Capybara global configurations # @!method default_selector - # See {Capybara#configure} + # See {Capybara.configure} # @!method default_max_wait_time - # See {Capybara#configure} + # See {Capybara.configure} # @!method app_host - # See {Capybara#configure} + # See {Capybara.configure} # @!method always_include_port - # See {Capybara#configure} + # See {Capybara.configure} # @!method wait_on_first_by_default - # See {Capybara#configure} + # See {Capybara.configure} SessionConfig::OPTIONS.each do |method| def_delegators :config, method, "#{method}=" end diff --git a/lib/capybara/node/matchers.rb b/lib/capybara/node/matchers.rb index 0e31ce6f..0d95cd19 100644 --- a/lib/capybara/node/matchers.rb +++ b/lib/capybara/node/matchers.rb @@ -432,11 +432,12 @@ module Capybara # # page.has_select?('Language', with_options: ['English', 'German']) # - # @param [String] locator The label, name or id of a select box - # @option options [Array] :options Options which should be contained in this select box - # @option options [Array] :with_options Partial set of options which should be contained in this select box - # @option options [String, Array] :selected Options which should be selected - # @return [Boolean] Whether it exists + # @param [String] locator The label, name or id of a select box + # @option options [Array] :options Options which should be contained in this select box + # @option options [Array] :with_options Partial set of options which should be contained in this select box + # @option options [String, Array] :selected Options which should be selected + # @option options [String, Array] :with_selected Partial set of options which should minimally be selected + # @return [Boolean] Whether it exists # def has_select?(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash diff --git a/lib/capybara/rspec/matchers.rb b/lib/capybara/rspec/matchers.rb index f45acc36..d5eea164 100644 --- a/lib/capybara/rspec/matchers.rb +++ b/lib/capybara/rspec/matchers.rb @@ -196,10 +196,14 @@ module Capybara alias_method :failure_message_for_should_not, :failure_message_when_negated end + # RSpec matcher for whether the element(s) matching a given selector exist + # See {Capybara::Node::Matcher#assert_selector} def have_selector(*args, &optional_filter_block) HaveSelector.new(*args, &optional_filter_block) end + # RSpec matcher for whether the current element matches a given selector + # See {Capybara::Node::Matchers#assert_matches_selector} def match_selector(*args, &optional_filter_block) MatchSelector.new(*args, &optional_filter_block) end @@ -208,22 +212,30 @@ module Capybara ::RSpec::Matchers.define_negated_matcher :not_match_selector, :match_selector if defined?(::RSpec::Expectations::Version) && (Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.1')) + # RSpec matcher for whether elements(s) matching a given xpath selector exist + # See {Capybara::Node::Matchers#has_xpath?} def have_xpath(xpath, options={}, &optional_filter_block) HaveSelector.new(:xpath, xpath, options, &optional_filter_block) end + # RSpec matcher for whether the current element matches a given xpath selector def match_xpath(xpath, options={}, &optional_filter_block) MatchSelector.new(:xpath, xpath, options, &optional_filter_block) end + # RSpec matcher for whether elements(s) matching a given css selector exist + # See {Capybara::Node::Matchers#has_css?} def have_css(css, options={}, &optional_filter_block) HaveSelector.new(:css, css, options, &optional_filter_block) end + # RSpec matcher for whether the current element matches a given css selector def match_css(css, options={}, &optional_filter_block) MatchSelector.new(:css, css, options, &optional_filter_block) end + # RSpec matcher for text on the page + # See {Capybara::SessionMatchers#assert_text} def have_text(*args) HaveText.new(*args) end @@ -233,40 +245,56 @@ module Capybara HaveTitle.new(title, options) end + # RSpec matcher for the current path + # See {Capybara::SessionMatchers#assert_current_path} def have_current_path(path, options = {}) HaveCurrentPath.new(path, options) end + # RSpec matcher for links + # See {Capybara::Node::Matchers#has_link?} def have_link(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash HaveSelector.new(:link, locator, options, &optional_filter_block) end + # RSpec matcher for buttons + # See {Capybara::Node::Matchers#has_button?} def have_button(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash HaveSelector.new(:button, locator, options, &optional_filter_block) end + # RSpec matcher for links + # See {Capybara::Node::Matchers#has_field?} def have_field(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash HaveSelector.new(:field, locator, options, &optional_filter_block) end + # RSpec matcher for checked fields + # See {Capybara::Node::Matchers#has_checked_field?} def have_checked_field(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash HaveSelector.new(:field, locator, options.merge(checked: true), &optional_filter_block) end + # RSpec matcher for unchecked fields + # See {Capybara::Node::Matchers#has_unchecked_field?} def have_unchecked_field(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash HaveSelector.new(:field, locator, options.merge(unchecked: true), &optional_filter_block) end + # RSpec matcher for select elements + # See {Capybara::Node::Matchers#has_select?} def have_select(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash HaveSelector.new(:select, locator, options, &optional_filter_block) end + # RSpec matcher for table elements + # See {Capybara::Node::Matchers#has_table?} def have_table(locator=nil, options={}, &optional_filter_block) locator, options = nil, locator if locator.is_a? Hash HaveSelector.new(:table, locator, options, &optional_filter_block) diff --git a/lib/capybara/session/config.rb b/lib/capybara/session/config.rb index 7fd24630..43dbd856 100644 --- a/lib/capybara/session/config.rb +++ b/lib/capybara/session/config.rb @@ -12,49 +12,49 @@ module Capybara ## #@!method always_include_port - # See {Capybara#configure} + # See {Capybara.configure} #@!method run_server - # See {Capybara#configure} + # See {Capybara.configure} #@!method default_selector - # See {Capybara#configure} + # See {Capybara.configure} #@!method default_max_wait_time - # See {Capybara#configure} + # See {Capybara.configure} #@!method ignore_hidden_elements - # See {Capybara#configure} + # See {Capybara.configure} #@!method automatic_reload - # See {Capybara#configure} + # See {Capybara.configure} #@!method match - # See {Capybara#configure} + # See {Capybara.configure} #@!method exact - # See {Capybara#configure} + # See {Capybara.configure} #@!method raise_server_errors - # See {Capybara#configure} + # See {Capybara.configure} #@!method visible_text_only - # See {Capybara#configure} + # See {Capybara.configure} #@!method wait_on_first_by_default - # See {Capybara#configure} + # See {Capybara.configure} #@!method automatic_label_click - # See {Capybara#configure} + # See {Capybara.configure} #@!method enable_aria_label - # See {Capybara#configure} + # See {Capybara.configure} #@!method save_path - # See {Capybara#configure} + # See {Capybara.configure} #@!method exact_options - # See {Capybara#configure} + # See {Capybara.configure} #@!method asset_host - # See {Capybara#configure} + # See {Capybara.configure} #@!method default_host - # See {Capybara#configure} + # See {Capybara.configure} #@!method app_host - # See {Capybara#configure} + # See {Capybara.configure} #@!method save_and_open_page_path - # See {Capybara#configure} + # See {Capybara.configure} #@!method server_host - # See {Capybara#configure} + # See {Capybara.configure} #@!method server_port - # See {Capybara#configure} + # See {Capybara.configure} #@!method server_errors - # See {Capybara#configure} + # See {Capybara.configure} remove_method :server_host diff --git a/lib/capybara/session/matchers.rb b/lib/capybara/session/matchers.rb index 55010371..0564ad05 100644 --- a/lib/capybara/session/matchers.rb +++ b/lib/capybara/session/matchers.rb @@ -22,6 +22,7 @@ module Capybara ## # Asserts that the page doesn't have the given path. + # By default this will compare against the path+query portion of the full url # # @macro current_path_query_params # @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time @@ -33,6 +34,7 @@ module Capybara ## # Checks if the page has the given path. + # By default this will compare against the path+query portion of the full url # # @macro current_path_query_params # @return [Boolean] @@ -45,6 +47,7 @@ module Capybara ## # Checks if the page doesn't have the given path. + # By default this will compare against the path+query portion of the full url # # @macro current_path_query_params # @return [Boolean]