123456789_123456789_123456789_123456789_123456789_

Class: Capybara::RSpecMatchers::Matchers::BecomeClosed

Relationships & Source Files
Inherits: Object
Defined in: lib/capybara/rspec/matchers/become_closed.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(options) ⇒ BecomeClosed

[ GitHub ]

  
# File 'lib/capybara/rspec/matchers/become_closed.rb', line 7

def initialize(options)
  @options = options
end

Instance Method Details

#failure_message

[ GitHub ]

  
# File 'lib/capybara/rspec/matchers/become_closed.rb', line 23

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

#failure_message_when_negated

[ GitHub ]

  
# File 'lib/capybara/rspec/matchers/become_closed.rb', line 27

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

#matches?(window) ⇒ Boolean

[ GitHub ]

  
# File 'lib/capybara/rspec/matchers/become_closed.rb', line 11

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.01
  end
  true
end