From ae8d37b81dcb33d91024a36b08f28c818dc0eb63 Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Mon, 16 Jun 2014 16:20:21 +0200 Subject: [PATCH] add lint rake task with robocop and fix issues --- Gemfile | 1 + Rakefile | 12 ++++++++++++ default/serverspec/spec_helper.rb | 2 ++ default/serverspec/sysctl_spec.rb | 2 ++ modules_disabled/serverspec/modules_spec.rb | 2 ++ modules_disabled/serverspec/spec_helper.rb | 2 ++ modules_disabled/serverspec/sysctl_spec.rb | 2 ++ 7 files changed, 23 insertions(+) diff --git a/Gemfile b/Gemfile index 50f7734..09e4f60 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,4 @@ source 'https://rubygems.org' gem 'rake' gem 'serverspec' +gem 'rubocop', '~> 0.18.1' \ No newline at end of file diff --git a/Rakefile b/Rakefile index b4d1cf3..c5d2a1f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,18 @@ require 'rake' require 'rspec/core/rake_task' +require 'rubocop/rake_task' +# Rubocop +desc 'Run Rubocop lint checks' +task :rubocop do + Rubocop::RakeTask.new +end + +# Lint the cookbook +desc "Run linters" +task :lint => [ :rubocop ] + +# Serverspec tests suites = Dir.glob('*').select{|entry| File.directory?(entry) } class ServerspecTask < RSpec::Core::RakeTask diff --git a/default/serverspec/spec_helper.rb b/default/serverspec/spec_helper.rb index cbfbfe9..cd26eac 100644 --- a/default/serverspec/spec_helper.rb +++ b/default/serverspec/spec_helper.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + if ENV['STANDALONE_SPEC'] require 'serverspec' diff --git a/default/serverspec/sysctl_spec.rb b/default/serverspec/sysctl_spec.rb index 05ff436..6530412 100644 --- a/default/serverspec/sysctl_spec.rb +++ b/default/serverspec/sysctl_spec.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'spec_helper' RSpec.configure do |c| diff --git a/modules_disabled/serverspec/modules_spec.rb b/modules_disabled/serverspec/modules_spec.rb index fe45b3e..d43e982 100644 --- a/modules_disabled/serverspec/modules_spec.rb +++ b/modules_disabled/serverspec/modules_spec.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'spec_helper' describe 'preloaded modules' do diff --git a/modules_disabled/serverspec/spec_helper.rb b/modules_disabled/serverspec/spec_helper.rb index ba9b6d3..0ee5836 100644 --- a/modules_disabled/serverspec/spec_helper.rb +++ b/modules_disabled/serverspec/spec_helper.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'serverspec' require 'pathname' diff --git a/modules_disabled/serverspec/sysctl_spec.rb b/modules_disabled/serverspec/sysctl_spec.rb index 00d5e34..4df75de 100644 --- a/modules_disabled/serverspec/sysctl_spec.rb +++ b/modules_disabled/serverspec/sysctl_spec.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'spec_helper' describe 'System sysctl' do