Module: VerifiedDouble::RSpecMocksSyntaxOverrides

Defined in:
lib/verified_double/rspec_mocks_syntax_overrides.rb

Instance Method Summary collapse

Instance Method Details

#allow(*args) ⇒ Object



3
4
5
6
# File 'lib/verified_double/rspec_mocks_syntax_overrides.rb', line 3

def allow(*args)
  VerifiedDouble.registry.update_current_double args[0]
  super(*args)
end

#allow_any_instance_of(*args) ⇒ Object



8
9
10
11
# File 'lib/verified_double/rspec_mocks_syntax_overrides.rb', line 8

def allow_any_instance_of(*args)
  VerifiedDouble.registry.update_current_double nil
  super(*args)
end

#expect(*args) ⇒ Object



13
14
15
16
# File 'lib/verified_double/rspec_mocks_syntax_overrides.rb', line 13

def expect(*args)
  VerifiedDouble.registry.update_current_double args[0]
  super(*args)
end

#expect_any_instance_of(*args) ⇒ Object



18
19
20
21
# File 'lib/verified_double/rspec_mocks_syntax_overrides.rb', line 18

def expect_any_instance_of(*args)
  VerifiedDouble.registry.update_current_double nil
  super(*args)
end

#receive(*args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/verified_double/rspec_mocks_syntax_overrides.rb', line 23

def receive(*args)
  if VerifiedDouble.registry.current_double
    VerifiedDouble.registry.add_method_signature_with_current_double(args[0])
    super(*args).tap do |result|
      result.extend(VerifiedDouble::CanRecordInteractions)
    end
  else
    super(*args)
  end
end