From 4892ffb82cd60dc4ca5f70891a38346041726092 Mon Sep 17 00:00:00 2001 From: Andy White Date: Thu, 25 Jul 2024 11:17:38 +1000 Subject: [PATCH] More rubocop cleanup, and move dev dependencies from the gemspec to the Gemfile --- .rubocop.yml | 5 ++--- Gemfile | 9 +++++++++ bmt.gemspec | 6 ------ lib/bmt.rb | 4 ++-- spec/bmt/step_spec.rb | 4 ++-- spec/bmt_spec.rb | 8 ++++---- spec/spec_helper.rb | 2 +- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4f5988a..74860c7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,12 +8,11 @@ Style/Documentation: Style/FrozenStringLiteralComment: Enabled: false -Metrics/LineLength: +Layout/LineLength: Max: 120 - IgnoreCopDirectives: true Metrics/BlockLength: - ExcludedMethods: + AllowedMethods: - configure - context - define diff --git a/Gemfile b/Gemfile index b73a005..94db4f2 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,12 @@ source 'https://rubygems.org' # Specify your gem's dependencies in bmt-ruby.gemspec gemspec + +group :development do + gem 'bundler', require: false + gem 'pry', require: false + gem 'rake', require: false + gem 'rspec', require: false + gem 'rubocop', require: false + gem 'rubocop-performance', require: false +end diff --git a/bmt.gemspec b/bmt.gemspec index edac891..b33a90e 100644 --- a/bmt.gemspec +++ b/bmt.gemspec @@ -16,12 +16,6 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.required_ruby_version = '>= 3.1' - spec.add_development_dependency 'bundler', '~> 2.1' - spec.add_development_dependency 'pry', '~> 0.11' - spec.add_development_dependency 'rake', '~> 12.3' - spec.add_development_dependency 'rspec', '~> 3.6' - spec.add_development_dependency 'rubocop', '1.65' - spec.metadata = { 'homepage_uri' => 'https://github.com/bugcrowd/bmt-ruby', 'changelog_uri' => 'https://github.com/bugcrowd/bmt-ruby/blob/main/CHANGELOG.md', diff --git a/lib/bmt.rb b/lib/bmt.rb index 00d9183..6b69451 100644 --- a/lib/bmt.rb +++ b/lib/bmt.rb @@ -43,7 +43,7 @@ def methodology_keys(version: current_version) DATA_DIR.join(version, 'methodologies').entries .map(&:basename) .map(&:to_s) - .select { |dirname| dirname =~ /json/ } + .grep(/json/) .map { |filepath| File.basename(filepath, File.extname(filepath)) } end @@ -67,6 +67,6 @@ def json_dir_names DATA_DIR.entries .map(&:basename) .map(&:to_s) - .select { |dirname| dirname =~ /^[0-9]+\.[0-9]/ }.sort + .grep(/^[0-9]+\.[0-9]/).sort end end diff --git a/spec/bmt/step_spec.rb b/spec/bmt/step_spec.rb index c147a7e..71f96d6 100644 --- a/spec/bmt/step_spec.rb +++ b/spec/bmt/step_spec.rb @@ -48,8 +48,6 @@ end context 'with an executive_summary step type' do - let(:attributes) { methodology_json.dig('content', 'steps', 2) } - subject do described_class.new( methodology:, @@ -57,6 +55,8 @@ ) end + let(:attributes) { methodology_json.dig('content', 'steps', 2) } + it 'returns the correct type' do expect(subject.type).to eq 'executive_summary' end diff --git a/spec/bmt_spec.rb b/spec/bmt_spec.rb index 9dde979..bc14f6b 100644 --- a/spec/bmt_spec.rb +++ b/spec/bmt_spec.rb @@ -5,7 +5,7 @@ subject { described_class.versions } it 'return all of the versions in the filesystem in reverse semver order' do - is_expected.to eq(['2.1', '1.0']) + expect(subject).to eq(['2.1', '1.0']) end end @@ -13,7 +13,7 @@ subject { described_class.current_version } it 'return the most recent version number for the vrt' do - is_expected.to eq('2.1') + expect(subject).to eq('2.1') end end @@ -22,7 +22,7 @@ subject { described_class.methodology_keys } it 'returns methodologies for the latest version' do - is_expected.to match_array(%w[website-testing outback-animal-testing]) + expect(subject).to match_array(%w[website-testing outback-animal-testing]) end end @@ -30,7 +30,7 @@ subject { described_class.methodology_keys(version: '1.0') } it 'returns methodologies for the specified version' do - is_expected.to match_array(['website-testing']) + expect(subject).to match_array(['website-testing']) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ab7bee0..aaeb1ad 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,7 +6,7 @@ c.syntax = :expect end - config.before(:each) do + config.before do # The following adds a new, test-only BMT versions stub_const('BMT::DATA_DIR', Pathname.new('spec/sample')) end