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

Skip to content

Commit 5921be4

Browse files
committed
Added a Travis config. Added matchers for chefspec. Added a few chefspec tests for python::default.
1 parent dd65106 commit 5921be4

File tree

6 files changed

+64
-12
lines changed

6 files changed

+64
-12
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rvm:
2+
- 1.9.3
3+
- 2.0.0
4+
before_script:
5+
- bundle exec berks install
6+
script:
7+
- bundle exec foodcritic -f any .

Gemfile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
source 'https://rubygems.org'
22

3-
gem 'rake'
4-
gem 'rspec'
53
gem 'foodcritic'
6-
gem 'berkshelf'
7-
gem 'thor-foodcritic'
8-
gem 'vagrant-wrapper'
9-
10-
group :integration do
11-
gem 'test-kitchen', :git => "git://github.com/opscode/test-kitchen.git"
12-
gem 'kitchen-vagrant', :git => "git://github.com/opscode/kitchen-vagrant.git"
13-
gem 'kitchen-ec2', :git => "git://github.com/opscode/kitchen-ec2.git"
14-
gem 'kitchen-lxc', :git => "https://github.com/portertech/kitchen-lxc.git", :tag => 'v0.0.1.beta2'
15-
end
4+
gem 'berkshelf', '~> 2.0'
5+
gem 'chefspec', '~> 3.0'

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rspec/core/rake_task'
2+
3+
RSpec::Core::RakeTask.new(:spec)
4+
5+
task :default => :spec

libraries/matchers.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
if defined?(ChefSpec)
2+
def install_python_pip(package_name)
3+
ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :install, package_name)
4+
end
5+
6+
def upgrade_python_pip(package_name)
7+
ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :upgrade, package_name)
8+
end
9+
10+
def remove_python_pip(package_name)
11+
ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :remove, package_name)
12+
end
13+
14+
def purge_python_pip(package_name)
15+
ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :purge, package_name)
16+
end
17+
18+
def create_python_virtualenv(virtualenv_name)
19+
ChefSpec::Matchers::ResourceMatcher.new(:python_virtualenv, :create, virtualenv_name)
20+
end
21+
22+
def delete_python_virtualenv(virtualenv_name)
23+
ChefSpec::Matchers::ResourceMatcher.new(:python_virtualenv, :delete, virtualenv_name)
24+
end
25+
end

spec/default_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'spec_helper'
2+
3+
describe 'python::default' do
4+
let :chef_run do
5+
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04').converge described_recipe
6+
end
7+
8+
before do
9+
stub_command("/usr/bin/python -c 'import setuptools'").and_return(true)
10+
end
11+
12+
it 'includes python::package by default' do
13+
expect(chef_run).to include_recipe('python::package')
14+
end
15+
16+
it 'includes python::pip' do
17+
expect(chef_run).to include_recipe('python::pip')
18+
end
19+
20+
it 'includes python::virtualenv' do
21+
expect(chef_run).to include_recipe('python::virtualenv')
22+
end
23+
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'chefspec'
2+
require 'chefspec/berkshelf'

0 commit comments

Comments
 (0)