Class: RSpec::Wait::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/wait/proxy.rb

Overview

The RSpec::Wait::Proxy class is capable of creating a small container object for RSpec::Wait options, returned by the top-level wait method, which allows chaining wait and for methods for more expectations that read more naturally, like:

wait(3.seconds).for { this }.to eq(that)

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Proxy

Returns a new instance of Proxy.



13
14
15
# File 'lib/rspec/wait/proxy.rb', line 13

def initialize(**options)
  @options = options
end

Instance Method Details

#for(*args, &block) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
22
# File 'lib/rspec/wait/proxy.rb', line 17

def for(*args, &block)
  raise ArgumentError, "The `wait.for` method only accepts a block." if args.any?
  raise ArgumentError, "The `wait.for` method requires a block." unless block

  Target.new(block, @options)
end