basic documentations [ci skip]

This commit is contained in:
Thomas Walpole 2017-03-06 13:54:03 -08:00
parent b7e4f8dfc9
commit 902a58911d
2 changed files with 288 additions and 4 deletions

View File

@ -5,6 +5,8 @@ require 'capybara/dsl'
module Capybara
module Minitest
module Assertions
## Assert text exists
# see {Capybara::Node::Matchers#assert_text}
def assert_text(*args)
self.assertions += 1
subject, *args = determine_subject(args)
@ -14,6 +16,8 @@ module Capybara
end
alias_method :assert_content, :assert_text
## Assert text does not exist
# see {Capybara::Node::Matchers#assert_no_text}
def assert_no_text(*args)
self.assertions += 1
subject, *args = determine_subject(args)
@ -25,6 +29,8 @@ module Capybara
alias_method :refute_content, :refute_text
alias_method :assert_no_content, :refute_text
## Assert selector exists on page
# see {Capybara::Node::Matchers#assert_selector}
def assert_selector(*args, &optional_filter_block)
self.assertions +=1
subject, *args = determine_subject(args)
@ -33,6 +39,8 @@ module Capybara
raise ::Minitest::Assertion, e.message
end
## Assert selector does not exist on page
# see {Capybara::Node::Matchers#assert_no_selector}
def assert_no_selector(*args, &optional_filter_block)
self.assertions +=1
subject, *args = determine_subject(args)
@ -42,18 +50,22 @@ module Capybara
end
alias_method :refute_selector, :assert_no_selector
def assert_matches_selector(*args)
## Assert element matches selector
# see {Capybara::Node::Matchers#assert_matches_selector}
def assert_matches_selector(*args, &optional_filter_block)
self.assertions += 1
subject, *args = determine_subject(args)
subject.assert_matches_selector(*args)
subject.assert_matches_selector(*args, &optional_filter_block)
rescue Capybara::ExpectationNotMet => e
raise ::Minitest::Assertion, e.message
end
def assert_not_matches_selector(*args)
## Assert element does not match selector
# see {Capybara::Node::Matchers#assert_not_matches_selector}
def assert_not_matches_selector(*args, &optional_filter_block)
self.assertions += 1
subject, *args = determine_subject(args)
subject.assert_not_matches_selector(*args)
subject.assert_not_matches_selector(*args, &optional_filter_block)
rescue Capybara::ExpectationNotMet => e
raise ::Minitest::Assertion, e.message
end
@ -129,6 +141,147 @@ module Capybara
alias_method "refute_#{field_type}_field", "assert_no_#{field_type}_field"
end
##
# Assertion that there is xpath
#
# @!method assert_xpath
# see Capybara::Node::Matchers#has_xpath?
##
# Assertion that there is no xpath
#
# @!method refute_xpath
# @!method assert_no_xpath
# see Capybara::Node::Matchers#has_no_xpath?
##
# Assertion that there is css
#
# @!method assert_css
# see Capybara::Node::Matchers#has_css?
##
# Assertion that there is no css
#
# @!method refute_css
# @!method assert_no_css
# see Capybara::Node::Matchers#has_no_css?
##
# Assertion that there is link
#
# @!method assert_link
# see {Capybara::Node::Matchers#has_link?}
##
# Assertion that there is no link
#
# @!method assert_no_link
# @!method refute_link
# see {Capybara::Node::Matchers#has_no_link?}
##
# Assertion that there is button
#
# @!method assert_button
# see {Capybara::Node::Matchers#has_button?}
##
# Assertion that there is no button
#
# @!method refute_button
# @!method assert_no_button
# see {Capybara::Node::Matchers#has_no_button?}
##
# Assertion that there is field
#
# @!method assert_field
# see {Capybara::Node::Matchers#has_field?}
##
# Assertion that there is no field
#
# @!method refute_field
# @!method assert_no_field
# see {Capybara::Node::Matchers#has_no_field?}
##
# Assertion that there is checked_field
#
# @!method assert_checked_field
# see {Capybara::Node::Matchers#has_checked_field?}
##
# Assertion that there is no checked_field
#
# @!method assert_no_checked_field
# @!method refute_chceked_field
##
# Assertion that there is unchecked_field
#
# @!method assert_unchecked_field
# see {Capybara::Node::Matchers#has_unchecked_field?}
##
# Assertion that there is no unchecked_field
#
# @!method assert_no_unchecked_field
# @!method refute_unchceked_field
##
# Assertion that there is select
#
# @!method assert_select
# see {Capybara::Node::Matchers#has_select?}
##
# Assertion that there is no select
#
# @!method refute_select
# @!method assert_no_select
# see {Capybara::Node::Matchers#has_no_select?}
##
# Assertion that there is table
#
# @!method assert_table
# see {Capybara::Node::Matchers#has_table?}
##
# Assertion that there is no table
#
# @!method refute_table
# @!method assert_no_table
# see {Capybara::Node::Matchers#has_no_table?}
##
# Assertion that page title does match
#
# @!method assert_title
# see {Capybara::Node::DocumentMatchers#assert_title}
##
# Assertion that page title does not match
#
# @!method refute_title
# @!method assert_no_title
# see {Capybara::Node::DocumentMatchers#assert_no_title}
##
# Assertion that current path matches
#
# @!method assert_current_path
# see {Capybara::SessionMatchers#assert_current_path}
##
# Assertion that current page does not match
#
# @!method refute_current_path
# @!method assert_no_current_path
# see {Capybara::SessionMatchers#assert_no_current_path}
private
def determine_subject(args)

View File

@ -52,6 +52,137 @@ module Capybara
end
EOM
end
##
# Expectation that there is xpath
#
# @!method must_have_xpath
# see Capybara::Node::Matchers#has_xpath?
##
# Expectation that there is no xpath
#
# @!method wont_have_xpath
# see Capybara::Node::Matchers#has_no_xpath?
##
# Expectation that there is css
#
# @!method must_have_css
# see Capybara::Node::Matchers#has_css?
##
# Expectation that there is no css
#
# @!method wont_have_css
# see Capybara::Node::Matchers#has_no_css?
##
# Expectation that there is link
#
# @!method must_have_link
# see {Capybara::Node::Matchers#has_link?}
##
# Expectation that there is no link
#
# @!method wont_have_link
# see {Capybara::Node::Matchers#has_no_link?}
##
# Expectation that there is button
#
# @!method must_have_button
# see {Capybara::Node::Matchers#has_button?}
##
# Expectation that there is no button
#
# @!method wont_have_button
# see {Capybara::Node::Matchers#has_no_button?}
##
# Expectation that there is field
#
# @!method must_have_field
# see {Capybara::Node::Matchers#has_field?}
##
# Expectation that there is no field
#
# @!method wont_have_field
# see {Capybara::Node::Matchers#has_no_field?}
##
# Expectation that there is checked_field
#
# @!method must_have_checked_field
# see {Capybara::Node::Matchers#has_checked_field?}
##
# Expectation that there is no checked_field
#
# @!method wont_have_chceked_field
##
# Expectation that there is unchecked_field
#
# @!method must_have_unchecked_field
# see {Capybara::Node::Matchers#has_unchecked_field?}
##
# Expectation that there is no unchecked_field
#
# @!method wont_have_unchceked_field
##
# Expectation that there is select
#
# @!method must_have_select
# see {Capybara::Node::Matchers#has_select?}
##
# Expectation that there is no select
#
# @!method wont_have_select
# see {Capybara::Node::Matchers#has_no_select?}
##
# Expectation that there is table
#
# @!method must_have_table
# see {Capybara::Node::Matchers#has_table?}
##
# Expectation that there is no table
#
# @!method wont_have_table
# see {Capybara::Node::Matchers#has_no_table?}
##
# Expectation that page title does match
#
# @!method must_have_title
# see {Capybara::Node::DocumentMatchers#assert_title}
##
# Expectation that page title does not match
#
# @!method wont_have_title
# see {Capybara::Node::DocumentMatchers#assert_no_title}
##
# Expectation that current path matches
#
# @!method must_have_current_path
# see {Capybara::SessionMatchers#assert_current_path}
##
# Expectation that current page does not match
#
# @!method wont_have_current_path
# see {Capybara::SessionMatchers#assert_no_current_path}
end
end
end