0
require File.dirname(__FILE__) + '/spec_helper'
0
@@ -53,76 +32,95 @@ class MyApp < Thor
0
+ def method_missing(meth, *args)
0
it "calls a no-param method when no params are passed" do
0
- MyApp.start.
should == true
0
+ MyApp.start.
must == true
0
it "calls a single-param method when a single param is passed" do
0
ARGV.replace ["animal", "fish"]
0
- MyApp.start.
should == ["fish"]
0
+ MyApp.start.
must == ["fish"]
0
it "calls the alias of a method if one is provided via .map" do
0
ARGV.replace ["-T", "fish"]
0
- MyApp.start.
should == ["fish"]
0
+ MyApp.start.
must == ["fish"]
0
it "raises an error if a required param is not provided" do
0
ARGV.replace ["animal"]
0
- lambda { MyApp.start }.
should raise_error(ArgumentError)
0
+ lambda { MyApp.start }.
must raise_error(ArgumentError)
0
it "calls a method with an optional boolean param when the param is passed" do
0
ARGV.replace ["foo", "one", "--force"]
0
- MyApp.start.
should == ["one", {"force" => true, "f" => true}]
0
+ MyApp.start.
must == ["one", {"force" => true, "f" => true}]
0
it "calls a method with an optional boolean param when the param is not passed" do
0
ARGV.replace ["foo", "one"]
0
- MyApp.start.
should == ["one", {}]
0
+ MyApp.start.
must == ["one", {}]
0
it "calls a method with a required key/value param" do
0
ARGV.replace ["bar", "one", "two", "--option1", "hello"]
0
- MyApp.start.
should == ["one", "two", {"option1" => "hello", "o" => "hello"}]
0
+ MyApp.start.
must == ["one", "two", {"option1" => "hello", "o" => "hello"}]
0
it "errors out when a required key/value option is not passed" do
0
ARGV.replace ["bar", "one", "two"]
0
- lambda { MyApp.start }.
should raise_error(Getopt::Long::Error)
0
+ lambda { MyApp.start }.
must raise_error(Getopt::Long::Error)
0
it "calls a method with an optional key/value param" do
0
ARGV.replace ["baz", "one", "--option1", "hello"]
0
- MyApp.start.
should == ["one", {"option1" => "hello", "o" => "hello"}]
0
+ MyApp.start.
must == ["one", {"option1" => "hello", "o" => "hello"}]
0
it "calls a method with an empty Hash for options if an optional key/value param is not provided" do
0
ARGV.replace ["baz", "one"]
0
- MyApp.start.should == ["one", {}]
0
+ MyApp.start.must == ["one", {}]
0
+ it "calls method_missing if an unknown method is passed in" do
0
+ ARGV.replace ["unk", "hello"]
0
+ MyApp.start.must == [:unk, ["hello"]]
0
+ it "does not call a private method no matter what" do
0
+ MyApp.start.must == nil
0
it "provides useful help info for a simple method" do
0
- StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
should =~ /zoo +zoo around/
0
+ StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
must =~ /zoo +zoo around/
0
it "provides useful help info for a method with one param" do
0
- StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
should =~ /animal TYPE +horse around/
0
+ StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
must =~ /animal TYPE +horse around/
0
it "provides useful help info for a method with boolean options" do
0
- StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
should =~ /foo BAR \-\-force +do some fooing/
0
+ StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
must =~ /foo BAR \[\-\-force\] +do some fooing/
0
it "provides useful help info for a method with required options" do
0
- StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
should =~ /bar BAZ BAT \-\-option1=OPTION1 +do some barring/
0
+ StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
must =~ /bar BAZ BAT \-\-option1=OPTION1 +do some barring/
0
it "provides useful help info for a method with optional options" do
0
- StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
should =~ /baz BAT \[\-\-option1=OPTION1\] +do some bazzing/
0
+ StdOutCapturer.call_func { ARGV.replace ["help"]; MyApp.start }.
must =~ /baz BAT \[\-\-option1=OPTION1\] +do some bazzing/
0
\ No newline at end of file
Comments
No one has commented yet.