Class: Muack::Modifier

Inherits:
Struct
  • Object
show all
Defined in:
lib/muack/modifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defiObject

Returns the value of attribute defi

Returns:

  • (Object)

    the current value of defi



6
7
8
# File 'lib/muack/modifier.rb', line 6

def defi
  @defi
end

#mockObject

Returns the value of attribute mock

Returns:

  • (Object)

    the current value of mock



6
7
8
# File 'lib/muack/modifier.rb', line 6

def mock
  @mock
end

Instance Method Details

#objectObject

Public API



48
49
50
# File 'lib/muack/modifier.rb', line 48

def object
  mock.object
end

#peek_args(opts = {}, &block) ⇒ Object

Public API



36
37
38
39
# File 'lib/muack/modifier.rb', line 36

def peek_args opts={}, &block
  defi.peek_args = create_block(block, opts)
  self
end

#peek_return(opts = {}, &block) ⇒ Object

Public API



42
43
44
45
# File 'lib/muack/modifier.rb', line 42

def peek_return opts={}, &block
  defi.peek_return = create_block(block, opts)
  self
end

#returns(opts = {}, &block) ⇒ Object

Public API



30
31
32
33
# File 'lib/muack/modifier.rb', line 30

def returns opts={}, &block
  defi.returns = create_block(block, opts)
  self
end

#times(number) ⇒ Object

Public API



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/muack/modifier.rb', line 8

def times number
  if mock.__mock_class == Stub
    raise StubHasNoTimes.new(object, defi, number)
  end

  if number >= 1
    (number - 1).times{ mock.__mock_defis_push(defi) }
  elsif number == 0
    mock.__mock_defis_pop(defi)
  else
    raise "What would you expect from calling a method #{number} times?"
  end
  self
end

#with_any_argsObject

Public API



24
25
26
27
# File 'lib/muack/modifier.rb', line 24

def with_any_args
  defi.args = [WithAnyArgs]
  self
end