diff --git a/spec/Vagrantfile b/spec/Vagrantfile new file mode 100644 index 0000000..ca98915 --- /dev/null +++ b/spec/Vagrantfile @@ -0,0 +1,13 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.require_plugin 'vagrant-lxc' + +Vagrant.configure("2") do |config| + config.vm.box = "quantal64" + config.vm.hostname = 'lxc-test-box' + + config.vm.box_url = 'http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-04-10.box' + # Uncomment to test boxes built locally: + # config.vm.box_url = '../boxes/output/lxc-quantal64.box' +end diff --git a/spec/acceptance/sanity_check_spec.rb b/spec/acceptance/sanity_check_spec.rb new file mode 100644 index 0000000..370864b --- /dev/null +++ b/spec/acceptance/sanity_check_spec.rb @@ -0,0 +1,68 @@ +require 'acceptance_helper' + +describe 'Sanity check' do + context 'running a `vagrant up` from scratch' do + before(:all) do + destroy_container + vagrant_up + end + + it 'creates a the container' + + it 'starts the newly created container' + + it 'mounts shared folders with the right permissions' + + it 'provisions the container based on Vagrantfile configs' + + it 'forwards configured ports' + + it "is able to be SSH'ed" + end + + context '`vagrant halt` on a running container' do + before(:all) do + destroy_container + vagrant_up + vagrant_halt + end + + it 'shuts down container' + + it 'clears forwarded ports' + end + + context '`vagrant destroy`' do + before(:all) do + destroy_container + vagrant_up + vagrant_destroy + end + + it 'destroys the underlying container' + end + + def destroy_container + `sudo lxc-shutdown -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\`` + `sudo lxc-wait -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\` --state STOPPED` + `sudo lxc-destroy -n \`cat /vagrant/spec/.vagrant/machines/default/lxc/id\`` + end + + def vagrant_up + opts = { cwd: 'spec' } + env = Vagrant::Environment.new(opts) + env.cli('up', '--provider', 'lxc') + end + + def vagrant_halt + opts = { cwd: 'spec' } + env = Vagrant::Environment.new(opts) + env.cli('halt') + end + + def vagrant_destroy + opts = { cwd: 'spec' } + env = Vagrant::Environment.new(opts) + env.cli('destroy', '-f') + end +end diff --git a/spec/acceptance_helper.rb b/spec/acceptance_helper.rb new file mode 100644 index 0000000..a71724e --- /dev/null +++ b/spec/acceptance_helper.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +require 'vagrant' +require 'vagrant-lxc' + +# RSpec.configure do |config| +# config.include AcceptanceExampleGroup, :type => :unit, :example_group => { +# :file_path => /\bspec\/unit\// +# } +# end diff --git a/tasks/spec.rake b/tasks/spec.rake index 8b2f3de..d7e61a6 100644 --- a/tasks/spec.rake +++ b/tasks/spec.rake @@ -1,9 +1,8 @@ begin require 'rspec/core/rake_task' - # TODO: add 'spec:acceptance' and 'spec:integration' then they are in place desc 'Run all specs' - task :spec => ['spec:unit'] + task :spec => ['spec:unit', 'spec:acceptance'] desc 'Default task which runs all specs with code coverage enabled' task :default => ['spec:set_coverage', 'spec']