From 66aedce1c3ad544abe6c5647ea38b17b10e7d187 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Tue, 20 Sep 2016 12:37:03 +0200 Subject: [PATCH] Fix several Rubocop issues --- Gemfile | 34 ++++++++++++------------ Rakefile | 10 +++---- spec/acceptance/class_spec.rb | 20 ++++++-------- spec/classes/config_template_spec.rb | 25 +++++++++--------- spec/classes/default_influxdb_spec.rb | 6 ++--- spec/classes/influxdb_config_spec.rb | 38 +++++++++++++-------------- spec/classes/init_spec.rb | 17 ++++++------ spec/classes/params_spec.rb | 14 +++++----- spec/spec_helper.rb | 2 +- spec/spec_helper_acceptance.rb | 11 ++++---- 10 files changed, 84 insertions(+), 93 deletions(-) diff --git a/Gemfile b/Gemfile index f01b01b..1d44380 100644 --- a/Gemfile +++ b/Gemfile @@ -1,34 +1,34 @@ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :development, :test do - gem 'rake', :require => false - gem 'rspec','< 3.2.0', :require => false - gem 'rspec-puppet','~> 2.2', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', :require => false - gem 'simplecov', :require => false - gem 'puppet_facts', :require => false - gem 'json_pure','~> 1.8', :require => false - gem 'json', :require => false - gem 'metadata-json-lint', :require => false + gem 'rake', require: false + gem 'rspec', '< 3.2.0', require: false + gem 'rspec-puppet', '~> 2.2', require: false + gem 'puppetlabs_spec_helper', require: false + gem 'puppet-lint', require: false + gem 'simplecov', require: false + gem 'puppet_facts', require: false + gem 'json_pure', '~> 1.8', require: false + gem 'json', require: false + gem 'metadata-json-lint', require: false gem 'rspec-puppet-facts', '~> 0.10' end group :system_tests do - gem 'beaker-rspec', :require => false - gem 'serverspec', :require => false + gem 'beaker-rspec', require: false + gem 'serverspec', require: false end if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false + gem 'facter', facterversion, require: false else - gem 'facter', :require => false + gem 'facter', require: false end if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false + gem 'puppet', puppetversion, require: false else - gem 'puppet', :require => false + gem 'puppet', require: false end # vim:ft=ruby diff --git a/Rakefile b/Rakefile index 2711bb0..9a3e31c 100644 --- a/Rakefile +++ b/Rakefile @@ -2,13 +2,13 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.send('relative') -PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.send('disable_80chars') PuppetLint.configuration.send('disable_class_parameter_defaults') PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" +PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{check}:%{KIND}:%{message}' PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.ignore_paths = ["pkg/**/*", "vendor/**/*", "spec/**/*"] +PuppetLint.configuration.ignore_paths = ['pkg/**/*', 'vendor/**/*', 'spec/**/*'] -desc "Run syntax, lint, and beaker/rspec tests." -task :test => [:validate, :lint, :spec] +desc 'Run syntax, lint, and beaker/rspec tests.' +task test: [:validate, :lint, :spec] diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index b487fb6..50b0468 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,18 +1,16 @@ require 'spec_helper_acceptance' -describe 'influxdb class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - +describe 'influxdb class', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'default parameters' do - pp = <<-EOS class { 'influxdb::server': } EOS it 'should work with no errors' do # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, catch_failures: true) # wait because influxdb takes few seconds to start - shell("/bin/sleep 10") + shell('/bin/sleep 10') end describe package('influxdb') do @@ -23,8 +21,8 @@ class { 'influxdb::server': } it { should be_listening } end - describe process("influxdb") do - its(:user) { should eq "influxdb" } + describe process('influxdb') do + its(:user) { should eq 'influxdb' } end describe port('8089') do @@ -33,19 +31,17 @@ class { 'influxdb::server': } end context 'change some ports' do - it 'should change API port to 8089' do pp = <<-EOS class { 'influxdb::server': api_port => 8089} EOS - apply_manifest(pp, :catch_failures => true) - shell("/bin/sleep 10") + apply_manifest(pp, catch_failures: true) + shell('/bin/sleep 10') end describe port('8089') do it { should be_listening } end end - -end \ No newline at end of file +end diff --git a/spec/classes/config_template_spec.rb b/spec/classes/config_template_spec.rb index 1c4b72e..92f3e0d 100644 --- a/spec/classes/config_template_spec.rb +++ b/spec/classes/config_template_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' -describe 'influxdb::server', :type => :class do - +describe 'influxdb::server', type: :class do default = { 'meta_bind_address' => ':8088', 'meta_http_bind_address' => ':8091', @@ -11,7 +10,7 @@ 'leader_lease_timeout' => '500ms', 'commit_timeout' => '50ms', 'data_dir' => '/var/opt/influxdb/data', - 'max_wal_size' => 104857600, + 'max_wal_size' => 104_857_600, 'wal_flush_interval' => '10m', 'wal_partition_flush_delay' => '2s', 'shard_writer_timeout' => '5s', @@ -36,7 +35,7 @@ 'continuous_queries_enabled' => true, 'hinted_handoff_enabled' => true, 'hinted_handoff_dir' => '/var/opt/influxdb/hh', - 'hinted_handoff_max_size' => 1073741824, + 'hinted_handoff_max_size' => 1_073_741_824, 'hinted_handoff_max_age' => '168h', 'hinted_handoff_retry_rate_limit' => 0, 'hinted_handoff_retry_interval' => '1s', @@ -62,22 +61,22 @@ case facts[:osfamily] when 'Debian' - let (:params) {{ - :retention_check_interval => '20m', - :collectd_options => { - 'enabled' => true, - 'batch-size' => 5000, + let(:params) do + { + retention_check_interval: '20m', + collectd_options: { + 'enabled' => true, + 'batch-size' => 5000 + } } - }} + end it { is_expected.to contain_file('/etc/influxdb/influxdb.conf') } it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/bind-address = ":8088"/) } it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/check-interval = "20m"/) } - it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/wal-dir = "\/var\/lib\/influxdb\/wal"/) } + it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(%r{wal-dir = "/var/lib/influxdb/wal"}) } it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/batch-size = 5000/) } end - end end - end diff --git a/spec/classes/default_influxdb_spec.rb b/spec/classes/default_influxdb_spec.rb index 0ff4b1e..ea87007 100644 --- a/spec/classes/default_influxdb_spec.rb +++ b/spec/classes/default_influxdb_spec.rb @@ -1,15 +1,15 @@ require 'spec_helper' -describe 'influxdb::server', :type => :class do +describe 'influxdb::server', type: :class do on_supported_os.each do |os, facts| context "on #{os}" do - let (:params) {{ :influxd_opts => 'OPTIONS' }} + let(:params) { { influxd_opts: 'OPTIONS' } } let(:facts) do facts end it { is_expected.to contain_file('/etc/default/influxdb') } it { is_expected.to contain_file('/etc/default/influxdb').with_content(/INFLUXD_OPTS="OPTIONS"/) } - it { is_expected.to contain_file('/etc/default/influxdb').with_content(/STDERR=\/var\/log\/influxdb\/influxd\.log/) } + it { is_expected.to contain_file('/etc/default/influxdb').with_content(%r{STDERR=/var/log/influxdb/influxd.log}) } end end end diff --git a/spec/classes/influxdb_config_spec.rb b/spec/classes/influxdb_config_spec.rb index b58b84e..609e67f 100644 --- a/spec/classes/influxdb_config_spec.rb +++ b/spec/classes/influxdb_config_spec.rb @@ -1,31 +1,29 @@ require 'spec_helper' -describe 'influxdb::server', :type => :class do - +describe 'influxdb::server', type: :class do on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do facts - end - it { should contain_class('influxdb::server::install') } - it { should contain_class('influxdb::repo') } - it { should contain_class('influxdb::server::config') } - it { should contain_class('influxdb::server::service') } - case facts[:osfamily] - when 'Debian' - it { should contain_class('influxdb::repo::apt') } - context "with $manage_repos => false" do - let (:params) {{ :manage_repos => false }} - it { should_not contain_class('influxdb::repo::apt') } end - when 'RedHat' - it { should contain_class('influxdb::repo::yum') } - context "with $manage_repos => false" do - let (:params) {{ :manage_repos => false }} - it { should_not contain_class('influxdb::repo::yum') } + it { should contain_class('influxdb::server::install') } + it { should contain_class('influxdb::repo') } + it { should contain_class('influxdb::server::config') } + it { should contain_class('influxdb::server::service') } + case facts[:osfamily] + when 'Debian' + it { should contain_class('influxdb::repo::apt') } + context 'with $manage_repos => false' do + let(:params) { { manage_repos: false } } + it { should_not contain_class('influxdb::repo::apt') } + end + when 'RedHat' + it { should contain_class('influxdb::repo::yum') } + context 'with $manage_repos => false' do + let(:params) { { manage_repos: false } } + it { should_not contain_class('influxdb::repo::yum') } + end end end - end end - end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 7091912..c4267f3 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,14 +1,13 @@ require 'spec_helper' describe 'influxdb' do - - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts end - it { should contain_class('influxdb') } - it { is_expected.to compile.with_all_deps } - end - end + it { should contain_class('influxdb') } + it { is_expected.to compile.with_all_deps } + end + end end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 2e5893a..0c1d1e6 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -describe 'influxdb::params', :type => :class do +describe 'influxdb::params', type: :class do let :facts do { - :osfamily => 'Debian', - :operatingsystem => 'Ubuntu', - :operatingsystemrelease => '12.04', - :lsbdistcodename => 'precice', + osfamily: 'Debian', + operatingsystem: 'Ubuntu', + operatingsystemrelease: '12.04', + lsbdistcodename: 'precice' } end - it { is_expected.to contain_class("influxdb::params") } -end \ No newline at end of file + it { is_expected.to contain_class('influxdb::params') } +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6e4e08b..1ffdf17 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,3 @@ require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' -include RspecPuppetFacts \ No newline at end of file +include RspecPuppetFacts diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 20fdcc2..cfde567 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,12 +1,11 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' - unless ENV['RS_PROVISION'] == 'no' # This will install the latest available package on el and deb based # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { :default_action => 'gem_install' } - if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end + foss_opts = { default_action: 'gem_install' } + default.is_pe? ? install_pe : install_puppet(foss_opts) hosts.each do |host| if host['platform'] =~ /debian/ @@ -17,7 +16,7 @@ end end -UNSUPPORTED_PLATFORMS = ['Suse','windows','AIX','Solaris'] +UNSUPPORTED_PLATFORMS = %w(Suse windows AIX Solaris).freeze RSpec.configure do |c| # Project root @@ -31,8 +30,8 @@ # Install module and dependencies hosts.each do |host| shell("/bin/touch #{default['puppetpath']}/hiera.yaml") - on host, puppet('module install puppetlabs-stdlib --version 3.2.0'), { :acceptable_exit_codes => [0,1] } - copy_module_to(host, :source => proj_root, :module_name => 'influxdb') + on host, puppet('module install puppetlabs-stdlib --version 3.2.0'), acceptable_exit_codes: [0, 1] + copy_module_to(host, source: proj_root, module_name: 'influxdb') end end end