Skip to content

Commit

Permalink
Merge pull request #254 from kpumuk/standardrb-rspec
Browse files Browse the repository at this point in the history
Switching from Rubocop to Standard completely
  • Loading branch information
kpumuk committed Jan 17, 2023
2 parents b76079e + 31817e1 commit 9a4637b
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 46 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/standard.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
name: StandardRB

on: [push]
on:
push:
pull_request:
types: [opened, reopened]
env:
BUNDLE_GEMFILE: gemfiles/rails_7.0.gemfile

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: StandardRB Linter
uses: andrewmcodes/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: Set up Ruby 3.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.0
- name: Cache gems
uses: actions/cache@v3
with:
path: gemfiles/vendor/bundle
key: ${{ runner.os }}-rubocop-${{ hashFiles('gemfiles/rails_7.0.gemfile') }}
restore-keys: |
${{ runner.os }}-rubocop-
- name: Install gems
run: |
bundle config path vendor/bundle
bundle check || (bundle install --jobs=4 --retry=3 && bundle clean)
- name: Run StandardRB
run: |
bundle exec standardrb
17 changes: 17 additions & 0 deletions .rubocop-rails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require:
- rubocop-rails

inherit_gem:
rubocop-rails:
- config/default.yml

AllCops:
TargetRailsVersion: 5.1

# Do not require loading Rails environment for Rake tasks as we are not a Rails application.
Rails/RakeEnvironment:
Enabled: false

# Do not require subclassing from ApplicationController as we're not a rails application
Rails/ApplicationController:
Enabled: false
6 changes: 6 additions & 0 deletions .rubocop-rake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require:
- rubocop-rake

inherit_gem:
rubocop-rake:
- config/default.yml
35 changes: 2 additions & 33 deletions .rubocop.yml → .rubocop-rspec.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
require:
- standard
- rubocop-performance
- rubocop-rails
- rubocop-rake
- rubocop-rspec

inherit_gem:
standard: config/base.yml

AllCops:
# Enable all the rules by default
EnabledByDefault: true
# Command line rubocop options
ExtraDetails: true
DisplayStyleGuide: true
DisplayCopNames: true
SuggestExtensions: false
# Target versions
TargetRubyVersion: 2.6
TargetRailsVersion: 5.1

#-------------------------------------------------------------------------------
# RSpec rules
#-------------------------------------------------------------------------------
rubocop-rspec:
- config/default.yml

RSpec/MultipleExpectations:
Max: 7
Expand Down Expand Up @@ -51,15 +32,3 @@ RSpec/VerifiedDoubles:
RSpec/NoExpectationExample:
AllowedPatterns:
- test_hashes_and_arrays

#-------------------------------------------------------------------------------
# Disabled rules
#-------------------------------------------------------------------------------

# Do not require loading Rails enviroment for Rake tasks as we are not a Rails application.
Rails/RakeEnvironment:
Enabled: false

# Do not require subclassing from ApplicationController as we're not a rails application
Rails/ApplicationController:
Enabled: false
7 changes: 7 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ruby_version: 2.6.0
extend_config:
- .rubocop-rake.yml
- .rubocop-rails.yml
- .rubocop-rspec.yml
ignore:
- "gemfiles/vendor/**/*"
7 changes: 3 additions & 4 deletions meta-tags.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec", "~> 3.12.0"
spec.add_development_dependency "rspec-html-matchers", "~> 0.10.0"
spec.add_development_dependency "appraisal", "~> 2.4.1"
spec.add_development_dependency "simplecov", "~> 0.21.2"
spec.add_development_dependency "simplecov", "~> 0.22.0"
# Code style
spec.add_development_dependency "standard", "~> 1.18.1"
spec.add_development_dependency "rubocop-performance", "~> 1.15.1"
spec.add_development_dependency "standard", "~> 1.22.0"
spec.add_development_dependency "rubocop-rails", "~> 2.17.3"
spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
spec.add_development_dependency "rubocop-rspec", "~> 2.15.0"
spec.add_development_dependency "rubocop-rspec", "~> 2.18.0"
# Format RSpec output for CircleCI
spec.add_development_dependency "rspec_junit_formatter", "~> 0.6.0"

Expand Down
2 changes: 1 addition & 1 deletion spec/controller_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

before do
skip("Does not work properly with RBS") if ENV["RBS_TEST_TARGET"] # rubocop:disable RSpec/Pending
skip("Does not work properly with RBS") if ENV["RBS_TEST_TARGET"]
end

describe "module" do
Expand Down
2 changes: 1 addition & 1 deletion spec/view_helper/description_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
end

it "fails when title is not a String-like object" do
skip("Fails RBS") if ENV["RBS_TEST_TARGET"] # rubocop:disable RSpec/Pending
skip("Fails RBS") if ENV["RBS_TEST_TARGET"]

expect {
subject.display_meta_tags(description: 5)
Expand Down
2 changes: 1 addition & 1 deletion spec/view_helper/title_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
end

it "fails when title is not a String-like object" do
skip("Fails RBS") if ENV["RBS_TEST_TARGET"] # rubocop:disable RSpec/Pending
skip("Fails RBS") if ENV["RBS_TEST_TARGET"]

expect {
subject.display_meta_tags(site: "someSite", title: 5)
Expand Down

0 comments on commit 9a4637b

Please sign in to comment.