Class: Should

Inherits:
Object show all
Defined in:
lib/caricature/bacon/integration.rb

Instance Method Summary collapse

Instance Method Details

#have_received?(name, &b) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/caricature/bacon/integration.rb', line 3

def have_received?(name, &b)
  lambda { |obj, *args| obj.did_receive?(name, &b).successful? }
end

#satisfy(*args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/caricature/bacon/integration.rb', line 7

def satisfy(*args, &block)
  if args.size == 1 && String === args.first
    description = args.shift
  else
    description = ""
  end
  
  r=nil
  err = nil
  begin
    r = yield(@object, *args)
  rescue Caricature::ArgumentMatchError => e
    err =e 
  end
  if Bacon::Counter[:depth] > 0
    Bacon::Counter[:requirements] += 1
    raise (err.is_a?(Caricature::ArgumentMatchError) ? err : Bacon::Error.new(:failed, description)) unless @negated ^ r
    r
  else
    @negated ? !r : !!r
  end
end