From c4380ac17a50561351c5181651b61fb4d32798a3 Mon Sep 17 00:00:00 2001 From: Derek Tamsen Date: Tue, 2 Feb 2016 12:32:54 -0800 Subject: [PATCH 1/4] fix .which method nameerror, improve tests to look for specific errors, and move dev deps into gemfile --- Gemfile | 9 +++++++++ lib/lowered/expectations.rb | 2 +- lowered-expectations.gemspec | 7 ------- .../integration/lowered/expectations_integration_spec.rb | 2 +- spec/lowered/expectations_spec.rb | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index fa75df1..7051e25 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,12 @@ source 'https://rubygems.org' gemspec + +group :development, :test do + gem "bundler", "~> 1.7" + gem "rake", "~> 10.4" + gem "rspec", "~> 3.0" + gem "rspec-mocks", "~> 3.0" + gem "rubocop", "~> 0.24" + gem "rubygems-tasks", "~> 0.2" +end diff --git a/lib/lowered/expectations.rb b/lib/lowered/expectations.rb index 6b2af7f..e071928 100644 --- a/lib/lowered/expectations.rb +++ b/lib/lowered/expectations.rb @@ -33,7 +33,7 @@ def self.which(cmd) return exe if File.executable?(exe) && !File.directory?(exe) end end - raise MissingExecutableError.new("#{executable} not found in #{ENV['PATH']}") + raise MissingExecutableError.new("#{cmd} not found in #{ENV['PATH']}") end def self.verify_version(version, pattern) diff --git a/lowered-expectations.gemspec b/lowered-expectations.gemspec index 2096812..13458ff 100644 --- a/lowered-expectations.gemspec +++ b/lowered-expectations.gemspec @@ -26,11 +26,4 @@ END spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - - spec.add_development_dependency "bundler", "~> 1.7" - spec.add_development_dependency "rake", "~> 10.4" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "rspec-mocks", "~> 3.0" - spec.add_development_dependency "rubocop", "~> 0.24" - spec.add_development_dependency "rubygems-tasks", "~> 0.2" end diff --git a/spec/integration/lowered/expectations_integration_spec.rb b/spec/integration/lowered/expectations_integration_spec.rb index 1de4623..54c3741 100644 --- a/spec/integration/lowered/expectations_integration_spec.rb +++ b/spec/integration/lowered/expectations_integration_spec.rb @@ -23,7 +23,7 @@ end it 'raises an error when the executable is not on the PATH' do - expect{LoweredExpectations.which 'sometoolthatdoesnotexist'}.to raise_error + expect{LoweredExpectations.which 'sometoolthatdoesnotexist'}.to raise_error(LoweredExpectations::MissingExecutableError) end end end diff --git a/spec/lowered/expectations_spec.rb b/spec/lowered/expectations_spec.rb index af3c0b8..6588a7c 100644 --- a/spec/lowered/expectations_spec.rb +++ b/spec/lowered/expectations_spec.rb @@ -48,7 +48,7 @@ end it 'raises an error when the executable is not on the PATH' do - expect{LoweredExpectations.which 'sometoolthatdoesnotexist'}.to raise_error + expect{LoweredExpectations.which 'sometoolthatdoesnotexist'}.to raise_error(LoweredExpectations::MissingExecutableError) end end From db32f1b0383960664aff1b9f65eff3160a53bbc5 Mon Sep 17 00:00:00 2001 From: Derek Tamsen Date: Tue, 2 Feb 2016 12:51:30 -0800 Subject: [PATCH 2/4] bump version to 1.0.1, bump rubocop version, fix rubocop issues --- .rubocop.yml | 9 --------- Gemfile | 2 +- lib/lowered/expectations.rb | 4 ++-- .../lowered/expectations_integration_spec.rb | 2 +- spec/lowered/expectations_spec.rb | 14 +++++++------- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 78c60ea..0f943f7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -108,11 +108,6 @@ SelfAssignment: SignalException: Enabled: false -# Offense count: 53 -# Cop supports --auto-correct. -SingleSpaceBeforeFirstArg: - Enabled: false - SpaceAroundOperators: Enabled: false @@ -304,10 +299,6 @@ Style/NumericLiterals: Metrics/ParameterLists: Enabled: false -Style/TrailingComma: - # EnforcedStyleForMultiline: comma - Enabled: false - Metrics/CyclomaticComplexity: Enabled: false diff --git a/Gemfile b/Gemfile index 7051e25..69bef0f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,6 @@ group :development, :test do gem "rake", "~> 10.4" gem "rspec", "~> 3.0" gem "rspec-mocks", "~> 3.0" - gem "rubocop", "~> 0.24" + gem "rubocop", "~> 0.36" gem "rubygems-tasks", "~> 0.2" end diff --git a/lib/lowered/expectations.rb b/lib/lowered/expectations.rb index e071928..cf7c16f 100644 --- a/lib/lowered/expectations.rb +++ b/lib/lowered/expectations.rb @@ -5,7 +5,7 @@ require 'pty' class LoweredExpectations - VERSION = '1.0.0' + VERSION = '1.0.1'.freeze class VersionPatternError < StandardError end @@ -54,7 +54,7 @@ def self.run!(*args, quiet: false) while !r.eof? c = r.getc stdout << c - $stdout.write "#{c}" + $stdout.write c.to_s end Process.wait(pid) end diff --git a/spec/integration/lowered/expectations_integration_spec.rb b/spec/integration/lowered/expectations_integration_spec.rb index 54c3741..97332ad 100644 --- a/spec/integration/lowered/expectations_integration_spec.rb +++ b/spec/integration/lowered/expectations_integration_spec.rb @@ -19,7 +19,7 @@ describe '.which' do it 'returns true when the executable is on the PATH' do - expect(LoweredExpectations.which tool).to be_truthy + expect(LoweredExpectations.which(tool)).to be_truthy end it 'raises an error when the executable is not on the PATH' do diff --git a/spec/lowered/expectations_spec.rb b/spec/lowered/expectations_spec.rb index 6588a7c..45405a5 100644 --- a/spec/lowered/expectations_spec.rb +++ b/spec/lowered/expectations_spec.rb @@ -44,7 +44,7 @@ describe '.which' do it 'returns true when the executable is on the PATH' do - expect(LoweredExpectations.which tool).to be_truthy + expect(LoweredExpectations.which(tool)).to be_truthy end it 'raises an error when the executable is not on the PATH' do @@ -54,12 +54,12 @@ describe '.verify_version' do it 'returns true when the version string matches the version pattern' do - expect(LoweredExpectations.verify_version version, '~> 0.1').to be_truthy - expect(LoweredExpectations.verify_version version, '~> 0').to be_truthy - expect(LoweredExpectations.verify_version version, '> 0.1.1').to be_truthy - expect(LoweredExpectations.verify_version version, '< 1').to be_truthy - expect(LoweredExpectations.verify_version version, '> 0').to be_truthy - expect(LoweredExpectations.verify_version version, "= #{version}").to be_truthy + expect(LoweredExpectations.verify_version(version, '~> 0.1')).to be_truthy + expect(LoweredExpectations.verify_version(version, '~> 0')).to be_truthy + expect(LoweredExpectations.verify_version(version, '> 0.1.1')).to be_truthy + expect(LoweredExpectations.verify_version(version, '< 1')).to be_truthy + expect(LoweredExpectations.verify_version(version, '> 0')).to be_truthy + expect(LoweredExpectations.verify_version(version, "= #{version}")).to be_truthy end it 'raise an error when the version string does not match the version pattern' do From 65ee83ba8ebe4e4c3b4036a98cf78855197d521f Mon Sep 17 00:00:00 2001 From: Derek Tamsen Date: Tue, 2 Feb 2016 12:59:13 -0800 Subject: [PATCH 3/4] set encoding to lowercase --- lib/lowered/expectations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lowered/expectations.rb b/lib/lowered/expectations.rb index cf7c16f..d93a8a7 100644 --- a/lib/lowered/expectations.rb +++ b/lib/lowered/expectations.rb @@ -1,4 +1,4 @@ -# Encoding: utf-8 +# encoding: utf-8 require 'rubygems/dependency' require 'open3' require 'shellwords' From 062465db47c2ff1cb0df87d1cf70742afd65564f Mon Sep 17 00:00:00 2001 From: Derek Tamsen Date: Tue, 2 Feb 2016 13:07:34 -0800 Subject: [PATCH 4/4] change encoding case back and disable frozenstringliteralcomments in rubocop --- .rubocop.yml | 3 +++ lib/lowered/expectations.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0f943f7..9712cc1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -209,6 +209,9 @@ Style/EmptyLines: Style/EmptyLinesAroundAccessModifier: Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false + Style/GuardClause: Enabled: false diff --git a/lib/lowered/expectations.rb b/lib/lowered/expectations.rb index d93a8a7..cf7c16f 100644 --- a/lib/lowered/expectations.rb +++ b/lib/lowered/expectations.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# Encoding: utf-8 require 'rubygems/dependency' require 'open3' require 'shellwords'