Implementing multi-level extends, except for one case
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
base:
|
||||
a: 101
|
||||
b: 102
|
||||
c: 103
|
||||
frame:
|
||||
x: 104
|
||||
y: 105
|
||||
b: 106
|
||||
title:
|
||||
extends:
|
||||
- base
|
||||
- frame
|
||||
a: 107
|
||||
x: 108
|
||||
@@ -6,5 +6,5 @@ title:
|
||||
y: 50
|
||||
width: 100
|
||||
subtitle:
|
||||
extends: subtitle
|
||||
extends: title
|
||||
y: 150
|
||||
+63
-2
@@ -94,7 +94,7 @@ describe Squib::Deck do
|
||||
)
|
||||
end
|
||||
|
||||
it "applies the single-level extends multiple timess" do
|
||||
it "applies the single-level extends multiple times" do
|
||||
d = Squib::Deck.new(layout: test_file('single-level-multi-extends.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'frame' => {
|
||||
@@ -117,8 +117,69 @@ describe Squib::Deck do
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
# it "applies multiple extends in a single rule" do
|
||||
# d = Squib::Deck.new(layout: test_file('multi-extends-single-entry.yml'))
|
||||
# expect(d.layout).to \
|
||||
# eq({'base' => {
|
||||
# 'x' => 38,
|
||||
# 'y' => 38,
|
||||
# },
|
||||
# 'frame' => {
|
||||
# 'extends' => 'frame',
|
||||
# 'x' => 38,
|
||||
# 'y' => 50,
|
||||
# 'width' => 100,
|
||||
# },
|
||||
# 'title' => {
|
||||
# 'extends' => 'frame',
|
||||
# 'x' => 75,
|
||||
# 'y' => 150,
|
||||
# 'width' => 150,
|
||||
# },
|
||||
# }
|
||||
# )
|
||||
# end
|
||||
|
||||
it "applies multi-level extends" do
|
||||
d = Squib::Deck.new(layout: test_file('multi-level-extends.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'frame' => {
|
||||
'x' => 38,
|
||||
'y' => 38,
|
||||
},
|
||||
'title' => {
|
||||
'extends' => 'frame',
|
||||
'x' => 38,
|
||||
'y' => 50,
|
||||
'width' => 100,
|
||||
},
|
||||
'subtitle' => {
|
||||
'extends' => 'title',
|
||||
'x' => 38,
|
||||
'y' => 150,
|
||||
'width' => 100,
|
||||
},
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
it "fails on a self-circular extends" do
|
||||
file = test_file('self-circular-extends.yml')
|
||||
expect { Squib::Deck.new(layout: file) }.to \
|
||||
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
||||
end
|
||||
|
||||
it "fails on a easy-circular extends" do
|
||||
file = test_file('easy-circular-extends.yml')
|
||||
expect { Squib::Deck.new(layout: file) }.to \
|
||||
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
||||
end
|
||||
|
||||
it "hard on a easy-circular extends" do
|
||||
file = test_file('hard-circular-extends.yml')
|
||||
expect { Squib::Deck.new(layout: file) }.to \
|
||||
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user