spec/cli/app_spec.rb in wojtekmach-cli-0.1.3 vs spec/cli/app_spec.rb in wojtekmach-cli-0.2.0
- old
+ new
@@ -77,6 +77,36 @@
@app.run!(%w( -m Goodmorning! ))
end
end
end
end
+
+ describe App, "a simple app" do
+ before do
+ @app = App.new("hello") do
+ default do
+ puts args[0]
+ end
+ end
+ end
+
+ it "always runs the default action" do
+ $stdout.should_receive(:puts).with("Hello, World!")
+ @app.run!(["Hello, World!"])
+
+ $stdout.should_receive(:puts).with("1")
+ @app.run!(%w(1 2 3))
+ end
+ end
+
+ describe App, "blank app" do
+ describe "run!" do
+ it "should fail" do
+ @app = App.new("blank") do
+ end
+
+ $stdout.should_receive(:puts).with("Error: you have to define 'default' action")
+ @app.run!([])
+ end
+ end
+ end
end