Skip to content

Commit

Permalink
make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbrdo committed Jun 10, 2012
1 parent 76e6a06 commit addaf30
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 128 deletions.
6 changes: 5 additions & 1 deletion lib/rack/webconsole/repl.rb
Expand Up @@ -71,7 +71,7 @@ def call(env)
hash = {}
$pry_output ||= StringIO.new("")
$pry_output.string = ""
if $pry.blank?
if $pry.nil?
Pry.pager = false
$pry = Pry.new(:output => $pry_output, :pager => false)
end
Expand All @@ -83,11 +83,15 @@ def call(env)
pry.inject_sticky_locals(target)
code = params['query']
hash[:prompt] = pry.select_prompt("", target) + Pry::Code.new(code).to_s
begin
if !pry.process_command(code, "", target)
result = target.eval(code, Pry.eval_path, Pry.current_line)
pry.set_last_result(result, target, code)
pry.show_result(result) if pry.should_print?
end
rescue StandardError => e
$pry_output.write("Error: " + e.message)
end
# cleanup (supposed to call when $pry is destroyed)
# pry.repl_epilogue(target)

Expand Down
6 changes: 2 additions & 4 deletions spec/rack/webconsole/repl_spec.rb
Expand Up @@ -23,7 +23,7 @@ module Rack

response = @repl.call(env).last.first

MultiJson.decode(response)['result'].must_equal "8"
MultiJson.decode(response)['result'].must_include "8" # include because of coloring characters
end

it 'maintains local state in subsequent calls thanks to an evil global variable' do
Expand All @@ -41,9 +41,7 @@ module Rack

response = @repl.call(env).last.first # call 2 retrieves a and multiplies it by 8

MultiJson.decode(response)['result'].must_equal "32"
$sandbox.instance_variable_get(:@locals)[:a].must_equal 4
$sandbox.instance_variable_get(:@locals).size.must_equal 1
MultiJson.decode(response)['result'].must_include "32" # include because of coloring characters
end

it "returns any found errors prepended with 'Error:'" do
Expand Down
50 changes: 0 additions & 50 deletions spec/rack/webconsole/sandbox_spec.rb

This file was deleted.

73 changes: 0 additions & 73 deletions spec/rack/webconsole/shell_spec.rb

This file was deleted.

0 comments on commit addaf30

Please sign in to comment.