Module: Capybara::Node::DocumentMatchers

Included in:
Document, Simple
Defined in:
lib/capybara/node/document_matchers.rb

Instance Method Summary collapse

Instance Method Details

#assert_no_title(string, **options) ⇒ true #assert_no_title(regexp, **options) ⇒ true

Asserts that the page doesn’t have the given title.

Overloads:

  • #assert_no_title(string, **options) ⇒ true

    Parameters:

    • string (String)

      The string that title should include

  • #assert_no_title(regexp, **options) ⇒ true

    Parameters:

    • regexp (Regexp)

      The regexp that title should match to

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :wait (Numeric) — default: Capybara.default_max_wait_time

    Maximum time that Capybara will wait for title to eq/match given string/regexp argument

  • :exact (Boolean) — default: false

    When passed a string should the match be exact or just substring

Returns:

  • (true)

Raises:



30
31
32
# File 'lib/capybara/node/document_matchers.rb', line 30

def assert_no_title(title, **options)
  _verify_title(title, options) { |query| raise Capybara::ExpectationNotMet, query.negative_failure_message if query.resolves_for?(self) }
end

#assert_title(string, **options) ⇒ true #assert_title(regexp, **options) ⇒ true

Asserts that the page has the given title.

Overloads:

  • #assert_title(string, **options) ⇒ true

    Parameters:

    • string (String)

      The string that title should include

  • #assert_title(regexp, **options) ⇒ true

    Parameters:

    • regexp (Regexp)

      The regexp that title should match to

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :wait (Numeric) — default: Capybara.default_max_wait_time

    Maximum time that Capybara will wait for title to eq/match given string/regexp argument

  • :exact (Boolean) — default: false

    When passed a string should the match be exact or just substring

Returns:

  • (true)

Raises:



19
20
21
# File 'lib/capybara/node/document_matchers.rb', line 19

def assert_title(title, **options)
  _verify_title(title, options) { |query| raise Capybara::ExpectationNotMet, query.failure_message unless query.resolves_for?(self) }
end

#has_no_title?(string, **options) ⇒ Boolean #has_no_title?(regexp, **options) ⇒ Boolean

Checks if the page doesn’t have the given title.

Overloads:

  • #has_no_title?(string, **options) ⇒ Boolean

    Parameters:

    • string (String)

      The string that title should include

  • #has_no_title?(regexp, **options) ⇒ Boolean

    Parameters:

    • regexp (Regexp)

      The regexp that title should match to

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :wait (Numeric) — default: Capybara.default_max_wait_time

    Maximum time that Capybara will wait for title to eq/match given string/regexp argument

  • :exact (Boolean) — default: false

    When passed a string should the match be exact or just substring

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/capybara/node/document_matchers.rb', line 52

def has_no_title?(title, **options)
  assert_no_title(title, options)
rescue Capybara::ExpectationNotMet
  false
end

#has_title?(string, **options) ⇒ Boolean #has_title?(regexp, **options) ⇒ Boolean

Checks if the page has the given title.

Overloads:

  • #has_title?(string, **options) ⇒ Boolean

    Parameters:

    • string (String)

      The string that title should include

  • #has_title?(regexp, **options) ⇒ Boolean

    Parameters:

    • regexp (Regexp)

      The regexp that title should match to

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :wait (Numeric) — default: Capybara.default_max_wait_time

    Maximum time that Capybara will wait for title to eq/match given string/regexp argument

  • :exact (Boolean) — default: false

    When passed a string should the match be exact or just substring

Returns:

  • (Boolean)


40
41
42
43
44
# File 'lib/capybara/node/document_matchers.rb', line 40

def has_title?(title, **options)
  assert_title(title, options)
rescue Capybara::ExpectationNotMet
  false
end