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



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

def defi
  @defi
end

#mockObject

Returns the value of attribute mock

Returns:

  • (Object)

    the current value of mock



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

def mock
  @mock
end

Instance Method Details

#objectObject

Public API



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

def object
  mock.object
end

#proxyObject

Public API



19
20
21
22
# File 'lib/muack/modifier.rb', line 19

def proxy
  defi.proxy = true
  self
end

#returns(val = nil, &block) ⇒ Object

Public API



13
14
15
16
# File 'lib/muack/modifier.rb', line 13

def returns val=nil, &block
  defi.block = block || lambda{ val }
  self
end

#times(number) ⇒ Object

Public API



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/muack/modifier.rb', line 25

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



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

def with_any_args
  defi.args = [WithAnyArgs]
  self
end