From 2082a5a81d61a8fa4e6e871d4d69aeb5c04c1790 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 31 Jul 2013 22:35:49 -0300 Subject: [PATCH] Remove some unused args and add pending specs so that we don't forget to test it --- lib/vagrant-lxc/driver.rb | 5 ++--- lib/vagrant-lxc/driver/cli.rb | 6 ++---- spec/unit/driver/cli_spec.rb | 8 -------- spec/unit/driver_spec.rb | 9 +++++++-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 9289d88..9b6b612 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -76,7 +76,7 @@ module Vagrant prune_customizations write_customizations(customizations + @customizations) - @cli.transition_to(:running) { |c| c.start([], (extra || nil)) } + @cli.transition_to(:running) { |c| c.start(extra) } end def forced_halt @@ -124,8 +124,7 @@ module Vagrant end def prune_customizations - # Use sed to just strip out the block of code which was inserted - # by Vagrant + # Use sed to just strip out the block of code which was inserted by Vagrant @logger.debug 'Prunning vagrant-lxc customizations' @sudo_wrapper.su_c("sed -e '/^# VAGRANT-BEGIN/,/^# VAGRANT-END/ d' -ibak #{base_path.join('config')}") end diff --git a/lib/vagrant-lxc/driver/cli.rb b/lib/vagrant-lxc/driver/cli.rb index 0bc1829..bdbee19 100644 --- a/lib/vagrant-lxc/driver/cli.rb +++ b/lib/vagrant-lxc/driver/cli.rb @@ -63,10 +63,8 @@ module Vagrant run :destroy, '--name', @name end - def start(overrides = [], extra_opts = []) - options = [] - options += extra_opts if extra_opts - run :start, '-d', '--name', @name, *options + def start(options = []) + run :start, '-d', '--name', @name, *Array(options) end def stop diff --git a/spec/unit/driver/cli_spec.rb b/spec/unit/driver/cli_spec.rb index 0a0e65b..5ff5b0f 100644 --- a/spec/unit/driver/cli_spec.rb +++ b/spec/unit/driver/cli_spec.rb @@ -96,14 +96,6 @@ describe Vagrant::LXC::Driver::CLI do '--name', name ) end - - it 'uses provided array to override container configs' do - subject.start([['config', 'value'], ['other', 'value']]) - subject.should have_received(:run).with(:start, '-d', '--name', name, - '-s', "lxc.config='value'", - '-s', "lxc.other='value'" - ) - end end describe 'shutdown' do diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 83bf6e7..ab52f05 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -75,8 +75,9 @@ describe Vagrant::LXC::Driver do let(:customizations) { [['a', '1'], ['b', '2']] } let(:internal_customization) { ['internal', 'customization'] } let(:cli) { instance_double('Vagrant::LXC::Driver::CLI', start: true) } + let(:sudo) { instance_double('Vagrant::LXC::SudoWrapper', su_c: true) } - subject { described_class.new('name', nil, cli) } + subject { described_class.new('name', sudo, cli) } before do cli.stub(:transition_to).and_yield(cli) @@ -84,8 +85,12 @@ describe Vagrant::LXC::Driver do subject.start(customizations) end + it 'prunes previous customizations before writing' + + it 'writes configurations to config file' + it 'starts container with configured customizations' do - cli.should have_received(:start).with(customizations + [internal_customization], nil) + cli.should have_received(:start) end it 'expects a transition to running state to take place' do