Module: Pry::Testable::Mockable
- Defined in:
- lib/pry/testable/mockable.rb
Instance Method Summary collapse
Instance Method Details
#mock_command(cmd, args = [], opts = {}) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/pry/testable/mockable.rb', line 8 def mock_command(cmd, args = [], opts = {}) output = StringIO.new pry = Pry.new(output: output) ret = cmd.new(opts.merge(pry_instance: pry, output: output)).call_safely(*args) Struct.new(:output, :return).new(output.string, ret) end |
#mock_exception(*mock_backtrace) ⇒ Object
15 16 17 18 19 |
# File 'lib/pry/testable/mockable.rb', line 15 def mock_exception(*mock_backtrace) StandardError.new.tap do |e| e.define_singleton_method(:backtrace) { mock_backtrace } end end |