Module: Smartmock::Next::ClassMethods

Defined in:
lib/smartmock/helpers.rb

Instance Method Summary collapse

Instance Method Details

#last_smartmockObject



14
15
16
# File 'lib/smartmock/helpers.rb', line 14

def last_smartmock
  @last_mock
end

#revert_smartmock_nextObject



23
24
25
26
27
# File 'lib/smartmock/helpers.rb', line 23

def revert_smartmock_next
  class << self
    alias new orig_new
  end
end

#setup_smartmock_nextObject



29
30
31
32
33
34
# File 'lib/smartmock/helpers.rb', line 29

def setup_smartmock_next
  class << self
    alias orig_new new
    alias new smartmock_new
  end
end

#smartmock_new(attribs = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/smartmock/helpers.rb', line 5

def smartmock_new(attribs={})
  @last_mock = Mock.new(self, attribs)
  if @smartmock_stubs
    @last_mock.stubs = @smartmock_stubs
  end
  revert_smartmock_next
  @last_mock
end

#smartmock_next_stub(stubs) ⇒ Object



18
19
20
# File 'lib/smartmock/helpers.rb', line 18

def smartmock_next_stub(stubs)
  @smartmock_stubs = stubs
end