Class: Minitest::Capybara::Unit::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest-capybara-unit.rb

Defined Under Namespace

Classes: MatcherName

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_matcher_name) ⇒ Matcher

Returns a new instance of Matcher.



10
11
12
13
14
# File 'lib/minitest-capybara-unit.rb', line 10

def initialize(node_matcher_name)
  @name = MatcherName.new(node_matcher_name)
  define_assert
  define_refute
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/minitest-capybara-unit.rb', line 8

def name
  @name
end

Class Method Details

.failure_message(assertion_method, matcher_name, *args) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/minitest-capybara-unit.rb', line 29

def self.failure_message(assertion_method, matcher_name, *args)
  if assertion_method == 'assert'
    message = "Matcher failed: "
  else
    message = 'Matcher should have failed: '
  end
  message += "#{matcher_name}(#{args.map(&:inspect).join(', ')})"
end

Instance Method Details

#define_assertObject



16
17
18
# File 'lib/minitest-capybara-unit.rb', line 16

def define_assert
  define_assertion
end

#define_refuteObject



20
21
22
23
# File 'lib/minitest-capybara-unit.rb', line 20

def define_refute
  name.negate!
  define_assertion
end

#test(page, *args) ⇒ Object



25
26
27
# File 'lib/minitest-capybara-unit.rb', line 25

def test(page, *args)
  wrap(page).send(name.original, *args)
end