Sha256: 00f82b2536887acdbf09aa4ca90572d61aa442dfd0ba28f49168dbf1876fc57d
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
require File.join(File.dirname(__FILE__), 'test_helper') describe "Shell" do before { reset_ripl } def shell(options={}) Ripl.shell(options) end describe "#loop" do before { mock(shell).before_loop } it "exits with exit" do mock(shell).get_input { 'exit' } dont_allow(shell).eval_input shell.loop end it "exits with Control-D" do mock(shell).get_input { nil } dont_allow(shell).eval_input shell.loop end end describe "#prompt" do it "as a string" do shell(:prompt=>'> ').prompt.should == '> ' end it "as a lambda" do shell(:prompt=>lambda { "#{10 + 10}> " }).prompt.should == '20> ' end end describe "#eval_input" do before { @line = shell.line; shell.eval_input("10 ** 2") } describe "normally" do it "sets result" do shell.result.should == 100 end it "sets _" do shell.eval_input('_') shell.result.should == 100 end it "increments line" do shell.line.should == @line + 1 end end describe "with error" do before { @line = shell.line @stderr = capture_stderr { shell.eval_input('{') } } it "prints it" do @stderr.should =~ /^SyntaxError: compile error/ end it "sets @error_raised" do shell.instance_variable_get("@error_raised").should == true end it "increments line" do shell.line.should == @line + 1 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ripl-0.2.3 | test/shell_test.rb |
ripl-0.2.2 | test/shell_test.rb |
ripl-0.2.1 | test/shell_test.rb |