test/runner_test.rb in ripl-0.2.5 vs test/runner_test.rb in ripl-0.2.6
- old
+ new
@@ -155,23 +155,50 @@
$DEBUG.should == true
$DEBUG = nil
end
it "with -v option prints version" do
- should.raise(SystemExit) { ripl("-v").should == Ripl::VERSION }
+ mock(Runner).exit
+ ripl("-v", :start=>true).chomp.should == Ripl::VERSION
end
it "with -h option prints help" do
- should.raise(SystemExit) {
- actual = ripl("-v")
- actual.should =~ /^Usage: ripl/
- actual.should =~ /Options:\n -f/
- }
+ mock(Runner).exit
+ actual = ripl("-h", :start=>true)
+ actual.should =~ /^Usage: ripl/
+ actual.should =~ /Options:\n -f/
end
it "with invalid options prints errors" do
capture_stderr {
ripl('--blah', '-z', :start=>true)
}.chomp.should == "ripl: invalid option `blah'\nripl: invalid option `z'"
+ end
+
+ describe "with plugin" do
+ before_all do
+ Moo = Module.new do
+ def parse_option(option, argv)
+ option == '--moo' ? puts("MOOOO") : super
+ end
+ end
+ Runner.extend Moo
+ Runner.add_options ['--moo', 'just moos']
+ end
+
+ it "parses plugin option" do
+ ripl("--moo", :start=>true).chomp.should == 'MOOOO'
+ end
+
+ it "displays plugin option in --help" do
+ mock(Runner).exit
+ ripl("--help", :start=>true).should =~ /--moo\s*just moos/
+ end
+
+ it "handles invalid option" do
+ capture_stderr {
+ ripl('--blah', :start=>true)
+ }.chomp.should == "ripl: invalid option `blah'"
+ end
end
end
end