Module: Caricature::ExpectationSyntax

Included in:
Expectation, ExpectationBuilder
Defined in:
lib/caricature/expectation.rb

Overview

contains the syntax for building up an expectation This is shared between the ExpecationBuilder and the Expectation

Instance Method Summary collapse

Instance Method Details

#actual_raiseObject

tell the expectation it needs to raise an error with the specified arguments



65
# File 'lib/caricature/expectation.rb', line 65

alias_method :actual_raise, :raise

#any_args?Boolean

indicates whether this expectation should match with any arguments or only for the specified arguments

Returns:

  • (Boolean)


87
88
89
# File 'lib/caricature/expectation.rb', line 87

def any_args?
  @any_args
end

#pass_block(*args, &b) ⇒ Object

Sets up arguments for the block that is being passed into the isolated method call



57
58
59
60
61
62
# File 'lib/caricature/expectation.rb', line 57

def pass_block(*args, &b)
  @any_block_args = args.first.is_a?(Symbol) and args.first == :any
  @block_args = args
  @block_callback = b unless b.nil?
  self
end

#raise(*args) ⇒ Object



66
67
68
69
# File 'lib/caricature/expectation.rb', line 66

def raise(*args)
  @error_args = args
  self
end

#return(value = nil, &b) ⇒ Object

tell the expectation it nees to return this value or the value returned by the block you provide to this method.



50
51
52
53
54
# File 'lib/caricature/expectation.rb', line 50

def return(value=nil, &b)
  @return_value = value
  @return_callback = b if b
  self
end

#super_after(&b) ⇒ Object

tell the expectation it needs to call the super after the expecation execution



79
80
81
82
83
# File 'lib/caricature/expectation.rb', line 79

def super_after(&b)
  @super = :after
  @block = b if b
  self
end

#super_before(&b) ⇒ Object

tell the expecation it needs to call the super before the expectation exectution



72
73
74
75
76
# File 'lib/caricature/expectation.rb', line 72

def super_before(&b)
  @super = :before
  @block = b if b
  self
end

#with(*args, &b) ⇒ Object

tell the expection which arguments it needs to respond to there is a magic argument here any which configures the expectation to respond to any arguments



41
42
43
44
45
46
# File 'lib/caricature/expectation.rb', line 41

def with(*args, &b)
  @any_args = args.first.is_a?(Symbol) and args.first == :any
  @args = args   
  @callback = b unless b.nil?
  self
end