diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..21b4bce --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: ruby +rvm: + - 1.9.3 + - 2.0.0 +before_script: + - bundle exec berks install + - bundle exec foodcritic -f any . diff --git a/Gemfile b/Gemfile index 2fea7a8..90bf270 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,5 @@ source 'https://rubygems.org' -gem 'rake' -gem 'rspec' gem 'foodcritic' -gem 'berkshelf' -gem 'thor-foodcritic' -gem 'vagrant-wrapper' - -group :integration do - gem 'test-kitchen', :git => "git://github.com/opscode/test-kitchen.git" - gem 'kitchen-vagrant', :git => "git://github.com/opscode/kitchen-vagrant.git" - gem 'kitchen-ec2', :git => "git://github.com/opscode/kitchen-ec2.git" - gem 'kitchen-lxc', :git => "https://github.com/portertech/kitchen-lxc.git", :tag => 'v0.0.1.beta2' -end +gem 'berkshelf', '~> 2.0' +gem 'chefspec', '~> 3.0' diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..70a846d --- /dev/null +++ b/Rakefile @@ -0,0 +1,5 @@ +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec diff --git a/libraries/matchers.rb b/libraries/matchers.rb new file mode 100644 index 0000000..bb0a94c --- /dev/null +++ b/libraries/matchers.rb @@ -0,0 +1,25 @@ +if defined?(ChefSpec) + def install_python_pip(package_name) + ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :install, package_name) + end + + def upgrade_python_pip(package_name) + ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :upgrade, package_name) + end + + def remove_python_pip(package_name) + ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :remove, package_name) + end + + def purge_python_pip(package_name) + ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :purge, package_name) + end + + def create_python_virtualenv(virtualenv_name) + ChefSpec::Matchers::ResourceMatcher.new(:python_virtualenv, :create, virtualenv_name) + end + + def delete_python_virtualenv(virtualenv_name) + ChefSpec::Matchers::ResourceMatcher.new(:python_virtualenv, :delete, virtualenv_name) + end +end diff --git a/spec/default_spec.rb b/spec/default_spec.rb new file mode 100644 index 0000000..4eda06b --- /dev/null +++ b/spec/default_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe 'python::default' do + let :chef_run do + ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04').converge described_recipe + end + + before do + stub_command("/usr/bin/python -c 'import setuptools'").and_return(true) + end + + it 'includes python::package by default' do + expect(chef_run).to include_recipe('python::package') + end + + it 'includes python::pip' do + expect(chef_run).to include_recipe('python::pip') + end + + it 'includes python::virtualenv' do + expect(chef_run).to include_recipe('python::virtualenv') + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..1dd5126 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'chefspec' +require 'chefspec/berkshelf'