Class: Capybara::RSpecMatchers::BecomeClosed

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/rspec/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BecomeClosed

Returns a new instance of BecomeClosed.



251
252
253
# File 'lib/capybara/rspec/matchers.rb', line 251

def initialize(options)
  @options = options
end

Instance Method Details

#failure_messageObject



267
268
269
# File 'lib/capybara/rspec/matchers.rb', line 267

def failure_message
  "expected #{@window.inspect} to become closed after #{@wait_time} seconds"
end

#failure_message_when_negatedObject



271
272
273
# File 'lib/capybara/rspec/matchers.rb', line 271

def failure_message_when_negated
  "expected #{@window.inspect} not to become closed after #{@wait_time} seconds"
end

#matches?(window) ⇒ Boolean

Returns:

  • (Boolean)


255
256
257
258
259
260
261
262
263
264
265
# File 'lib/capybara/rspec/matchers.rb', line 255

def matches?(window)
  @window = window
  @wait_time = Capybara::Queries::BaseQuery.wait(@options, window.session.config.default_max_wait_time)
  timer = Capybara::Helpers.timer(expire_in: @wait_time)
  while window.exists?
    return false if timer.expired?

    sleep 0.05
  end
  true
end