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



214
215
216
# File 'lib/capybara/rspec/matchers.rb', line 214

def initialize(options)
  @options = options
end

Instance Method Details

#failure_messageObject



229
230
231
# File 'lib/capybara/rspec/matchers.rb', line 229

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

#failure_message_when_negatedObject



233
234
235
# File 'lib/capybara/rspec/matchers.rb', line 233

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

#matches?(window) ⇒ Boolean

Returns:

  • (Boolean)


218
219
220
221
222
223
224
225
226
227
# File 'lib/capybara/rspec/matchers.rb', line 218

def matches?(window)
  @window = window
  @wait_time = Capybara::Queries::BaseQuery.wait(@options, window.session.config.default_max_wait_time)
  start_time = Capybara::Helpers.monotonic_time
  while window.exists?
    return false if (Capybara::Helpers.monotonic_time - start_time) > @wait_time
    sleep 0.05
  end
  true
end