-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from ehaselwanter/rubocop
update rubocop, add common linter task, fix rubocop issues
- Loading branch information
Showing
3 changed files
with
11 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ source 'https://rubygems.org' | |
|
||
gem 'rake' | ||
gem 'serverspec' | ||
gem 'rubocop', '~> 0.18.1' | ||
gem 'rubocop', '~> 0.23' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,44 @@ | ||
# encoding: utf-8 | ||
|
||
require 'rake' | ||
require 'rspec/core/rake_task' | ||
require 'rubocop/rake_task' | ||
|
||
# Rubocop | ||
desc 'Run Rubocop lint checks' | ||
task :rubocop do | ||
Rubocop::RakeTask.new | ||
RuboCop::RakeTask.new | ||
end | ||
|
||
# Lint the cookbook | ||
desc "Run linters" | ||
task :lint => [ :rubocop ] | ||
desc 'Run linters' | ||
task :run_all_linters => [:rubocop] # rubocop:disable Style/HashSyntax | ||
|
||
# Serverspec tests | ||
suites = Dir.glob('*').select{|entry| File.directory?(entry) } | ||
suites = Dir.glob('*').select { |entry| File.directory?(entry) } | ||
|
||
class ServerspecTask < RSpec::Core::RakeTask | ||
|
||
attr_accessor :target | ||
|
||
def spec_command | ||
|
||
if target.nil? | ||
puts "specify either env TARGET_HOST or target_host=" | ||
if target.nil? | ||
puts 'specify either env TARGET_HOST or target_host=' | ||
exit 1 | ||
end | ||
|
||
cmd = super | ||
"env TARGET_HOST=#{target} STANDALONE_SPEC=true #{cmd} --format documentation --no-profile" | ||
end | ||
|
||
end | ||
|
||
namespace :serverspec do | ||
suites.each do |suite| | ||
desc "Run serverspec suite #{suite}" | ||
ServerspecTask.new(suite.to_sym) do |t| | ||
t.rspec_opts = "--no-color --format html --out report.html" if ENV['format'] == 'html' | ||
t.rspec_opts = '--no-color --format html --out report.html' if ENV['format'] == 'html' | ||
t.target = ENV['TARGET_HOST'] || ENV['target_host'] | ||
t.ruby_opts = "-I #{suite}/serverspec" | ||
t.pattern = "#{suite}/serverspec/*_spec.rb" | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters