diff --git a/Gemfile b/Gemfile index c3be1d5..781e97c 100644 --- a/Gemfile +++ b/Gemfile @@ -23,8 +23,9 @@ end group :plugins do gem 'vagrant-lxc', path: '.' - # TODO: Disable these plugins when running acceptance specs - gem 'vagrant-cachier', git: 'https://github.com/fgrehm/vagrant-cachier.git' - gem 'vagrant-pristine', git: 'https://github.com/fgrehm/vagrant-pristine.git' - gem 'vagrant-omnibus' + if ENV['ACCEPTANCE'] != 'true' + gem 'vagrant-cachier', git: 'https://github.com/fgrehm/vagrant-cachier.git' + gem 'vagrant-pristine', git: 'https://github.com/fgrehm/vagrant-pristine.git' + gem 'vagrant-omnibus' + end end diff --git a/tasks/spec.rake b/tasks/spec.rake index ddd4867..a44bf01 100644 --- a/tasks/spec.rake +++ b/tasks/spec.rake @@ -3,7 +3,7 @@ begin require 'coveralls/rake/task' desc 'Run all specs' - task :spec => ['spec:unit', 'spec:acceptance'] + task :spec => ['spec:set_coverage', 'spec:unit', 'spec:acceptance'] desc 'Default task which runs all specs with code coverage enabled' task :default => ['spec:set_coverage', 'spec:unit'] @@ -17,17 +17,24 @@ namespace :spec do ENV['COVERAGE'] = 'true' end - def types - dirs = Dir['./spec/**/*_spec.rb'].map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') }.uniq - Hash[dirs.map { |d| [d.split('/').last, d] }] + desc 'Run acceptance specs using vagrant-spec' + task :acceptance do + components = %w( + basic + network/forwarded_port + synced_folder + synced_folder/nfs + synced_folder/rsync + provisioner/shell + provisioner/puppet + provisioner/chef-solo + package + ).map{|s| "provider/lxc/#{s}" } + sh "export ACCEPTANCE=true && bundle exec vagrant-spec test --components=#{components.join(' ')}" end - types.each do |type, dir| - desc "Run the code examples in #{dir}" - RSpec::Core::RakeTask.new(type) do |t| - # Tells rspec-fire to verify if constants used really exist - ENV['VERIFY_CONSTANT_NAMES'] = '1' - t.pattern = "./#{dir}/**/*_spec.rb" - end + desc "Run unit specs with rspec" + RSpec::Core::RakeTask.new(:unit) do |t| + t.pattern = "./unit/**/*_spec.rb" end end diff --git a/vagrant-spec.config.rb b/vagrant-spec.config.rb new file mode 100644 index 0000000..c584211 --- /dev/null +++ b/vagrant-spec.config.rb @@ -0,0 +1,27 @@ +unless ENV['USER'] == 'vagrant' + puts 'Acceptance specs are supposed to run from one of the vagrant-lxc dev machines' + exit 1 +end + +# if defined? SimpleCov +# SimpleCov.command_name 'acceptance' +# end + +if ENV['BOX_PATH'] == nil + latest = ENV.fetch('LATEST_BOXES','2014-03-11') + release = ENV.fetch('RELEASE', 'precise') + local_path ="#{File.expand_path("../", __FILE__)}/boxes/output/#{latest}/vagrant-lxc-#{release}-amd64.box" + if File.exists?(local_path) + ENV['BOX_PATH'] = local_path + else + raise 'Set $BOX_PATH to the latest released boxes' + end +end + +Vagrant::Spec::Acceptance.configure do |c| + c.component_paths << "spec/acceptance" + + c.provider 'lxc', + box: ENV['BOX_PATH'], + features: ['!suspend'] +end