test/runner_test.rb in ripl-0.2.4 vs test/runner_test.rb in ripl-0.2.5
- old
+ new
@@ -4,24 +4,24 @@
describe ".start" do
before { reset_ripl }
it "loads riplrc" do
mock_riplrc
- mock(Ripl).shell(anything) { shell = Shell.new; mock(shell).loop; shell }
+ mock_shell
Ripl.start
end
it "sets a shell's variables" do
mock_riplrc
- mock(Shell).create(anything) {|e| shell = Shell.new(e); mock(shell).loop; shell }
+ mock_shell
Ripl.start(:name=>'shh')
Ripl.shell.name.should == 'shh'
end
it "overrides config set in riplrc" do
mock_riplrc { Ripl.config[:name] = 'blah' }
- mock(Shell).create(anything) {|e| shell = Shell.new(e); mock(shell).loop; shell }
+ mock_shell
Ripl.start(:name=>'dude')
Ripl.shell.name.should == 'dude'
end
end
@@ -29,32 +29,33 @@
describe "riplrc" do
before { reset_ripl }
it "sets config" do
mock_riplrc { Ripl.config[:blah] = true }
- mock(Shell).create(anything) {|e| shell = Shell.new(e); mock(shell).loop; shell }
+ mock_shell
Runner.run([])
Ripl.config[:blah].should == true
end
it "catches and prints error" do
mock(Runner).load(anything) { raise SyntaxError }
- mock(Ripl).shell(anything) { shell = Shell.new; mock(shell).loop; shell }
- capture_stderr { Runner.run([]) }.should =~ %r{^Error while loading ~/.riplrc:\nSyntaxError:}
+ mock_shell
+ capture_stderr { Runner.run([]) }.should =~ %r{^ripl: Error while loading ~/.riplrc:\nSyntaxError:}
end
end
describe "with subcommand" do
it "that is valid gets invoked with arguments" do
mock(Runner).exec('ripl-rails', '--blah')
ripl("rails", '--blah')
end
- it "has global options before it parsed" do
- mock(Runner).parse_options(anything) {|e| e.shift }
+ it "has global option before it parsed" do
mock(Runner).exec('ripl-rails')
- ripl("-f", "rails")
+ dont_allow(Runner).load_rc(anything)
+ ripl("-F", "rails", :riplrc=>false)
+ ENV.delete('RIPLRC')
end
it "that is invalid aborts" do
mock(Runner).abort("`zzz' is not a ripl command.")
ripl 'zzz'
@@ -125,17 +126,29 @@
end
end
it "with -f option doesn't load irbrc" do
reset_ripl
- mock(Shell).create(anything) {|e|
- shell = Shell.new(e)
+ stub(Kernel).at_exit()
+ mock_shell { |shell|
mock(shell).loop_once { throw :ripl_exit }
dont_allow(Runner).load_rc(anything)
- shell
}
ripl("-f")
+ ENV.delete('RIPL_IRBRC')
Ripl.config[:irbrc] = '~/.irbrc'
+ end
+
+ it "with -F option doesn't load riplrc" do
+ reset_ripl
+ dont_allow(Runner).load_rc(anything)
+ mock_shell { |shell|
+ stub(Kernel).at_exit
+ mock(shell).before_loop
+ mock(shell).loop_once { throw :ripl_exit }
+ }
+ ripl("-F", :riplrc => false)
+ ENV.delete('RIPLRC')
end
it "with -d option sets $DEBUG" do
ripl("-d", :start=>true)
$DEBUG.should == true