spec/kitchen/config_spec.rb in test-kitchen-1.3.1 vs spec/kitchen/config_spec.rb in test-kitchen-1.4.0.beta.1

- old
+ new

@@ -25,11 +25,13 @@ require "kitchen/driver" require "kitchen/instance" require "kitchen/platform" require "kitchen/provisioner" require "kitchen/suite" +require "kitchen/transport" require "kitchen/util" +require "kitchen/verifier" module Kitchen class DummyLoader @@ -50,23 +52,27 @@ { :loader => loader, :kitchen_root => "/tmp/that/place", :log_root => "/tmp/logs", :test_base_path => "/testing/yo", - :log_level => :debug + :log_level => :debug, + :log_overwrite => false } end let(:default_kitchen_config) do { :defaults => { :driver => "dummy", - :provisioner => "chef_solo" + :provisioner => "chef_solo", + :transport => "ssh", + :verifier => "busser" }, :kitchen_root => "/tmp/that/place", :test_base_path => "/testing/yo", - :log_level => :debug + :log_level => :debug, + :log_overwrite => false } end describe "#loader" do @@ -131,10 +137,23 @@ config.log_level.must_equal :info end end + describe "#log_overwrite" do + + it "returns its log level" do + config.log_overwrite.must_equal false + end + + it "uses :info by default" do + opts.delete(:log_overwrite) + + config.log_overwrite.must_equal true + end + end + describe "#platforms" do before do Kitchen::DataMunger.stubs(:new).returns(munger) Kitchen::Platform.stubs(:new).returns("platform") @@ -150,15 +169,17 @@ loader.expects(:read).returns(Hash.new) config.platforms end - it "constucts a munger with loader data and defaults" do + it "constructs a munger with loader data and defaults" do loader.stubs(:read).returns("datum") - Kitchen::DataMunger.expects(:new).with("datum", default_kitchen_config). - returns(munger) + Kitchen::DataMunger.expects(:new).with { |data, kitchen_config| + data.must_equal "datum" + kitchen_config.is_a?(Hash).must_equal true + }.returns(munger) config.platforms end it "platform_data is called on munger" do @@ -204,12 +225,14 @@ end it "constucts a munger with loader data and defaults" do loader.stubs(:read).returns("datum") - Kitchen::DataMunger.expects(:new).with("datum", default_kitchen_config). - returns(munger) + Kitchen::DataMunger.expects(:new).with { |data, kitchen_config| + data.must_equal "datum" + kitchen_config.is_a?(Hash).must_equal true + }.returns(munger) config.suites end it "platform_data is called on munger" do @@ -245,37 +268,31 @@ [stub(:name => "tiny", :includes => [], :excludes => [])] end let(:munger) do stub( - :busser_data_for => { "junk" => true }, :driver_data_for => { "junk" => true }, - :provisioner_data_for => { "junk" => true } + :provisioner_data_for => { "junk" => true }, + :transport_data_for => { "junk" => true }, + :verifier_data_for => { "junk" => true } ) end before do Kitchen::Instance.stubs(:new).returns("instance") - Kitchen::Busser.stubs(:new).returns("busser") Kitchen::Driver.stubs(:for_plugin).returns("driver") Kitchen::Provisioner.stubs(:for_plugin).returns("provisioner") + Kitchen::Transport.stubs(:for_plugin).returns("transport") + Kitchen::Verifier.stubs(:for_plugin).returns("verifier") Kitchen::Logger.stubs(:new).returns("logger") Kitchen::StateFile.stubs(:new).returns("state_file") Kitchen::DataMunger.stubs(:new).returns(munger) config.stubs(:platforms).returns(platforms) config.stubs(:suites).returns(suites) end - it "constructs a Busser object" do - munger.expects(:busser_data_for).with("tiny", "unax").returns("datum") - Kitchen::Busser.unstub(:new) - Kitchen::Busser.expects(:new).with("tiny", "datum") - - config.instances - end - it "constructs a Driver object" do munger.expects(:driver_data_for).with("tiny", "unax"). returns(:name => "drivey", :datum => "lots") Kitchen::Driver.unstub(:for_plugin) Kitchen::Driver.expects(:for_plugin). @@ -292,16 +309,37 @@ with("provey", :name => "provey", :datum => "lots") config.instances end + it "constructs a Transport object" do + munger.expects(:transport_data_for).with("tiny", "unax"). + returns(:name => "transey", :datum => "lots") + Kitchen::Transport.unstub(:for_plugin) + Kitchen::Transport.expects(:for_plugin). + with("transey", :name => "transey", :datum => "lots") + + config.instances + end + + it "constructs a Verifier object" do + munger.expects(:verifier_data_for).with("tiny", "unax"). + returns(:name => "vervey", :datum => "lots") + Kitchen::Verifier.unstub(:for_plugin) + Kitchen::Verifier.expects(:for_plugin). + with("vervey", :name => "vervey", :datum => "lots") + + config.instances + end + it "constructs a Logger object" do Kitchen::Logger.unstub(:new) Kitchen::Logger.expects(:new).with( :stdout => STDOUT, :color => :cyan, :logdev => "/tmp/logs/tiny-unax.log", + :log_overwrite => false, :level => 0, :progname => "tiny-unax" ) config.instances @@ -314,18 +352,21 @@ config.instances end it "constructs an Instance object from all built objects" do Kitchen::Instance.unstub(:new) + Kitchen::Instance.expects(:new).with( - :busser => "busser", :driver => "driver", :logger => "logger", :suite => suites.first, :platform => platforms.first, :provisioner => "provisioner", + :transport => "transport", + :verifier => "verifier", :state_file => "state_file" ) + config.instances end end describe "using Suite#includes" do