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



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

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
20
# File 'lib/rspec/wait/target.rb', line 8

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

    new(block, options)
  elsif block
    raise ArgumentError, "You cannot pass both an argument and a block to `wait_for`."
  else
    warn "[DEPRECATION] As of rspec-wait version 1.0, " \
      "neither wait_for nor wait.for will accept an argument, only a block."
    new(value, options)
  end
end

Instance Method Details

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



37
38
39
40
41
42
# File 'lib/rspec/wait/target.rb', line 37

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

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



29
30
31
32
33
34
# File 'lib/rspec/wait/target.rb', line 29

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