Skip to content

Commit 1750f90

Browse files
authored
Merge pull request #233 from n-rodriguez/wip/cleanup
Modernize gem
2 parents d52d0c5 + f26d900 commit 1750f90

87 files changed

Lines changed: 2873 additions & 2488 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: CI
3+
4+
on:
5+
push:
6+
branches:
7+
- '**'
8+
pull_request:
9+
branches:
10+
- '**'
11+
schedule:
12+
- cron: '0 4 1 * *'
13+
14+
jobs:
15+
rubocop:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v5
21+
22+
- name: Setup Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: '3.0'
26+
27+
- name: Bundler
28+
run: bundle install
29+
30+
- name: Rubocop
31+
run: bin/rubocop
32+
33+
rspec:
34+
runs-on: ubuntu-latest
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
ruby:
40+
- '4.0'
41+
- '3.4'
42+
- '3.3'
43+
- '3.2'
44+
- '3.1'
45+
- '3.0'
46+
rails:
47+
- rails_8.1
48+
- rails_8.0
49+
- rails_7.2
50+
- rails_7.1
51+
- rails_7.0
52+
- rails_6.1
53+
54+
exclude:
55+
- ruby: '3.0'
56+
rails: 'rails_7.2'
57+
- ruby: '3.0'
58+
rails: 'rails_8.0'
59+
- ruby: '3.0'
60+
rails: 'rails_8.1'
61+
62+
- ruby: '3.1'
63+
rails: 'rails_8.0'
64+
- ruby: '3.1'
65+
rails: 'rails_8.1'
66+
67+
env:
68+
# $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
69+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.rails }}.gemfile
70+
# Check for frozen strings
71+
RUBYOPT: "--enable=frozen-string-literal --debug=frozen-string-literal"
72+
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v5
76+
77+
- name: Setup Ruby
78+
uses: ruby/setup-ruby@v1
79+
with:
80+
ruby-version: ${{ matrix.ruby }}
81+
bundler-cache: true
82+
83+
- name: RSpec
84+
run: bin/rspec

.rspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
--color
2-
--format=documentation
31
--require spec_helper
2+
--warnings

.rubocop.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
plugins:
3+
- rubocop-capybara
4+
- rubocop-performance
5+
- rubocop-rake
6+
- rubocop-rspec
7+
8+
inherit_from:
9+
- .rubocop_todo.yml
10+
11+
AllCops:
12+
NewCops: enable
13+
SuggestExtensions: true
14+
TargetRubyVersion: 3.0
15+
Exclude:
16+
- bin/*
17+
- gemfiles/*
18+
19+
Gemspec/RequireMFA:
20+
Enabled: false
21+
22+
Style/Documentation:
23+
Enabled: false
24+
25+
Naming/FileName:
26+
Exclude:
27+
- lib/simple-navigation.rb
28+
29+
###########
30+
# METRICS #
31+
###########
32+
33+
Metrics/ClassLength:
34+
Exclude:
35+
- spec/**/*
36+
37+
Metrics/MethodLength:
38+
Exclude:
39+
- spec/**/*
40+
41+
#########
42+
# RSPEC #
43+
#########
44+
45+
RSpec/NestedGroups:
46+
Max: 6
47+
48+
RSpec/MultipleMemoizedHelpers:
49+
Max: 8

.rubocop_todo.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
3+
Layout/LineLength:
4+
Enabled: false
5+
6+
Naming/VariableNumber:
7+
Enabled: false
8+
9+
Style/BlockDelimiters:
10+
Enabled: false
11+
12+
#########
13+
# RSPEC #
14+
#########
15+
16+
RSpec/SubjectStub:
17+
Enabled: false
18+
19+
RSpec/NamedSubject:
20+
Enabled: false
21+
22+
RSpec/VerifiedDoubles:
23+
Enabled: false
24+
25+
RSpec/ContextWording:
26+
Enabled: false
27+
28+
RSpec/MessageSpies:
29+
Enabled: false
30+
31+
RSpec/IndexedLet:
32+
Enabled: false
33+
34+
############
35+
# CAPYBARA #
36+
############
37+
38+
Capybara/NegationMatcher:
39+
Enabled: false

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

Appraisals

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# frozen_string_literal: true
2+
3+
# To update files in gemfiles/ directory:
4+
# rm gemfiles/*
5+
# bin/appraisal generate
6+
7+
# To run tests:
8+
# bin/appraisal rails_8.1 bundle install
9+
# bin/appraisal rails_8.1 rake
10+
# bin/appraisal rails_8.1 rspec
11+
12+
appraise 'rails_6.1' do
13+
gem 'railties', '~> 6.1.0'
14+
gem 'rspec-rails'
15+
gem 'concurrent-ruby', '1.3.4'
16+
17+
# Fix:
18+
# warning: drb was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
19+
# You can add drb to your Gemfile or gemspec to silence this warning.
20+
install_if '-> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") }' do
21+
gem 'base64'
22+
gem 'bigdecimal'
23+
gem 'drb'
24+
gem 'mutex_m'
25+
end
26+
27+
install_if '-> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("4.0.0") }' do
28+
gem 'benchmark'
29+
end
30+
end
31+
32+
appraise 'rails_7.0' do
33+
gem 'railties', '~> 7.0.0'
34+
gem 'rspec-rails'
35+
end
36+
37+
appraise 'rails_7.1' do
38+
gem 'railties', '~> 7.1.0'
39+
gem 'rspec-rails'
40+
end
41+
42+
appraise 'rails_7.2' do
43+
gem 'railties', '~> 7.2.0'
44+
gem 'rspec-rails'
45+
end
46+
47+
appraise 'rails_8.0' do
48+
gem 'railties', '~> 8.0.0'
49+
gem 'rspec-rails'
50+
end
51+
52+
appraise 'rails_8.1' do
53+
gem 'railties', '~> 8.1.0'
54+
gem 'rspec-rails'
55+
end

Gemfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec
6+
7+
# Dev libs
8+
gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
9+
gem 'capybara'
10+
gem 'memfs', git: 'https://github.com/simonc/memfs.git'
11+
gem 'rake'
12+
gem 'rdoc'
13+
gem 'rspec'
14+
gem 'simplecov'
15+
gem 'tzinfo'
16+
gem 'warning'
17+
18+
# Dev tools / linter
19+
gem 'guard-rspec', require: false
20+
gem 'rubocop', require: false
21+
gem 'rubocop-capybara', require: false
22+
gem 'rubocop-performance', require: false
23+
gem 'rubocop-rake', require: false
24+
gem 'rubocop-rspec', require: false

Guardfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# frozen_string_literal: true
2+
13
guard :rspec, all_after_pass: true, failed_mode: :none do
24
watch(%r{^spec/.+_spec\.rb$})
3-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
46
watch(%r{^spec/fake_app/.+\.rb$}) { 'spec/integration' }
57

6-
watch('spec/spec_helper.rb') { 'spec' }
8+
watch('spec/spec_helper.rb') { 'spec' }
79
end

README.md

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,19 @@ Fork, fix, then send a Pull Request.
3131

3232
To run the test suite locally against all supported frameworks:
3333

34-
% bundle install
35-
% rake spec:all
34+
```sh
35+
bundle install
36+
bin/appraisal bundle install
37+
bin/appraisal rspec
38+
bin/appraisal rspec ./spec/requests/users_spec.rb
39+
```
3640

3741
To target the test suite against one framework:
3842

39-
% rake spec:rails-4-2-stable
40-
41-
You can find a list of supported spec tasks by running rake -T. You may also find it useful to run a specific test for a specific framework. To do so, you'll have to first make sure you have bundled everything for that configuration, then you can run the specific test:
42-
43-
% BUNDLE_GEMFILE='gemfiles/rails-4-2-stable.gemfile' bundle install -j 4
44-
% BUNDLE_GEMFILE='gemfiles/rails-4-2-stable.gemfile' bundle exec rspec ./spec/requests/users_spec.rb
45-
46-
### Rake and Bundler
47-
48-
If you use a shell plugin (like oh-my-zsh:bundler) that auto-prefixes commands with `bundle exec` using the `rake` command will fail.
49-
50-
Get the original command with `type -a rake`:
51-
52-
% type -a rake
53-
rake is an alias for bundled_rake
54-
rake is /Users/username/.rubies/ruby-2.2.3/bin/rake
55-
rake is /usr/bin/rake
56-
57-
In this situation `/Users/username/.rubies/ruby-2.2.3/bin/rake` is the command you should use.
43+
```sh
44+
bin/appraisal rails_8.1 rspec
45+
bin/appraisal rails_8.1 rspec ./spec/requests/users_spec.rb
46+
```
5847

5948
## License
6049

Rakefile

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,12 @@
1-
require 'bundler'
2-
Bundler::GemHelper.install_tasks
1+
# frozen_string_literal: true
32

4-
require 'rspec/core'
3+
require 'bundler/gem_tasks'
54
require 'rspec/core/rake_task'
6-
75
require 'rdoc/task'
86

97
RSpec::Core::RakeTask.new(:spec)
10-
118
task default: 'spec'
129

13-
namespace :spec do
14-
mappers = %w[
15-
rails-3-2-stable
16-
rails-4-1-stable
17-
rails-4-2-stable
18-
rails-5-2-stable
19-
rails-6-0-stable
20-
rails-6-1-stable
21-
]
22-
23-
mappers.each do |gemfile|
24-
desc "Run Tests against #{gemfile}"
25-
task gemfile do
26-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle -j 4 --quiet"
27-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t spec"
28-
end
29-
end
30-
31-
desc 'Run Tests against all ORMs'
32-
task all: mappers
33-
end
34-
3510
RDoc::Task.new do |rdoc|
3611
rdoc.rdoc_dir = 'rdoc'
3712
rdoc.title = 'SimpleNavigation'

0 commit comments

Comments
 (0)