Skip to content

Commit

Permalink
Merge pull request dev-sec#23 from ehaselwanter/rubocop-updates
Browse files Browse the repository at this point in the history
update rubocop, add default rake task. fix errors with default task
  • Loading branch information
arlimus committed Jun 23, 2014
2 parents e66cbf3 + 0ae7e85 commit a4552a6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
@@ -0,0 +1,5 @@
rvm:
- 1.9.3
- 2.0.0
language: ruby
bundler_args: --without development integration openstack
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -6,7 +6,7 @@ gem 'chefspec', '~> 3.4'
gem 'foodcritic', '~> 3.0'
gem 'thor-foodcritic'
gem 'rake'
gem 'rubocop', '~> 0.18.1'
gem 'rubocop', '~> 0.23'

group :development do
gem 'guard'
Expand Down
38 changes: 20 additions & 18 deletions Rakefile
@@ -1,42 +1,44 @@
#!/usr/bin/env rake
# encoding: utf-8

require 'foodcritic'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

# General tasks

# Rubocop before rspec so we don't lint vendored cookbooks
desc "Run all tests except Kitchen (default task)"
task :integration => %w{rubocop foodcritic spec}
task :default => :unit
desc 'Run all tests except Kitchen (default task)'
task integration: %w(rubocop foodcritic spec)
task default: [:lint, :spec]

# Lint the cookbook
desc "Run linters"
task :lint => [ :rubocop, :foodcritic ]
desc 'Run linters'
task lint: [:rubocop, :foodcritic]

# Lint the cookbook
desc "Run all linters: rubocop and foodcritic"
task :run_all_linters => [ :rubocop, :foodcritic ]
desc 'Run all linters: rubocop and foodcritic'
task run_all_linters: [:rubocop, :foodcritic]

# Run the whole shebang
desc "Run all tests"
task :test => [ :lint, :integration ]
desc 'Run all tests'
task test: [:lint, :integration]

# RSpec
desc 'Run chefspec tests'
task :spec do
puts "Running Chefspec tests"
puts 'Running Chefspec tests'
RSpec::Core::RakeTask.new(:spec)
end

# Foodcritic
desc 'Run foodcritic lint checks'
task :foodcritic do
if Gem::Version.new('1.9.2') <= Gem::Version.new(RUBY_VERSION.dup)
puts "Running Foodcritic tests..."
puts 'Running Foodcritic tests...'
FoodCritic::Rake::LintTask.new do |t|
t.options = { :fail_tags => ['any'] }
puts "done."
t.options = { fail_tags: ['any'] }
puts 'done.'
end
else
puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
Expand All @@ -46,16 +48,16 @@ end
# Rubocop
desc 'Run Rubocop lint checks'
task :rubocop do
Rubocop::RakeTask.new
RuboCop::RakeTask.new
end

begin
require 'kitchen/rake_tasks'
Kitchen::RakeTasks.new

desc "Alias for kitchen:all"
task :acceptance => "kitchen:all"
desc 'Alias for kitchen:all'
task acceptance: 'kitchen:all'

rescue LoadError
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
end
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,4 @@
# encoding: utf-8

require 'chefspec'
require 'chefspec/berkshelf'

0 comments on commit a4552a6

Please sign in to comment.