Skip to content

Commit 03217f9

Browse files
authored
Merge pull request #771 from lcreid/rake-wo-bundle-exec-clean-up-warnings
Rake Without `bundle exec` and Clean Up Warnings
2 parents febe119 + 5e3ed5a commit 03217f9

File tree

7 files changed

+35
-26
lines changed

7 files changed

+35
-26
lines changed

.rubocop.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AllCops:
66
DisplayCopNames: true
77
DisplayStyleGuide: true
88
TargetRubyVersion: 3.2
9-
TargetRailsVersion: 7.1
9+
TargetRailsVersion: 7.2
1010
NewCops: enable
1111
Exclude:
1212
- bin/*
@@ -25,7 +25,6 @@ AllCops:
2525
- gemfiles/vendor/bundle/**/*
2626
- vendor/bundle/**/*
2727
- Guardfile
28-
- Rakefile
2928
- vendor/**/*
3029

3130
Layout/LineLength:
@@ -73,6 +72,10 @@ Rails/ApplicationRecord:
7372
Exclude:
7473
- "demo/db/migrate/**"
7574

75+
Rails/RakeEnvironment:
76+
Exclude:
77+
- "Rakefile"
78+
7679
Rails/RefuteMethods:
7780
Enabled: false
7881

.yarnrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# yarn lockfile v1
33

44

5-
lastUpdateCheck 1761786460258
5+
lastUpdateCheck 1762373771610

Rakefile

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
11
begin
2-
require 'bundler/setup'
3-
4-
require 'bundler/gem_tasks'
2+
require "bundler/setup"
3+
require "bundler/gem_tasks"
54
require "minitest/test_task"
6-
require 'rdoc/task'
7-
require 'rubocop/rake_task'
8-
rescue LoadError
9-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5+
require "rdoc/task"
6+
require "rubocop/rake_task"
7+
rescue LoadError => e
8+
puts "You must run `bundle install` to run rake tasks (#{e.message})"
109
end
1110

1211
RDoc::Task.new(:rdoc) do |rdoc|
13-
rdoc.rdoc_dir = 'rdoc'
14-
rdoc.title = 'BootstrapForm'
15-
rdoc.options << '--line-numbers'
16-
rdoc.rdoc_files.include('README.md')
17-
rdoc.rdoc_files.include('lib/**/*.rb')
12+
rdoc.rdoc_dir = "rdoc"
13+
rdoc.title = "BootstrapForm"
14+
rdoc.options << "--line-numbers"
15+
rdoc.rdoc_files.include("README.md")
16+
rdoc.rdoc_files.include("lib/**/*.rb")
1817
end
1918

2019
Minitest::TestTask.create(:test) do |t|
21-
t.libs << "test"
22-
t.libs << "lib"
23-
t.warning = false
20+
t.warning = true
2421
t.test_globs = ["test/**/*_test.rb"]
2522
end
2623

27-
desc 'Run RuboCop checks'
24+
desc "Run RuboCop checks"
2825
RuboCop::RakeTask.new(:rubocop)
2926

3027
task default: %i[test rubocop:autocorrect]
3128

3229
namespace :test do
3330
desc "Run tests for all supported Rails versions, with current Ruby version"
3431
task :all do
35-
original_gemfile = ENV["BUNDLE_GEMFILE"]
32+
original_gemfile = ENV.fetch("BUNDLE_GEMFILE", nil)
3633
gemfiles = Dir.glob("gemfiles/*.gemfile").reject { |f| File.basename(f) == "common.gemfile" }
3734
gemfiles.each do |f|
3835
ENV["BUNDLE_GEMFILE"] = f
36+
system("bundle update --bundler")
3937
system("bundle check") || system("bundle install")
40-
system("bundle exec rake test")
38+
system("rake test")
4139
end
4240

4341
original_directory = Dir.pwd
4442
Dir.chdir("demo")
4543
ENV.delete("BUNDLE_GEMFILE")
44+
system("bundle update --bundler")
4645
system("bundle check") || system("bundle install")
47-
system("bundle exec rake test:all")
48-
46+
system("rake test:all")
4947
ensure
5048
original_gemfile.nil? ? ENV.delete("BUNDLE_GEMFILE") : ENV["BUNDLE_GEMFILE"] = original_gemfile
5149
Dir.chdir(original_directory) unless original_directory.nil?

demo/Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ gem "sqlite3", ">= 2.1"
1414
gem "stimulus-rails"
1515
gem "thruster", require: false
1616
gem "turbo-rails"
17-
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
17+
gem "tzinfo-data", platforms: %i[windows jruby]
1818

1919
group :development, :test do
2020
gem "brakeman", require: false
21-
gem "debug", platforms: %i[mri mingw x64_mingw]
21+
gem "debug", platforms: %i[mri windows]
2222
end
2323

2424
group :development do

demo/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,4 @@ DEPENDENCIES
310310
web-console
311311

312312
BUNDLED WITH
313-
2.5.9
313+
2.7.2

gemfiles/common.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ end
2020
group :development, :test do
2121
gem "debug"
2222
gem "ostruct" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.5.0")
23+
gem "warning"
2324
end
2425

2526
group :ci do

test/test_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
ENV["RAILS_ENV"] ||= "test"
22

3+
puts "BUNDLE_GEMFILE: #{ENV.fetch('BUNDLE_GEMFILE', nil)}" # rubocop/ignore Rails/Output
4+
5+
require "warning"
6+
mail_gem_path = Gem::Specification.find_by_name("mail").full_gem_path
7+
Warning.ignore(:not_reached, mail_gem_path)
8+
Warning.ignore(/warning: assigned but unused variable - testEof/, mail_gem_path)
9+
310
require "diffy"
411
require "nokogiri"
512
require "equivalent-xml"

0 commit comments

Comments
 (0)