Skip to content

Commit e763fa4

Browse files
committed
Fixing more tests
1 parent 0ef19f0 commit e763fa4

File tree

1 file changed

+46
-6
lines changed

1 file changed

+46
-6
lines changed

spec/unit/deprecations_spec.rb

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
require "spec_helper"
22

33
# stree-ignore
4-
constant_remappings = {
5-
"SuperDiff::ActiveRecord::ObjectInspection::InspectionTreeBuilders::ActiveRecordModel" => "SuperDiff::ActiveRecord::InspectionTreeBuilders::ActiveRecordModel",
6-
"SuperDiff::ActiveRecord::ObjectInspection::InspectionTreeBuilders::ActiveRecordRelation" => "SuperDiff::ActiveRecord::InspectionTreeBuilders::ActiveRecordRelation",
7-
"SuperDiff::ActiveSupport::ObjectInspection::InspectionTreeBuilders::HashWithIndifferentAccess" => "SuperDiff::ActiveSupport::InspectionTreeBuilders::HashWithIndifferentAccess",
8-
"SuperDiff::ActiveSupport::ObjectInspection::InspectionTreeBuilders::OrderedOptions" => "SuperDiff::ActiveSupport::InspectionTreeBuilders::OrderedOptions",
4+
common_constant_remappings = {
95
"SuperDiff::ColorizedDocumentExtensions" => "SuperDiff::Core::ColorizedDocumentExtensions",
106
"SuperDiff::Configuration" => "SuperDiff::Core::Configuration",
117
# TODO: Add back?
@@ -87,7 +83,19 @@
8783
"SuperDiff::TieredLinesFormatter" => "SuperDiff::Core::TieredLinesFormatter",
8884
}
8985

90-
constant_remappings.each do |old_constant_name, new_constant_name|
86+
# stree-ignore
87+
active_record_constant_remappings = {
88+
"SuperDiff::ActiveRecord::ObjectInspection::InspectionTreeBuilders::ActiveRecordModel" => "SuperDiff::ActiveRecord::InspectionTreeBuilders::ActiveRecordModel",
89+
"SuperDiff::ActiveRecord::ObjectInspection::InspectionTreeBuilders::ActiveRecordRelation" => "SuperDiff::ActiveRecord::InspectionTreeBuilders::ActiveRecordRelation",
90+
}
91+
92+
# stree-ignore
93+
active_support_constant_remappings = {
94+
"SuperDiff::ActiveSupport::ObjectInspection::InspectionTreeBuilders::HashWithIndifferentAccess" => "SuperDiff::ActiveSupport::InspectionTreeBuilders::HashWithIndifferentAccess",
95+
"SuperDiff::ActiveSupport::ObjectInspection::InspectionTreeBuilders::OrderedOptions" => "SuperDiff::ActiveSupport::InspectionTreeBuilders::OrderedOptions",
96+
}
97+
98+
common_constant_remappings.each do |old_constant_name, new_constant_name|
9199
RSpec.describe old_constant_name, type: :unit do
92100
it "maps to #{new_constant_name}" do
93101
capture_warnings do
@@ -103,6 +111,38 @@
103111
end
104112
end
105113

114+
active_record_constant_remappings.each do |old_constant_name, new_constant_name|
115+
RSpec.describe old_constant_name, type: :unit, active_record: true do
116+
it "maps to #{new_constant_name}" do
117+
capture_warnings do
118+
expect(Object.const_get(old_constant_name)).to be(
119+
Object.const_get(new_constant_name)
120+
)
121+
end
122+
end
123+
124+
it "points users to #{new_constant_name} instead" do
125+
expect(old_constant_name).to be_deprecated_in_favor_of(new_constant_name)
126+
end
127+
end
128+
end
129+
130+
active_support_constant_remappings.each do |old_constant_name, new_constant_name|
131+
RSpec.describe old_constant_name, type: :unit, active_support: true do
132+
it "maps to #{new_constant_name}" do
133+
capture_warnings do
134+
expect(Object.const_get(old_constant_name)).to be(
135+
Object.const_get(new_constant_name)
136+
)
137+
end
138+
end
139+
140+
it "points users to #{new_constant_name} instead" do
141+
expect(old_constant_name).to be_deprecated_in_favor_of(new_constant_name)
142+
end
143+
end
144+
end
145+
106146
RSpec.describe "SuperDiff::Differs::Main.call", type: :unit do
107147
it "maps to SuperDiff.diff" do
108148
capture_warnings do

0 commit comments

Comments
 (0)