test/runner_test.rb in ripl-0.2.9 vs test/runner_test.rb in ripl-0.3.0
- old
+ new
@@ -92,20 +92,26 @@
mock_exec 'blah', '-F'
ripl("rails", "blah", "-F", :riplrc=>false)
Ripl::Runner.argv.should == ['blah', '-F']
end
- it "has other global option parsed" do
+ it "has global option parsed" do
mock_exec '-r=blah'
mock(Runner).require('blah')
ripl("rails", "-r=blah")
end
+ it "has global option parsed after arguments" do
+ mock_exec 'test', '-r=blah'
+ mock(Runner).require('blah')
+ ripl("rails", "test", "-r=blah", :riplrc=>false)
+ end
+
it "has automatic --help" do
mock_exec '--help'
mock(Runner).exit
- ripl("rails", "--help").chomp.should == "ripl rails [OPTIONS] [ARGS]"
+ ripl("rails", "--help").chomp.should == "ripl rails [ARGS] [OPTIONS]"
end
it "that is invalid aborts" do
mock(Runner).abort("`zzz' is not a ripl command.")
ripl 'zzz', :riplrc => false, :loop => false
@@ -178,11 +184,10 @@
end
it "with -f option doesn't load irbrc" do
reset_ripl
reset_config
- stub(Kernel).at_exit()
mock_shell { |shell|
mock(shell).loop_once { throw :ripl_exit }
dont_allow(Runner).load_rc(anything)
}
ripl("-f", :loop => false)
@@ -191,13 +196,13 @@
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 }
+ mock(shell).after_loop
}
ripl("-F", :riplrc => false, :loop => false)
end
it "with -d option sets $DEBUG" do
@@ -248,7 +253,19 @@
capture_stderr {
ripl('--blah')
}.chomp.should == "ripl: invalid option `blah'"
end
end
+ end
+
+ describe "API" do
+ Runner::API.instance_methods.each do |meth|
+ it "##{meth} is accessible to plugins" do
+ mod = Object.const_set "Ping_#{meth}", Module.new
+ mod.send(:define_method, meth) { "pong_#{meth}" }
+ Runner.extend mod
+ Runner.send(meth).should == "pong_#{meth}"
+ end
+ end
+ after_all { Runner.extend Runner::API }
end
end