Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

Add initial support for chefspec. #66

Merged
merged 3 commits into from
Dec 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
before_script:
- bundle exec berks install
- bundle exec foodcritic -f any .
14 changes: 2 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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'
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
25 changes: 25 additions & 0 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'chefspec'
require 'chefspec/berkshelf'