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.



162
163
164
# File 'lib/capybara/rspec/matchers.rb', line 162

def initialize(options)
  @wait_time = Capybara::Query.new(options).wait
end

Instance Method Details

#failure_messageObject Also known as: failure_message_for_should



176
177
178
# File 'lib/capybara/rspec/matchers.rb', line 176

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

#failure_message_when_negatedObject Also known as: failure_message_for_should_not



180
181
182
# File 'lib/capybara/rspec/matchers.rb', line 180

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

#matches?(window) ⇒ Boolean

Returns:

  • (Boolean)


166
167
168
169
170
171
172
173
174
# File 'lib/capybara/rspec/matchers.rb', line 166

def matches?(window)
  @window = window
  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