Skip to content

Commit

Permalink
Improve Rubocop config, fix offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Sep 1, 2024
1 parent 747d4d2 commit 12c85aa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
18 changes: 17 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllCops:
- bin/*
- lib/generators/**/*.rb
- gemfiles/*
- spec/**/*
- spec/dummy/**/*

Gemspec/RequireMFA:
Enabled: false
Expand All @@ -27,6 +27,9 @@ Style/Documentation:
Style/HashSyntax:
EnforcedShorthandSyntax: never

Style/BlockDelimiters:
AllowedPatterns: ['expect']

##########
# LAYOUT #
##########
Expand All @@ -50,3 +53,16 @@ Layout/EmptyLinesAroundBlockBody:

Layout/EmptyLinesAroundModuleBody:
Enabled: false

#########
# RSPEC #
#########

RSpec/MultipleExpectations:
Max: 6

RSpec/ExampleLength:
Max: 8

RSpec/NotToNot:
EnforcedStyle: to_not
2 changes: 2 additions & 0 deletions spec/config_rspec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Configure RSpec
RSpec.configure do |config|
# Use DB agnostic schema by default
Expand Down
15 changes: 10 additions & 5 deletions spec/royce/role_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Basic tests' do
RSpec.describe 'Basic tests' do # rubocop:disable RSpec/DescribeClass

before { User.delete_all }

let(:user) { User.create }

it 'can create role' do
role = Royce::Role.create(name: 'some_role')
expect(role).to_not be nil
expect(role).to_not be_nil
expect(role.name).to eq 'some_role'
expect(role.to_s).to eq 'some_role'
end

it 'Can create user' do
user = User.create
expect(user).to_not be nil
expect(user).to_not be_nil
end

it 'Creates roles automatically' do
Expand Down Expand Up @@ -108,7 +111,9 @@

it 'has named scopes for each role' do
User.available_roles.each do |role|
User.send role.name.pluralize.to_sym
expect {
User.send(role.name.pluralize.to_sym)
}.to_not raise_error
end
end

Expand All @@ -119,7 +124,7 @@
expect(user.role_list).to eq ['user']

user.add_role :admin
expect(user.role_list).to eq ['user', 'admin']
expect(user.role_list).to eq %w[user admin]
end

it 'doesnt get double roles' do
Expand Down
8 changes: 5 additions & 3 deletions spec/royce/scope_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Testing class-level scopes' do
RSpec.describe 'Testing class-level scopes' do # rubocop:disable RSpec/DescribeClass

before do
Employee.delete_all
Expand Down Expand Up @@ -31,10 +33,10 @@

describe 'Role to owning class relationships' do
the_role = Royce::Role.find_or_create_by(name: 'partier')
count = 20
count = 20

it 'exist for single word models' do
count.times{ Employee.create.add_role 'partier' }
count.times { Employee.create.add_role 'partier' }
expect(the_role.employees.count).to eq count
end

Expand Down

0 comments on commit 12c85aa

Please sign in to comment.