test/vagrant/commands/base_test.rb in vagrant-0.3.4 vs test/vagrant/commands/base_test.rb in vagrant-0.4.0
- old
+ new
@@ -65,24 +65,44 @@
end
context "executing" do
should "show version if flag is set" do
@instance.expects(:puts_version).once
- @instance.expects(:puts_help).never
+ @instance.expects(:show_help).never
@instance.execute(["--version"])
end
should "just print the help by default" do
@instance.expects(:puts_version).never
- @klass.expects(:puts_help)
+ @instance.expects(:show_help).once
@instance.execute([])
end
end
+ context "all or single methods" do
+ should "call the single method if a name is given" do
+ name = "bar"
+ @instance.expects(:foo_single).with(name).once
+ @instance.all_or_single(["bar"], :foo)
+ end
+
+ should "call the single method for each VM if no name is given" do
+ vms = { :foo => nil, :bar => nil }
+ vms.keys.each do |name|
+ @instance.expects(:foo_single).with(name).once
+ end
+
+ @env.stubs(:vms).returns(vms)
+ @instance.all_or_single([], :foo)
+ end
+ end
+
context "getting the option parser" do
should "create it with the options spec if it hasn't been created yet" do
opts = mock("opts")
+ opts.stubs(:on)
+
result = mock("result")
OptionParser.expects(:new).yields(opts).returns(result)
@instance.expects(:options_spec).with(opts)
assert_equal result, @instance.option_parser(true)
@@ -108,11 +128,12 @@
@instance.stubs(:option_parser).returns(@option_parser)
@instance.stubs(:options).returns(@options)
end
should "parse the options with the args" do
- @option_parser.expects(:parse!).with(@args).once
- assert_equal @options, @instance.parse_options(@args)
+ result = mock("result")
+ @option_parser.expects(:parse!).with(@args).once.returns(result)
+ assert_equal result, @instance.parse_options(@args)
end
end
end
end