Class: Playwright::Test::Matchers::PlaywrightMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/playwright/test.rb

Instance Method Summary collapse

Constructor Details

#initialize(expectation_method, *args, **kwargs) ⇒ PlaywrightMatcher

Returns a new instance of PlaywrightMatcher.



29
30
31
32
33
# File 'lib/playwright/test.rb', line 29

def initialize(expectation_method, *args, **kwargs)
  @method = expectation_method
  @args = args
  @kwargs = kwargs
end

Instance Method Details

#failure_messageObject



43
44
45
# File 'lib/playwright/test.rb', line 43

def failure_message
  @failure_message
end

#failure_message_when_negatedObject

we have to invert the message again here because RSpec wants to control its own negation



49
50
51
# File 'lib/playwright/test.rb', line 49

def failure_message_when_negated
  @failure_message.gsub("expected to", "not expected to")
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
# File 'lib/playwright/test.rb', line 35

def matches?(actual)
  Expect.new.call(actual).send(@method, *@args, **@kwargs)
  true
rescue AssertionError => e
  @failure_message = e.full_message
  false
end