Module: RSpec::Mockbidden::Methods

Defined in:
lib/rspec/mockbidden/methods.rb

Overview

Methods included in RSpec example lifecycle

Instance Method Summary collapse

Instance Method Details

#forbid(target) ⇒ Object



30
31
32
33
34
# File 'lib/rspec/mockbidden/methods.rb', line 30

def forbid(target)
  forbiddance_target = ::RSpec::Mockbidden::ForbiddanceTarget.new(target)
  ::RSpec::Mocks.space.forbid_proxy(forbiddance_target)
  forbiddance_target
end

#forbid_any_instance_of(target) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rspec/mockbidden/methods.rb', line 36

def forbid_any_instance_of(target)
  anything_class = ::RSpec::Mocks::ArgumentMatchers::AnyArgMatcher
  unless target.is_a?(Module) || target.instance_of?(anything_class)
    raise ArgumentError,
          "Argument to `forbid_any_instance_of` must be a Class/Module or `anything`, given `#{target.inspect}`"
  end

  forbiddance_target = ::RSpec::Mockbidden::AnyForbiddanceTarget.new(target)
  ::RSpec::Mocks.space.forbid_proxy(forbiddance_target)
  forbiddance_target
end

#receiving(method) ⇒ Object



48
49
50
# File 'lib/rspec/mockbidden/methods.rb', line 48

def receiving(method)
  method
end