spec/applix_spec.rb in applix-0.2.2 vs spec/applix_spec.rb in applix-0.3.0
- old
+ new
@@ -1,11 +1,36 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Applix" do
- #it "fails" do
- # fail "hey buddy, you should probably rename this file and start specing for real"
- #end
-
+
+ it 'should call actions by first argument names' do
+ argv = ['func']
+ Applix.main(argv) do
+ handle(:func) { :func_return }
+ end.should == :func_return
+ end
+
+ it 'should pass arguments to function' do
+ argv = ['func', 'p1', 'p2']
+ Applix.main(argv) do
+ handle(:func) { |*args, options| args }
+ end.should == %w{p1 p2}
+ end
+
+ it 'should pass emtpy options to function on default' do
+ argv = %w(func)
+ Applix.main(argv) do
+ handle(:func) { |*_, options| options }
+ end.should == {}
+ end
+
+ it 'should pass a processed options hash' do
+ argv = %w(-a --bar func)
+ Applix.main(argv) do
+ handle(:func) { |*_, options| options }
+ end.should == {:a => true, :bar => true}
+ end
+
it "should parse the old unit test..." do
# -f becomes { :f => true }
# --flag becomes { :flag => true }
(ApplixHash.parse '-f').should == [:f, true]
(ApplixHash.parse '--flag').should == [:flag, true]