diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 46f16014..8db63a05 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v1 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7.2 + ruby-version: 3.3.0 - name: Run bundle install working-directory: ${{env.api-dir}} diff --git a/.rubocop.yml b/.rubocop.yml index 6f841e05..7e8db4ae 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.3.0 Style/Documentation: Enabled: false diff --git a/.ruby-version b/.ruby-version index 37c2961c..15a27998 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +3.3.0 diff --git a/bugcrowd_templates.gemspec b/bugcrowd_templates.gemspec index bdd1dec8..a9164fc9 100644 --- a/bugcrowd_templates.gemspec +++ b/bugcrowd_templates.gemspec @@ -17,13 +17,13 @@ Gem::Specification.new do |spec| spec.license = 'MIT' spec.files = Dir['lib/**/*.{rb,json}'] spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.5' + spec.required_ruby_version = '>= 3.0' - 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', '0.56.0' + spec.add_development_dependency 'bundler', '~> 2.5.5' + spec.add_development_dependency 'pry', '~> 0.14.2' + spec.add_development_dependency 'rake', '~> 13.0.6' + spec.add_development_dependency 'rspec', '~> 3.12' + spec.add_development_dependency 'rubocop', '1.52.1' spec.metadata = { 'homepage_uri' => 'https://github.com/bugcrowd/templates', diff --git a/lib/bugcrowd_templates.rb b/lib/bugcrowd_templates.rb index 428b1250..8bc6cd6c 100644 --- a/lib/bugcrowd_templates.rb +++ b/lib/bugcrowd_templates.rb @@ -32,12 +32,12 @@ def get( raise TypeError, 'Invalid template type' unless TEMPLATE_TYPES.value?(type) template_path = TemplatePath.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).template_file template_data(template_path) diff --git a/lib/bugcrowd_templates/template_path.rb b/lib/bugcrowd_templates/template_path.rb index 5fdbe0b3..0f1dbf02 100644 --- a/lib/bugcrowd_templates/template_path.rb +++ b/lib/bugcrowd_templates/template_path.rb @@ -6,7 +6,7 @@ class InputError < StandardError; end class TemplatePath attr_reader :type, :field, :category, :subcategory, :item, :file_name - # rubocop:disable Metrics/ParameterLists, Metrics/CyclomaticComplexity + # rubocop:disable Metrics/ParameterLists def initialize(type:, field:, category: '', subcategory: '', item: '', file_name: '') @type = type || '' @field = field || '' @@ -15,7 +15,7 @@ def initialize(type:, field:, category: '', subcategory: '', item: '', file_name @item = item || '' @file_name = file_name || '' end - # rubocop:enable Metrics/ParameterLists, Metrics/CyclomaticComplexity + # rubocop:enable Metrics/ParameterLists def template_file validate_input_attrs @@ -30,6 +30,7 @@ def template_file def find_template_file return item_file_path if item && File.exist?(item_file_path) return subcategory_file_path if subcategory && File.exist?(subcategory_file_path) + category_file_path end diff --git a/spec/bugcrowd_templates/template_path_spec.rb b/spec/bugcrowd_templates/template_path_spec.rb index 49b28256..c47b0128 100644 --- a/spec/bugcrowd_templates/template_path_spec.rb +++ b/spec/bugcrowd_templates/template_path_spec.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require 'spec_helper' @@ -6,18 +5,20 @@ describe BugcrowdTemplates::TemplatePath do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ) end let!(:directory) { BugcrowdTemplates.current_directory } let!(:file_name_with_extension) { [file_name, 'md'].join('.') } - let!(:mock_path) { Pathname.new(Gem::Specification.find_by_name('bugcrowd_templates').gem_dir).join('spec', 'fixture')} + let!(:mock_path) do + Pathname.new(Gem::Specification.find_by_name('bugcrowd_templates').gem_dir).join('spec', 'fixture') + end describe '#new' do context 'initialize with submission type' do @@ -28,8 +29,6 @@ let!(:item) { 'ocr_optical_character_recognition' } let!(:file_name) { 'template' } - - it 'initialize an item' do expect(subject).to be_a(described_class) expect(subject.type).to eq('submission') @@ -61,12 +60,12 @@ describe '#template_file' do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).template_file end @@ -115,12 +114,12 @@ describe '#find_template_file' do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).find_template_file end @@ -154,8 +153,6 @@ end end - - context 'when it has category params for submissions' do let!(:type) { 'submissions' } let!(:field) { 'description' } @@ -188,12 +185,12 @@ describe '#item_file_path' do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).item_file_path end @@ -229,12 +226,12 @@ describe '#subcategory_file_path' do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).subcategory_file_path end @@ -270,12 +267,12 @@ describe '#category_file_path' do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).category_file_path end @@ -311,12 +308,12 @@ describe '#valid?' do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).valid?(type) end @@ -350,12 +347,12 @@ describe '#validate_input_attrs' do subject do described_class.new( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ).validate_input_attrs end diff --git a/spec/bugcrowd_templates_spec.rb b/spec/bugcrowd_templates_spec.rb index 7920dd97..8c993e08 100644 --- a/spec/bugcrowd_templates_spec.rb +++ b/spec/bugcrowd_templates_spec.rb @@ -1,9 +1,6 @@ - require 'spec_helper' describe BugcrowdTemplates do - - describe '#VERSION' do subject { described_class::VERSION } @@ -31,12 +28,12 @@ describe '#get' do subject do described_class.get( - type: type, - field: field, - category: category, - subcategory: subcategory, - item: item, - file_name: file_name + type:, + field:, + category:, + subcategory:, + item:, + file_name: ) end @@ -46,7 +43,9 @@ let(:subcategory) { '' } let(:item) { '' } let(:file_name) { '' } - let!(:mock_path) {Pathname.new(Gem::Specification.find_by_name('bugcrowd_templates').gem_dir).join('spec').join('fixture')} + let!(:mock_path) do + Pathname.new(Gem::Specification.find_by_name('bugcrowd_templates').gem_dir).join('spec').join('fixture') + end context 'with correct params' do context 'with methodology type' do @@ -57,7 +56,6 @@ let!(:item) { '' } let!(:file_name) { 'information' } - it 'returns the bugcrowd template value as string' do is_expected.to include('# Information gathering') end @@ -206,7 +204,7 @@ let!(:file_name) { 'template' } it 'returns the nil' do - allow(BugcrowdTemplates).to receive(:current_directory).and_return( mock_path ) + allow(BugcrowdTemplates).to receive(:current_directory).and_return(mock_path) is_expected.to be_nil end end @@ -218,7 +216,7 @@ let!(:file_name) { 'template' } it 'returns the template defined in the category folder' do - allow(BugcrowdTemplates).to receive(:current_directory).and_return( mock_path ) + allow(BugcrowdTemplates).to receive(:current_directory).and_return(mock_path) is_expected.to include('# Fixture Category') end @@ -231,7 +229,7 @@ let!(:file_name) {} it 'returns the nil' do - allow(BugcrowdTemplates).to receive(:current_directory).and_return( mock_path ) + allow(BugcrowdTemplates).to receive(:current_directory).and_return(mock_path) is_expected.to be_nil end end