Some regression tests on loading layouts
parent
a643cf8025
commit
8bd814fc1a
|
|
@ -29,6 +29,10 @@ module Squib
|
||||||
# @api private
|
# @api private
|
||||||
attr_reader :text_hint
|
attr_reader :text_hint
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
|
attr_reader :layout, :config
|
||||||
|
|
||||||
# Squib's constructor that sets the immutable properties.
|
# Squib's constructor that sets the immutable properties.
|
||||||
#
|
#
|
||||||
# This is the starting point for Squib. In providing a block to the constructor, you have access to all of Deck's instance methods.
|
# This is the starting point for Squib. In providing a block to the constructor, you have access to all of Deck's instance methods.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
a:
|
||||||
|
extends: b
|
||||||
|
x: 50
|
||||||
|
b:
|
||||||
|
extends: a
|
||||||
|
x: 150
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
a:
|
||||||
|
extends: c
|
||||||
|
x: 50
|
||||||
|
b:
|
||||||
|
extends: a
|
||||||
|
x: 150
|
||||||
|
c:
|
||||||
|
extends: b
|
||||||
|
y: 250
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
frame:
|
||||||
|
x: 38
|
||||||
|
y: 38
|
||||||
|
title:
|
||||||
|
extends: frame
|
||||||
|
y: 50
|
||||||
|
width: 100
|
||||||
|
subtitle:
|
||||||
|
extends: subtitle
|
||||||
|
y: 150
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
frame:
|
||||||
|
x: 38
|
||||||
|
valign: !ruby/symbol middle
|
||||||
|
str: "blah"
|
||||||
|
font: Mr. Font
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
title:
|
||||||
|
extends: frame
|
||||||
|
y: 50
|
||||||
|
width: 100
|
||||||
|
frame:
|
||||||
|
x: 38
|
||||||
|
y: 38
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
a:
|
||||||
|
extends: a
|
||||||
|
x: 50
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
frame:
|
||||||
|
x: 38
|
||||||
|
y: 38
|
||||||
|
title:
|
||||||
|
extends: frame
|
||||||
|
y: 50
|
||||||
|
width: 100
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
frame:
|
||||||
|
x: 38
|
||||||
|
y: 38
|
||||||
|
title:
|
||||||
|
extends: frame
|
||||||
|
y: 50
|
||||||
|
width: 100
|
||||||
|
title2:
|
||||||
|
extends: frame
|
||||||
|
x: 75
|
||||||
|
y: 150
|
||||||
|
width: 150
|
||||||
|
|
@ -45,5 +45,81 @@ describe Squib::Deck do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end#describe
|
context "#load_layout" do
|
||||||
|
|
||||||
|
it "loads a normal layout with no extends" do
|
||||||
|
d = Squib::Deck.new(layout: test_file('no-extends.yml'))
|
||||||
|
expect(d.layout).to \
|
||||||
|
eq({'frame' => {
|
||||||
|
'x' => 38,
|
||||||
|
'valign' => :middle,
|
||||||
|
'str' => "blah",
|
||||||
|
'font' => "Mr. Font",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "loads with a single extends" do
|
||||||
|
d = Squib::Deck.new(layout: test_file('single-extends.yml'))
|
||||||
|
expect(d.layout).to \
|
||||||
|
eq({'frame' => {
|
||||||
|
'x' => 38,
|
||||||
|
'y' => 38,
|
||||||
|
},
|
||||||
|
'title' => {
|
||||||
|
'extends' => 'frame',
|
||||||
|
'x' => 38,
|
||||||
|
'y' => 50,
|
||||||
|
'width' => 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "applies the extends regardless of order" do
|
||||||
|
d = Squib::Deck.new(layout: test_file('pre-extends.yml'))
|
||||||
|
expect(d.layout).to \
|
||||||
|
eq({'frame' => {
|
||||||
|
'x' => 38,
|
||||||
|
'y' => 38,
|
||||||
|
},
|
||||||
|
'title' => {
|
||||||
|
'extends' => 'frame',
|
||||||
|
'x' => 38,
|
||||||
|
'y' => 50,
|
||||||
|
'width' => 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "applies the single-level extends multiple timess" do
|
||||||
|
d = Squib::Deck.new(layout: test_file('single-level-multi-extends.yml'))
|
||||||
|
expect(d.layout).to \
|
||||||
|
eq({'frame' => {
|
||||||
|
'x' => 38,
|
||||||
|
'y' => 38,
|
||||||
|
},
|
||||||
|
'title' => {
|
||||||
|
'extends' => 'frame',
|
||||||
|
'x' => 38,
|
||||||
|
'y' => 50,
|
||||||
|
'width' => 100,
|
||||||
|
},
|
||||||
|
'title2' => {
|
||||||
|
'extends' => 'frame',
|
||||||
|
'x' => 75,
|
||||||
|
'y' => 150,
|
||||||
|
'width' => 150,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,7 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
||||||
Coveralls::SimpleCov::Formatter
|
Coveralls::SimpleCov::Formatter
|
||||||
]
|
]
|
||||||
SimpleCov.start
|
SimpleCov.start
|
||||||
|
|
||||||
|
def test_file(str)
|
||||||
|
"#{File.expand_path(File.dirname(__FILE__))}/data/#{str}"
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue