Module: RSpec::ExitGuard::Helpers
- Defined in:
- lib/rspec/exit_guard.rb
Instance Method Summary collapse
- #catch_exit_guard_throw ⇒ Object
- #mock_exit_call_for_exit_guard(target, method_name) ⇒ Object
- #mock_exit_module_call_for_exit_guard(target, method_name) ⇒ Object
Instance Method Details
#catch_exit_guard_throw ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rspec/exit_guard.rb', line 22 def catch_exit_guard_throw exit_call = catch(:exit_guard) do yield nil end return unless exit_call raise RSpec::ExitGuard::ExitCalled, "#{exit_call[:call]} called at #{exit_call[:location]}" end |
#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/") } throw :exit_guard, {call: exit_guard_call_string(method_name, args), location: 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/") } throw :exit_guard, {call: exit_guard_call_string(method_name, args), location: location} end end |