Basic scaffolding for acceptance specs
This commit is contained in:
parent
243701a3f8
commit
f09e722691
4 changed files with 92 additions and 2 deletions
13
spec/Vagrantfile
vendored
Normal file
13
spec/Vagrantfile
vendored
Normal file
|
@ -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
|
68
spec/acceptance/sanity_check_spec.rb
Normal file
68
spec/acceptance/sanity_check_spec.rb
Normal file
|
@ -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
|
10
spec/acceptance_helper.rb
Normal file
10
spec/acceptance_helper.rb
Normal file
|
@ -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
|
|
@ -1,9 +1,8 @@
|
||||||
begin
|
begin
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
# TODO: add 'spec:acceptance' and 'spec:integration' then they are in place
|
|
||||||
desc 'Run all specs'
|
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'
|
desc 'Default task which runs all specs with code coverage enabled'
|
||||||
task :default => ['spec:set_coverage', 'spec']
|
task :default => ['spec:set_coverage', 'spec']
|
||||||
|
|
Loading…
Reference in a new issue