diff --git a/.travis.yml b/.travis.yml index 9f19b65e..7bbe907f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,3 @@ bundler_args: --without=development gemfile: - gemfiles/Gemfile.chef-11 - gemfiles/Gemfile.chef-10 - -before_script: - - rake berks diff --git a/Gemfile b/Gemfile index bd66af2e..76cc5104 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,7 @@ # -*- encoding: utf-8 -*- -source "http://rubygems.org" - -chef_version = ENV.key?('CHEF_VERSION') ? "= #{ENV['CHEF_VERSION']}" : ['~> 10'] +source "https://rubygems.org" gem "rake", "~> 10" -gem "chef", chef_version group :development do gem "travis-lint", "~> 1.4" @@ -17,7 +14,5 @@ group :test do gem "tailor", "~> 1.1" # Ruby style gem "foodcritic", "~> 1.6" # Lint testing gem "berkshelf", "~> 1.0" - gem "chefspec", "~> 0.7" - gem "fauxhai", "~> 0.0" - gem "moneta", "< 0.7.0" # See http://tickets.opscode.com/browse/CHEF-3721 + gem "chefspec", "~> 1.0.0.rc1" # See https://github.com/acrmp/chefspec/issues/93 end diff --git a/Rakefile b/Rakefile index e93a1387..733b3ed8 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,12 @@ require 'foodcritic' # https://github.com/turboladen/tailor require 'tailor/rake_task' -task :default => [:tailor, :foodcritic, :knife, :chefspec] +task :default => [ + :tailor, + :foodcritic, + :berks, + :chefspec +] Tailor::RakeTask.new do |task| task.file_set('attributes/**/*.rb', "attributes") do |style| @@ -30,19 +35,18 @@ FoodCritic::Rake::LintTask.new do |t| end # http://berkshelf.com/ -desc "Install Berkshelf shims" +desc "Check out cookbooks from Berkshelf to local path" task :berks do - sh %{berks install --path ./cookbooks} + sh %{bundle exec berks install --path ./cookbooks} end -# http://wiki.opscode.com/display/chef/Managing+Cookbooks+With+Knife#ManagingCookbooksWithKnife-test -desc "Test cookbooks via knife" +desc "Test Datadog cookbook via knife" task :knife do - sh %{knife cookbook test -o cookbooks -a} + sh %{bundle exec knife cookbook test datadog -o cookbooks} end # https://github.com/acrmp/chefspec desc "Run ChefSpec Unit Tests" task :chefspec do - sh %{rspec --color cookbooks/datadog/spec/} + sh %{bundle exec rspec --color cookbooks/datadog/spec/} end diff --git a/gemfiles/Gemfile.chef-10 b/gemfiles/Gemfile.chef-10 index 88be3462..f7321335 100644 --- a/gemfiles/Gemfile.chef-10 +++ b/gemfiles/Gemfile.chef-10 @@ -2,4 +2,4 @@ source 'https://rubygems.org' gem 'chef', '~> 10.0' -gemspec :path => '..' +eval(File.read(File.join(File.dirname(__FILE__), '..' ,'Gemfile'))) diff --git a/gemfiles/Gemfile.chef-11 b/gemfiles/Gemfile.chef-11 index 8930456e..f69afcea 100644 --- a/gemfiles/Gemfile.chef-11 +++ b/gemfiles/Gemfile.chef-11 @@ -2,4 +2,4 @@ source 'https://rubygems.org' gem 'chef', '~> 11.2' -gemspec :path => '..' +eval(File.read(File.join(File.dirname(__FILE__), '..' ,'Gemfile'))) diff --git a/spec/dd-agent_spec.rb b/spec/dd-agent_spec.rb index 2b57e372..b212bfd2 100644 --- a/spec/dd-agent_spec.rb +++ b/spec/dd-agent_spec.rb @@ -5,13 +5,18 @@ # This recipe needs to have an api_key, otherwise `raise` is called. # It also depends on specific platofrm versions for software install context 'when using a debian-family distro' do - before do - Fauxhai.mock(:platform => 'ubuntu', :version => '12.04') do |node| - node['datadog'] = { :api_key => "somethingnotnil" } + + let(:chef_run) do + ChefSpec::ChefRunner.new(platform: 'ubuntu', version: '12.04') do |node| + node.set['datadog'] = { + 'api_key' => "somethingnotnil" + } end end - let (:chef_run) { ChefSpec::ChefRunner.new.converge 'datadog::dd-agent' } + before do + chef_run.converge 'datadog::dd-agent' + end it 'sets up an apt repository' do pending "step into apt" @@ -35,13 +40,18 @@ end context 'when using a redhat-family distro above 6.x' do - before do - Fauxhai.mock(platform: 'centos', version: '6.3') do |node| - node['datadog'] = { :api_key => "somethingnotnil" } + + let(:chef_run) do + ChefSpec::ChefRunner.new(platform: 'centos', version: '6.3') do |node| + node.set['datadog'] = { + 'api_key' => "somethingnotnil" + } end end - let (:chef_run) { ChefSpec::ChefRunner.new.converge 'datadog::dd-agent' } + before do + chef_run.converge 'datadog::dd-agent' + end it 'sets up the EPEL repository' do pending "step intp yum::epel?" diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 9ba70ef4..8ee2dcbb 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -1,9 +1,14 @@ require 'spec_helper' describe 'datadog::default' do - let (:chef_run) { ChefSpec::ChefRunner.new.converge 'datadog::default' } - it 'should do nothing' do + context 'when converging this recipe' do + + let(:chef_run) { ChefSpec::ChefRunner.new.converge 'datadog::default' } + + it 'should do nothing' do + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1f25f7b1..468d080e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,2 +1 @@ require 'chefspec' -require 'fauxhai'