Skip to content

Commit 6472a30

Browse files
committed
Backfill tests for inspection AR model objects
1 parent 6744447 commit 6472a30

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

spec/unit/object_inspection_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,44 @@
680680
end
681681
end
682682

683+
context "given an ActiveRecord object" do
684+
context "given as_single_line: true" do
685+
it "returns a representation of the object on a single line" do
686+
inspection = described_class.inspect(
687+
SuperDiff::Test::Models::ActiveRecord::Person.new(
688+
name: "Elliot",
689+
age: 31,
690+
),
691+
as_single_line: true,
692+
)
693+
694+
expect(inspection).to eq(
695+
%(#<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot">)
696+
)
697+
end
698+
end
699+
700+
context "given as_single_line: false" do
701+
it "returns a representation of the object across multiple lines" do
702+
inspection = described_class.inspect(
703+
SuperDiff::Test::Models::ActiveRecord::Person.new(
704+
name: "Elliot",
705+
age: 31,
706+
),
707+
as_single_line: false,
708+
)
709+
710+
expect(inspection).to eq(<<~INSPECTION.rstrip)
711+
#<SuperDiff::Test::Models::ActiveRecord::Person {
712+
id: nil,
713+
age: 31,
714+
name: "Elliot"
715+
}>
716+
INSPECTION
717+
end
718+
end
719+
end
720+
683721
context "given a combination of all kinds of values" do
684722
context "given as_single_line: true" do
685723
it "returns a representation of the object on a single line" do

0 commit comments

Comments
 (0)