Module: Capybara::Assertions

Included in:
Minitest::AcceptanceSpec
Defined in:
lib/capybara/assertions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


3
4
5
# File 'lib/capybara/assertions.rb', line 3

def self.included(base)
  raise "Make sure to include Capybara::Minitest::Assertions after Capybara::DSL" unless base < Capybara::DSL
end

Instance Method Details

#assert_selector(*args) ⇒ Object


21
22
23
24
25
26
# File 'lib/capybara/assertions.rb', line 21

def assert_selector(*args)
  node, *args = prepare_args(args)
  node.assert_selector(*args)
rescue Capybara::ExpectationNotMet => e
  assert false, e.message
end

#assert_text(*args) ⇒ Object Also known as: assert_content


7
8
9
10
# File 'lib/capybara/assertions.rb', line 7

def assert_text(*args)
  node, *args = prepare_args(args)
  assert node.has_text?(*args), message { "Expected to include #{args.first.inspect}" }
end

#refute_selector(*args) ⇒ Object Also known as: assert_no_selector


28
29
30
31
32
33
# File 'lib/capybara/assertions.rb', line 28

def refute_selector(*args)
  node, *args = prepare_args(args)
  node.assert_no_selector(*args)
rescue Capybara::ExpectationNotMet => e
  assert false, e.message
end

#refute_text(*args) ⇒ Object Also known as: assert_no_text, refute_content, assert_no_content


13
14
15
16
# File 'lib/capybara/assertions.rb', line 13

def refute_text(*args)
  node, *args = prepare_args(args)
  assert node.has_no_text?(*args), message { "Expected not to include #{args.first.inspect}" }
end