Skip to content

Commit

Permalink
Merge pull request bugcrowd#529 from bugcrowd/ruby-version-upgrades
Browse files Browse the repository at this point in the history
ruby: from 2.7 to 3.3
bundler: from 2.1 to 2.5.5
pry: from 0.11 to 0.14.2
rake: from 12.3 to 13.0.6
rspec: from 3.6 to 3.12
rubocop: from 0.56.0 to 1.52.1
Modified GitHub Actions, Rubocop Config
Styling, and syntax changes based on rubocop
  • Loading branch information
abhinav-nain authored Apr 9, 2024
2 parents 145fe5c + 5ca8b07 commit d77233e
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 3.3.0

Style/Documentation:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.2
3.3.0
12 changes: 6 additions & 6 deletions bugcrowd_templates.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 6 additions & 6 deletions lib/bugcrowd_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lib/bugcrowd_templates/template_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 || ''
Expand All @@ -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
Expand All @@ -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

Expand Down
105 changes: 51 additions & 54 deletions spec/bugcrowd_templates/template_path_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@

# frozen_string_literal: true

require 'spec_helper'

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
Expand All @@ -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')
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -154,8 +153,6 @@
end
end



context 'when it has category params for submissions' do
let!(:type) { 'submissions' }
let!(:field) { 'description' }
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
26 changes: 12 additions & 14 deletions spec/bugcrowd_templates_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

require 'spec_helper'

describe BugcrowdTemplates do


describe '#VERSION' do
subject { described_class::VERSION }

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d77233e

Please sign in to comment.