Skip to content

Commit a5af23d

Browse files
committed
Support rails 8
1 parent 5d01c41 commit a5af23d

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

Gemfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
source 'https://rubygems.org'
22

3-
ruby '>= 2.4.0'
3+
ruby '>= 3.0.0'
44

5-
gem 'activerecord', '>= 4.2.5', '< 6', require: false
5+
gem 'activerecord', '>= 4.2.5', '< 9', require: false
66
gem 'rake', require: false
77

88
group :development do
@@ -29,7 +29,6 @@ group :development, :test do
2929
gem 'coveralls'
3030

3131
gem 'overcommit'
32-
gem 'ruby_dep', '1.5.0'
3332

3433
platforms :mri, :mingw do
3534
gem 'pry', require: false

annotate.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
77
s.name = 'annotate'
88
s.version = Annotate.version
99

10-
s.required_ruby_version = '>= 2.4.0'
10+
s.required_ruby_version = '>= 3.0.0'
1111
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
1212
s.authors = ['Alex Chaffee', 'Cuong Tran', 'Marcos Piccinini', 'Turadg Aleahmad', 'Jon Frisby']
1313
s.description = 'Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema.'
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
2323

2424
s.specification_version = 4 if s.respond_to? :specification_version
2525
s.add_runtime_dependency(%q<rake>, '>= 10.4', '< 14.0')
26-
s.add_runtime_dependency(%q<activerecord>, ['>= 3.2', '< 8.0'])
26+
s.add_runtime_dependency(%q<activerecord>, ['>= 3.2', '< 9.0'])
2727

2828
s.metadata = {
2929
"bug_tracker_uri" => "https://github.com/ctran/annotate_models/issues/",

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,8 +3087,11 @@ class User < ActiveRecord::Base
30873087
end
30883088

30893089
it 'displays the error message and stacktrace with trace enabled' do
3090-
expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("Unable to deannotate #{@model_dir}/user.rb: oops")).to_stderr
3091-
expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("/user.rb:2:in `<class:User>'")).to_stderr
3090+
output = capture_stderr do
3091+
AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true
3092+
end
3093+
expect(output).to include("Unable to deannotate #{@model_dir}/user.rb: oops")
3094+
expect(output).to include('/user.rb:2:in')
30923095
end
30933096
end
30943097

spec/spec_helper.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,23 @@
2424
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
2525
$LOAD_PATH.unshift(File.dirname(__FILE__))
2626

27+
require 'logger'
2728
require 'active_support'
29+
30+
# Ruby 3 removes File.exists? in favor of File.exist?
31+
unless File.respond_to?(:exists?)
32+
class << File
33+
alias exists? exist?
34+
end
35+
end
36+
37+
def capture_stderr
38+
old, $stderr = $stderr, StringIO.new
39+
yield
40+
$stderr.string
41+
ensure
42+
$stderr = old
43+
end
2844
require 'active_support/core_ext/object/blank'
2945
require 'active_support/core_ext/class/subclasses'
3046
require 'active_support/core_ext/string/inflections'

0 commit comments

Comments
 (0)