Skip to content

Commit

Permalink
Use stable ChefDK to run tests
Browse files Browse the repository at this point in the history
Instead of trying to maintain a dependency chain, use the current
released version of ChefDK to execute tests.

This is not a replacement for full integration testing.

Also remove the project's stale Gemfile, possibly to be replaced at a
later date with a subset of gems used for testing only.

Includes an update to rubocop's config and some style updates in tests.

Updates cookbook metadata in response to foodcritic warnings about
`suggests` and `*_url` fields.
  • Loading branch information
miketheman committed Mar 12, 2016
1 parent cdc31cd commit d0c7c2c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ AllCops:
Metrics/LineLength:
Max: 160

Style/SingleSpaceBeforeFirstArg:
Style/SpaceBeforeFirstArg:
Enabled: false
29 changes: 22 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
language: ruby
cache: bundler
sudo: false

rvm:
- 2.0
- 2.1
- 2.2
addons:
apt:
sources:
- chef-stable-precise
packages:
- chefdk

bundler_args: --without development kitchen_docker kitchen_vagrant
# Don't `bundle install`
install: echo "skip bundle install"

# Ensure we make ChefDK's Ruby the default
before_script:
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
# update foodcritic version to prevent false-postiive detection
# https://github.com/acrmp/foodcritic/pull/423
# TODO: Remove when 6.0.1 is included in ChefDK stable
- chef gem install foodcritic -v '6.0.1'
- chef gem install coveralls -v '~> 0.8.13'

script:
- chef --version
- gem query -d chefspec rubocop foodcritic rake
- rake

notifications:
webhooks:
Expand Down
41 changes: 0 additions & 41 deletions Gemfile

This file was deleted.

4 changes: 2 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
description 'Installs and configures nginx'
version '2.99.0'

suggests 'apt', '~> 2.6.1'
suggests 'yum', '~> 3.5.2'
issues_url 'https://github.com/miketheman/nginx/issues'
source_url 'https://github.com/miketheman/nginx'
3 changes: 1 addition & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

require 'chefspec'
require 'chefspec/berkshelf'
ChefSpec::Coverage.start!

RSpec.configure do |config|
# Uncomment to prevent any WARN messages during testing
Expand All @@ -16,5 +17,3 @@

# Load all shared example groups
Dir[File.join(File.dirname(__FILE__), 'shared_examples', '**.rb')].sort.each { |f| require f }

ChefSpec::Coverage.start!
10 changes: 5 additions & 5 deletions test/integration/example/serverspec/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

describe 'example service' do
it 'installs nginx package' do
expect(package 'nginx').to be_installed
expect(package('nginx')).to be_installed
end

it 'stops the default nginx service' do
expect(service 'nginx').to_not be_running
expect(service 'nginx').to_not be_enabled
expect(service('nginx')).to_not be_running
expect(service('nginx')).to_not be_enabled
end

it 'creates an nginx-example config file' do
Expand All @@ -20,8 +20,8 @@
end

it 'starts & enables the example nginx service' do
expect(service 'nginx-example').to be_running
expect(service 'nginx-example').to be_enabled
expect(service('nginx-example')).to be_running
expect(service('nginx-example')).to be_enabled
end
end

Expand Down
10 changes: 5 additions & 5 deletions test/integration/service_multi/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

describe 'multi service' do
it 'installs nginx package' do
expect(package 'nginx').to be_installed
expect(package('nginx')).to be_installed
end

it 'starts & enables nginx multi1 service' do
expect(service 'nginx-multi1').to be_running
expect(service 'nginx-multi1').to be_enabled
expect(service('nginx-multi1')).to be_running
expect(service('nginx-multi1')).to be_enabled
end

it 'starts & enables nginx multi2 service' do
expect(service 'nginx-multi2').to be_running
expect(service 'nginx-multi2').to be_enabled
expect(service('nginx-multi2')).to be_running
expect(service('nginx-multi2')).to be_enabled
end
end
6 changes: 3 additions & 3 deletions test/integration/service_single/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

describe 'single service' do
it 'installs nginx package' do
expect(package 'nginx').to be_installed
expect(package('nginx')).to be_installed
end

it 'starts & enables nginx service' do
expect(service 'nginx-single').to be_running
expect(service 'nginx-single').to be_enabled
expect(service('nginx-single')).to be_running
expect(service('nginx-single')).to be_enabled
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
describe 'single service, upstream repo' do
it 'creates the apt repo file' do
listfile = '/etc/apt/sources.list.d/nginx.org.list'
expect(file listfile).to be_a_file
expect((file listfile).content).to match(%r{http://nginx.org/packages/})
expect(file(listfile)).to be_a_file
expect(file(listfile).content).to match(%r{http://nginx.org/packages/})
end

it 'installs nginx package' do
expect(package 'nginx').to be_installed
expect((command 'grep -q nginx.org /var/lib/dpkg/status').exit_status).to eq 0
expect(package('nginx')).to be_installed
expect(command('grep -q nginx.org /var/lib/dpkg/status').exit_status).to eq 0
end

it 'starts & enables nginx service' do
expect(service 'nginx-single').to be_running
expect(service 'nginx-single').to be_enabled
expect(service('nginx-single')).to be_running
expect(service('nginx-single')).to be_enabled
end
end

0 comments on commit d0c7c2c

Please sign in to comment.