Permalink
Browse files

enable last pending test, required setting up commands for executables

  • Loading branch information...
1 parent 586b83e commit 6de8a75dbf7c166f710ea5ca09b8dbce70aa90c0 @cldwalker committed Mar 18, 2012
Showing with 27 additions and 5 deletions.
  1. +6 −5 test/bin_runner_test.rb
  2. +21 −0 test/test_helper.rb
View
@@ -57,11 +57,12 @@ def aborts_with(regex)
stderr.chomp.should == "Error: blarg"
end
- # TODO: enable once a default command exists
- xit "prints error for too many arguments" do
- boson "commands 1 2 3"
- stderr.should =~ /^'commands' was called incorrectly/
- process.success?.should == false
+ it "prints error for too many arguments" do
+ with_command('dude') do
+ boson "dude 1 2 3"
+ stderr.should =~ /^'dude' was called incorrectly/
+ process.success?.should == false
+ end
end
it "prints error for invalid command" do
View
@@ -37,6 +37,27 @@ def with_config(options)
Boson.config = old_config
end
+ # for use with executables
+ def with_command(cmd)
+ old = ENV['BOSONRC']
+ ENV['BOSONRC'] = File.dirname(__FILE__) + '/.bosonrc.temp'
+ File.open(ENV['BOSONRC'], 'w') {|f|
+ f.puts <<-STR
+require 'boson/runner'
+class SomeRunner < Boson::Runner
+def #{cmd}
+end
+end
+Boson::Manager.load SomeRunner
+STR
+ }
+
+ yield
+
+ FileUtils.rm_f ENV['BOSONRC']
+ ENV['BOSONRC'] = old
+ end
+
def manager_load(lib, options={})
@stderr = capture_stderr { Manager.load(lib, options) }
end

0 comments on commit 6de8a75

Please sign in to comment.