Skip to content

Commit e242595

Browse files
headiusandrykonchin
authored andcommitted
Add specs for Data subclass and empty Data definition
1 parent 7d8998a commit e242595

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

core/data/fixtures/classes.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,13 @@ def self.name
99
end
1010

1111
class DataSubclass < Data; end
12+
13+
MeasureSubclass = Class.new(Measure) do
14+
def initialize(amount:, unit:)
15+
super
16+
end
17+
end
18+
19+
Empty = Data.define()
1220
end
1321
end

core/data/initialize_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,15 @@
6060
e.message.should.include?("unknown keyword: :system")
6161
}
6262
end
63+
64+
it "supports super from a subclass" do
65+
ms = DataSpecs::MeasureSubclass.new(amount: 1, unit: "km")
66+
67+
ms.amount.should == 1
68+
ms.unit.should == "km"
69+
end
70+
71+
it "supports Data with no fields" do
72+
-> { DataSpecs::Empty.new }.should_not raise_error
73+
end
6374
end

0 commit comments

Comments
 (0)