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.



39
40
41
42
43
# File 'lib/playwright/test.rb', line 39

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

Instance Method Details

#failure_messageObject



53
54
55
# File 'lib/playwright/test.rb', line 53

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



59
60
61
# File 'lib/playwright/test.rb', line 59

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
# File 'lib/playwright/test.rb', line 45

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