diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bdbc54b..9129f95 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,22 +10,10 @@ require 'bundler/setup' require 'i18n' -require 'rspec-spies' +require 'vagrant-lxc/plugin' Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f } -# If we should verify constant names, eager loads -if ENV['VERIFY_CONSTANT_NAMES'] - require 'vagrant-lxc/plugin' - require 'vagrant-lxc/provider' - require 'vagrant-lxc/config' -end - -require 'rspec/fire' -RSpec::Fire.configure do |config| - config.verify_constant_names = ENV['VERIFY_CONSTANT_NAMES'] == '1' -end - RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true diff --git a/spec/unit/action/compress_rootfs_spec.rb b/spec/unit/action/compress_rootfs_spec.rb index 2a70ba4..0a81c72 100644 --- a/spec/unit/action/compress_rootfs_spec.rb +++ b/spec/unit/action/compress_rootfs_spec.rb @@ -1,13 +1,15 @@ require 'unit_helper' +require 'vagrant-lxc/plugin' +require 'vagrant-lxc/provider' require 'vagrant-lxc/action/compress_rootfs' describe Vagrant::LXC::Action::CompressRootFS do let(:app) { double(:app, call: true) } let(:env) { {machine: machine, ui: double(info: true)} } - let(:machine) { instance_double('Vagrant::Machine', provider: provider) } - let(:provider) { instance_double('Vagrant::LXC::Provider', driver: driver) } - let(:driver) { instance_double('Vagrant::LXC::Driver', compress_rootfs: compressed_rootfs_path) } + let(:machine) { double(Vagrant::Machine, provider: provider) } + let(:provider) { double(Vagrant::LXC::Provider, driver: driver) } + let(:driver) { double(Vagrant::LXC::Driver, compress_rootfs: compressed_rootfs_path) } let(:compressed_rootfs_path) { '/path/to/rootfs.tar.gz' } subject { described_class.new(app, env) } diff --git a/spec/unit/action/forward_ports_spec.rb b/spec/unit/action/forward_ports_spec.rb index 126907e..077ee7d 100644 --- a/spec/unit/action/forward_ports_spec.rb +++ b/spec/unit/action/forward_ports_spec.rb @@ -1,7 +1,7 @@ require 'unit_helper' require 'tmpdir' -require 'vagrant-lxc/errors' +require 'vagrant-lxc/provider' require 'vagrant-lxc/action/forward_ports' describe Vagrant::LXC::Action::ForwardPorts do @@ -9,7 +9,7 @@ describe Vagrant::LXC::Action::ForwardPorts do let(:env) { {machine: machine, ui: double(info: true)} } let(:machine) { double(:machine) } let!(:data_dir) { Pathname.new(Dir.mktmpdir) } - let(:provider) { instance_double('Vagrant::LXC::Provider', ssh_info: {host: container_ip}) } + let(:provider) { double(Vagrant::LXC::Provider, ssh_info: {host: container_ip}) } let(:host_ip) { '127.0.0.1' } let(:host_port) { 8080 } let(:guest_port) { 80 } diff --git a/spec/unit/action/handle_box_metadata_spec.rb b/spec/unit/action/handle_box_metadata_spec.rb index 3208355..78c2ce4 100644 --- a/spec/unit/action/handle_box_metadata_spec.rb +++ b/spec/unit/action/handle_box_metadata_spec.rb @@ -102,15 +102,11 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do it 'validates box versions' do %w( 2 3 1.0.0 ).each do |v| metadata['version'] = v - expect { - subject.call(env) - }.to_not raise_error(Vagrant::LXC::Errors::IncompatibleBox) + expect { subject.call(env) }.to_not raise_error end metadata['version'] = '1' - expect { - subject.call(env) - }.to raise_error(Vagrant::LXC::Errors::IncompatibleBox) + expect { subject.call(env) }.to raise_error end it 'raises an error if the rootfs tarball cant be found' do diff --git a/spec/unit/action/setup_package_files_spec.rb b/spec/unit/action/setup_package_files_spec.rb index 6c1c042..cf39158 100644 --- a/spec/unit/action/setup_package_files_spec.rb +++ b/spec/unit/action/setup_package_files_spec.rb @@ -5,9 +5,9 @@ require 'vagrant-lxc/action/setup_package_files' describe Vagrant::LXC::Action::SetupPackageFiles do let(:app) { double(:app, call: true) } let(:env) { {machine: machine, tmp_path: tmp_path, ui: double(info: true), 'package.rootfs' => rootfs_path} } - let(:machine) { instance_double('Vagrant::Machine', box: box) } + let(:machine) { double(Vagrant::Machine, box: box) } let!(:tmp_path) { Pathname.new(Dir.mktmpdir) } - let(:box) { instance_double('Vagrant::Box', directory: tmp_path.join('box')) } + let(:box) { double(Vagrant::Box, directory: tmp_path.join('box')) } let(:rootfs_path) { tmp_path.join('rootfs-amd64.tar.gz') } subject { described_class.new(app, env) } diff --git a/spec/unit/driver/cli_spec.rb b/spec/unit/driver/cli_spec.rb index 9e78353..e2f6c4a 100644 --- a/spec/unit/driver/cli_spec.rb +++ b/spec/unit/driver/cli_spec.rb @@ -1,9 +1,10 @@ require 'unit_helper' +require 'vagrant-lxc/sudo_wrapper' require 'vagrant-lxc/driver/cli' describe Vagrant::LXC::Driver::CLI do - let(:sudo_wrapper) { instance_double('Vagrant::LXC::SudoWrapper', run: true) } + let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) } subject { described_class.new(sudo_wrapper) } @@ -197,6 +198,6 @@ describe Vagrant::LXC::Driver::CLI do }.to raise_error(described_class::TransitionBlockNotProvided) end - pending 'waits for the expected container state' + skip 'waits for the expected container state' end end diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 1b31e22..ad52b29 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -1,15 +1,15 @@ require 'unit_helper' -require 'vagrant' require 'vagrant-lxc/driver' require 'vagrant-lxc/driver/cli' +require 'vagrant-lxc/sudo_wrapper' describe Vagrant::LXC::Driver do describe 'container name validation' do let(:unknown_container) { described_class.new('unknown', nil, cli) } let(:valid_container) { described_class.new('valid', nil, cli) } let(:new_container) { described_class.new(nil, nil) } - let(:cli) { instance_double('Vagrant::LXC::Driver::CLI', list: ['valid']) } + let(:cli) { double(Vagrant::LXC::Driver::CLI, list: ['valid']) } it 'raises a ContainerNotFound error if an unknown container name gets provided' do expect { @@ -37,7 +37,7 @@ describe Vagrant::LXC::Driver do let(:template_opts) { {'--some' => 'random-option'} } let(:config_file) { '/path/to/lxc-config-from-box' } let(:rootfs_tarball) { '/path/to/cache/rootfs.tar.gz' } - let(:cli) { instance_double('Vagrant::LXC::Driver::CLI', :create => true, :name= => true) } + let(:cli) { double(Vagrant::LXC::Driver::CLI, :create => true, :name= => true) } subject { described_class.new(nil, nil, cli) } @@ -60,7 +60,7 @@ describe Vagrant::LXC::Driver do end describe 'destruction' do - let(:cli) { instance_double('Vagrant::LXC::Driver::CLI', destroy: true) } + let(:cli) { double(Vagrant::LXC::Driver::CLI, destroy: true) } subject { described_class.new('name', nil, cli) } @@ -74,8 +74,8 @@ describe Vagrant::LXC::Driver do describe 'start' 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) } + let(:cli) { double(Vagrant::LXC::Driver::CLI, start: true) } + let(:sudo) { double(Vagrant::LXC::SudoWrapper, su_c: true) } subject { described_class.new('name', sudo, cli) } @@ -94,7 +94,7 @@ describe Vagrant::LXC::Driver do end describe 'halt' do - let(:cli) { instance_double('Vagrant::LXC::Driver::CLI', shutdown: true) } + let(:cli) { double(Vagrant::LXC::Driver::CLI, shutdown: true) } subject { described_class.new('name', nil, cli) } @@ -129,7 +129,7 @@ describe Vagrant::LXC::Driver do describe 'state' do let(:cli_state) { :something } - let(:cli) { instance_double('Vagrant::LXC::Driver::CLI', state: cli_state) } + let(:cli) { double(Vagrant::LXC::Driver::CLI, state: cli_state) } subject { described_class.new('name', nil, cli) } @@ -143,7 +143,7 @@ describe Vagrant::LXC::Driver do let(:folders) { [shared_folder] } let(:rootfs_path) { Pathname('/path/to/rootfs') } let(:expected_guest_path) { "#{rootfs_path}/vagrant" } - let(:sudo_wrapper) { instance_double('Vagrant::LXC::SudoWrapper', run: true) } + let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) } subject { described_class.new('name', sudo_wrapper) } diff --git a/spec/unit_helper.rb b/spec/unit_helper.rb index 4122faf..844be91 100644 --- a/spec/unit_helper.rb +++ b/spec/unit_helper.rb @@ -7,8 +7,6 @@ if defined? SimpleCov end RSpec.configure do |config| - config.include RSpec::Fire - config.include UnitExampleGroup, :type => :unit, :example_group => { :file_path => /\bspec\/unit\// }