Class: RSpec::Wait::Target

Inherits:
Expectations::ExpectationTarget
  • Object
show all
Defined in:
lib/rspec/wait/target.rb

Constant Summary collapse

UndefinedValue =
Module.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, options) ⇒ Target



22
23
24
25
# File 'lib/rspec/wait/target.rb', line 22

def initialize(target, options)
  @wait_options = options
  super(target)
end

Class Method Details

.for(value, block, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rspec/wait/target.rb', line 8

def self.for(value, block, options = {})
  if UndefinedValue.equal?(value)
    unless block
      raise ArgumentError, "You must pass either an argument or a block to `wait_for`."
    end
    new(block, options)
  elsif block
    raise ArgumentError, "You cannot pass both an argument and a block to `wait_for`."
  else
    new(value, options)
  end
end

Instance Method Details

#not_to(matcher = nil, message = nil, &block) ⇒ Object Also known as: to_not



34
35
36
37
# File 'lib/rspec/wait/target.rb', line 34

def not_to(matcher = nil, message = nil, &block)
  prevent_operator_matchers(:not_to, matcher) unless matcher
  with_wait { NegativeHandler.handle_matcher(@target, matcher, message, &block) }
end

#to(matcher = nil, message = nil, &block) ⇒ Object



28
29
30
31
# File 'lib/rspec/wait/target.rb', line 28

def to(matcher = nil, message = nil, &block)
  prevent_operator_matchers(:to, matcher) unless matcher
  with_wait { PositiveHandler.handle_matcher(@target, matcher, message, &block) }
end