Module: RSpec::ExitGuard::Helpers

Defined in:
lib/rspec/exit_guard.rb

Instance Method Summary collapse

Instance Method Details

#mock_exit_call_for_exit_guard(target, method_name) ⇒ Object



8
9
10
11
12
13
# File 'lib/rspec/exit_guard.rb', line 8

def mock_exit_call_for_exit_guard(target, method_name)
  allow_any_instance_of(target).to receive(method_name) do |_obj, *args|
    location = caller.find { |l| !l.include?("/gems/") }
    raise RSpec::ExitGuard::ExitCalled, "#{exit_guard_call_string(method_name, args)} called at #{location}"
  end
end

#mock_exit_module_call_for_exit_guard(target, method_name) ⇒ Object



15
16
17
18
19
20
# File 'lib/rspec/exit_guard.rb', line 15

def mock_exit_module_call_for_exit_guard(target, method_name)
  allow(target).to receive(method_name) do |*args|
    location = caller.find { |l| !l.include?("/gems/") }
    raise RSpec::ExitGuard::ExitCalled, "#{exit_guard_call_string(method_name, args)} called at #{location}"
  end
end