1
0
Fork 0
mirror of https://github.com/pry/pry-rails.git synced 2022-11-09 12:36:03 -05:00
pry--pry-rails/spec/spec_helper.rb
Kyrylo Silin 6ef5963eba SpecHelper: get rid of the minitest warning
The warning is: "Warning: you should require 'minitest/autorun' instead"
2013-05-19 10:32:57 +03:00

40 lines
690 B
Ruby

require 'minitest/autorun'
require 'rr'
class MiniTest::Spec
include RR::Adapters::RRMethods
end
require 'config/environment'
# Pry testing stuff (taken from Pry itself)
Pry.color = false
def redirect_pry_io(new_in, new_out = StringIO.new)
old_in = Pry.input
old_out = Pry.output
Pry.input = new_in
Pry.output = new_out
begin
yield
ensure
Pry.input = old_in
Pry.output = old_out
end
end
def mock_pry(*args)
binding = args.first.is_a?(Binding) ? args.shift : binding()
input = StringIO.new(args.join("\n"))
output = StringIO.new
redirect_pry_io(input, output) do
Pry.start(binding, :hooks => Pry::Hooks.new)
end
output.string
end