File: spec_helper.rb

package info (click to toggle)
ruby-pry-rails 0.3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 320 kB
  • sloc: ruby: 844; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'minitest/autorun'
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