shoes-core 4.0.0.pre6 → 4.0.0.pre7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/shoes-picker +1 -1
- data/lib/shoes/app.rb +3 -3
- data/lib/shoes/arc.rb +6 -5
- data/lib/shoes/arrow.rb +31 -0
- data/lib/shoes/background.rb +1 -1
- data/lib/shoes/border.rb +1 -1
- data/lib/shoes/builtin_methods.rb +1 -1
- data/lib/shoes/color.rb +3 -3
- data/lib/shoes/color/dsl_helpers.rb +10 -7
- data/lib/shoes/color/hex_converter.rb +1 -1
- data/lib/shoes/common/attachable.rb +11 -0
- data/lib/shoes/common/background_element.rb +8 -0
- data/lib/shoes/common/hover.rb +7 -17
- data/lib/shoes/common/link_finder.rb +12 -0
- data/lib/shoes/common/positioning.rb +1 -1
- data/lib/shoes/common/state.rb +1 -1
- data/lib/shoes/common/style.rb +9 -4
- data/lib/shoes/common/translate.rb +24 -0
- data/lib/shoes/common/ui_element.rb +1 -0
- data/lib/shoes/common/visibility.rb +1 -1
- data/lib/shoes/configuration.rb +2 -2
- data/lib/shoes/core/version.rb +3 -1
- data/lib/shoes/dimensions.rb +6 -2
- data/lib/shoes/dsl.rb +34 -14
- data/lib/shoes/font.rb +1 -1
- data/lib/shoes/gradient.rb +2 -1
- data/lib/shoes/image.rb +2 -2
- data/lib/shoes/input_box.rb +2 -2
- data/lib/shoes/internal_app.rb +8 -8
- data/lib/shoes/line.rb +7 -6
- data/lib/shoes/link.rb +5 -6
- data/lib/shoes/list_box.rb +2 -2
- data/lib/shoes/logger.rb +2 -1
- data/lib/shoes/mock.rb +1 -0
- data/lib/shoes/mock/arrow.rb +15 -0
- data/lib/shoes/mock/rect.rb +2 -1
- data/lib/shoes/mock/slot.rb +5 -1
- data/lib/shoes/mock/star.rb +2 -1
- data/lib/shoes/oval.rb +5 -4
- data/lib/shoes/point.rb +2 -1
- data/lib/shoes/progress.rb +1 -1
- data/lib/shoes/rect.rb +3 -2
- data/lib/shoes/shape.rb +14 -9
- data/lib/shoes/slot.rb +54 -25
- data/lib/shoes/slot_contents.rb +1 -3
- data/lib/shoes/star.rb +4 -3
- data/lib/shoes/text.rb +5 -0
- data/lib/shoes/text_block.rb +9 -9
- data/lib/shoes/ui/picker.rb +5 -5
- data/lib/shoes/version.rb +3 -1
- data/lib/shoes/widget.rb +2 -2
- data/lib/shoes/window.rb +6 -0
- data/spec/shoes/app_spec.rb +16 -16
- data/spec/shoes/arc_spec.rb +1 -1
- data/spec/shoes/arrow_spec.rb +28 -0
- data/spec/shoes/background_spec.rb +2 -2
- data/spec/shoes/border_spec.rb +3 -3
- data/spec/shoes/builtin_methods_spec.rb +2 -2
- data/spec/shoes/button_spec.rb +4 -2
- data/spec/shoes/color_spec.rb +12 -12
- data/spec/shoes/common/attachable_spec.rb +32 -0
- data/spec/shoes/common/inspect_spec.rb +4 -4
- data/spec/shoes/common/remove_spec.rb +5 -5
- data/spec/shoes/common/rotate_spec.rb +1 -1
- data/spec/shoes/common/style_normalizer_spec.rb +4 -4
- data/spec/shoes/common/style_spec.rb +15 -11
- data/spec/shoes/common/translate_spec.rb +27 -0
- data/spec/shoes/dimension_spec.rb +111 -100
- data/spec/shoes/dimensions_spec.rb +344 -303
- data/spec/shoes/download_spec.rb +17 -17
- data/spec/shoes/flow_spec.rb +2 -2
- data/spec/shoes/framework_learning_spec.rb +3 -1
- data/spec/shoes/helpers/fake_absolute_element.rb +3 -2
- data/spec/shoes/helpers/fake_element.rb +3 -2
- data/spec/shoes/input_box_spec.rb +2 -2
- data/spec/shoes/internal_app_spec.rb +14 -14
- data/spec/shoes/link_spec.rb +18 -19
- data/spec/shoes/list_box_spec.rb +9 -8
- data/spec/shoes/oval_spec.rb +1 -1
- data/spec/shoes/point_spec.rb +3 -3
- data/spec/shoes/renamed_delegate_spec.rb +2 -2
- data/spec/shoes/shape_spec.rb +20 -20
- data/spec/shoes/shared_examples/common_methods.rb +2 -2
- data/spec/shoes/shared_examples/dsl.rb +2 -2
- data/spec/shoes/shared_examples/dsl/flow.rb +1 -1
- data/spec/shoes/shared_examples/dsl/pattern.rb +2 -2
- data/spec/shoes/shared_examples/dsl/rgb.rb +2 -2
- data/spec/shoes/shared_examples/dsl/shape.rb +11 -7
- data/spec/shoes/shared_examples/dsl/star.rb +44 -44
- data/spec/shoes/shared_examples/dsl/style.rb +1 -1
- data/spec/shoes/shared_examples/dsl/text_elements.rb +6 -3
- data/spec/shoes/shared_examples/dsl/video.rb +1 -1
- data/spec/shoes/shared_examples/dsl_app_context.rb +6 -5
- data/spec/shoes/shared_examples/hover.rb +2 -2
- data/spec/shoes/shared_examples/shared_element_method.rb +2 -2
- data/spec/shoes/shared_examples/slot.rb +32 -21
- data/spec/shoes/shared_examples/style.rb +1 -1
- data/spec/shoes/slot_spec.rb +24 -7
- data/spec/shoes/span_spec.rb +5 -5
- data/spec/shoes/spec_helper.rb +1 -1
- data/spec/shoes/stack_spec.rb +5 -5
- data/spec/shoes/text_block_dimensions_spec.rb +6 -3
- data/spec/shoes/text_block_spec.rb +13 -7
- data/spec/shoes/text_spec.rb +22 -0
- data/spec/shoes/ui/picker_spec.rb +3 -3
- data/spec/shoes/url_spec.rb +4 -4
- data/spec/shoes/widget_spec.rb +1 -1
- data/spec/shoes_spec.rb +3 -3
- data/spec/spec_helper.rb +8 -1
- metadata +17 -4
- data/bin/shoes +0 -1
@@ -27,8 +27,8 @@ end
|
|
27
27
|
shared_examples_for "left, top as center" do |*params|
|
28
28
|
let(:centered_object) { described_class.new(app, parent, left, top, width, height, *params, center: true) }
|
29
29
|
it "should now be located somewhere" do
|
30
|
-
expect(centered_object.left).to eq(left-(width/2))
|
31
|
-
expect(centered_object.top).to eq(top-(height/2))
|
30
|
+
expect(centered_object.left).to eq(left - (width / 2))
|
31
|
+
expect(centered_object.top).to eq(top - (height / 2))
|
32
32
|
expect(centered_object.width).to eq(width)
|
33
33
|
expect(centered_object.height).to eq(height)
|
34
34
|
end
|
@@ -8,7 +8,7 @@
|
|
8
8
|
shared_examples "DSL container" do
|
9
9
|
let(:dsl) { app }
|
10
10
|
|
11
|
-
%w
|
11
|
+
%w(
|
12
12
|
animate
|
13
13
|
arc
|
14
14
|
background
|
@@ -36,7 +36,7 @@ shared_examples "DSL container" do
|
|
36
36
|
strokewidth
|
37
37
|
style
|
38
38
|
video
|
39
|
-
|
39
|
+
).each do |method|
|
40
40
|
include_examples "#{method} DSL method"
|
41
41
|
end
|
42
42
|
|
@@ -13,7 +13,7 @@ shared_examples_for "pattern DSL method" do
|
|
13
13
|
let(:pattern) { dsl.pattern honeydew..salmon }
|
14
14
|
|
15
15
|
it "returns a gradient" do
|
16
|
-
expect(pattern).to eq(dsl.gradient
|
16
|
+
expect(pattern).to eq(dsl.gradient(honeydew..salmon))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -28,7 +28,7 @@ shared_examples_for "pattern DSL method" do
|
|
28
28
|
let(:pattern) { dsl.pattern honeydew.hex..salmon.hex }
|
29
29
|
|
30
30
|
it "returns a gradient" do
|
31
|
-
expect(pattern).to eq(dsl.gradient
|
31
|
+
expect(pattern).to eq(dsl.gradient(honeydew..salmon))
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -18,11 +18,11 @@ shared_examples_for "rgb DSL method" do
|
|
18
18
|
|
19
19
|
describe "named color method" do
|
20
20
|
it "produces correct color" do
|
21
|
-
expect(dsl.cornflowerblue).to eq(Shoes::Color.new
|
21
|
+
expect(dsl.cornflowerblue).to eq(Shoes::Color.new(red, green, blue))
|
22
22
|
end
|
23
23
|
|
24
24
|
it "accepts alpha arg" do
|
25
|
-
expect(dsl.cornflowerblue(alpha)).to eq(Shoes::Color.new
|
25
|
+
expect(dsl.cornflowerblue(alpha)).to eq(Shoes::Color.new(red, green, blue, alpha))
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
shared_examples_for "shape DSL method" do
|
2
|
-
let(:shape)
|
3
|
-
dsl.shape
|
2
|
+
let(:shape) do
|
3
|
+
dsl.shape do
|
4
4
|
move_to 400, 300
|
5
5
|
line_to 400, 200
|
6
6
|
line_to 100, 100
|
7
7
|
line_to 400, 300
|
8
8
|
curve_to 100, 100, 20, 200, 120, 240
|
9
|
-
|
10
|
-
|
9
|
+
end
|
10
|
+
end
|
11
11
|
|
12
12
|
it "creates a Shoes::Shape" do
|
13
13
|
expect(shape).to be_an_instance_of(Shoes::Shape)
|
@@ -33,21 +33,25 @@ shared_examples_for "shape DSL method" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "can accept a left and top" do
|
36
|
-
left
|
36
|
+
left = 10
|
37
|
+
top = 20
|
37
38
|
shape = dsl.shape left, top
|
38
39
|
expect(shape.left).to eq(left)
|
39
40
|
expect(shape.top).to eq(top)
|
40
41
|
end
|
41
42
|
|
42
43
|
it "accepts left and top in styles" do
|
43
|
-
left
|
44
|
+
left = 10
|
45
|
+
top = 20
|
44
46
|
shape = dsl.shape left: left, top: top
|
45
47
|
expect(shape.left).to eq(left)
|
46
48
|
expect(shape.top).to eq(top)
|
47
49
|
end
|
48
50
|
|
49
51
|
it "can accept a left, top, and some styles" do
|
50
|
-
left
|
52
|
+
left = 10
|
53
|
+
top = 20
|
54
|
+
white = Shoes::COLORS.fetch(:white)
|
51
55
|
shape = dsl.shape left, top, stroke: white
|
52
56
|
expect(shape.left).to eq(left)
|
53
57
|
expect(shape.top).to eq(top)
|
@@ -8,33 +8,33 @@ shared_examples_for "star DSL method" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'instantiation' do
|
11
|
-
let(:left) {10}
|
12
|
-
let(:top) {20}
|
13
|
-
let(:points) {15}
|
14
|
-
let(:outer) {27}
|
15
|
-
let(:inner) {33}
|
16
|
-
let(:clickable) { proc {
|
11
|
+
let(:left) { 10 }
|
12
|
+
let(:top) { 20 }
|
13
|
+
let(:points) { 15 }
|
14
|
+
let(:outer) { 27 }
|
15
|
+
let(:inner) { 33 }
|
16
|
+
let(:clickable) { proc {} }
|
17
17
|
|
18
18
|
DEFAULT_POINTS = 10
|
19
19
|
DEFAULT_OUTER = 100.0
|
20
20
|
DEFAULT_INNER = 50.0
|
21
21
|
|
22
22
|
describe '2 arguments' do
|
23
|
-
subject {dsl.star left, top}
|
24
|
-
its(:left) {should eq left}
|
25
|
-
its(:top) {should eq top}
|
26
|
-
its(:points) {should eq DEFAULT_POINTS}
|
27
|
-
its(:outer) {should eq DEFAULT_OUTER}
|
28
|
-
its(:inner) {should eq DEFAULT_INNER}
|
23
|
+
subject { dsl.star left, top }
|
24
|
+
its(:left) { should eq left }
|
25
|
+
its(:top) { should eq top }
|
26
|
+
its(:points) { should eq DEFAULT_POINTS }
|
27
|
+
its(:outer) { should eq DEFAULT_OUTER }
|
28
|
+
its(:inner) { should eq DEFAULT_INNER }
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '2 arguments with hash' do
|
32
32
|
subject { dsl.star left, top, click: clickable }
|
33
|
-
its(:left) {should eq left}
|
34
|
-
its(:top) {should eq top}
|
35
|
-
its(:points) {should eq DEFAULT_POINTS}
|
36
|
-
its(:outer) {should eq DEFAULT_OUTER}
|
37
|
-
its(:inner) {should eq DEFAULT_INNER}
|
33
|
+
its(:left) { should eq left }
|
34
|
+
its(:top) { should eq top }
|
35
|
+
its(:points) { should eq DEFAULT_POINTS }
|
36
|
+
its(:outer) { should eq DEFAULT_OUTER }
|
37
|
+
its(:inner) { should eq DEFAULT_INNER }
|
38
38
|
|
39
39
|
it "gets the click" do
|
40
40
|
expect(subject.style[:click]).to eq(clickable)
|
@@ -43,11 +43,11 @@ shared_examples_for "star DSL method" do
|
|
43
43
|
|
44
44
|
describe '3 arguments with hash' do
|
45
45
|
subject { dsl.star left, top, points, click: clickable }
|
46
|
-
its(:left) {should eq left}
|
47
|
-
its(:top) {should eq top}
|
48
|
-
its(:points) {should eq points}
|
49
|
-
its(:outer) {should eq DEFAULT_OUTER}
|
50
|
-
its(:inner) {should eq DEFAULT_INNER}
|
46
|
+
its(:left) { should eq left }
|
47
|
+
its(:top) { should eq top }
|
48
|
+
its(:points) { should eq points }
|
49
|
+
its(:outer) { should eq DEFAULT_OUTER }
|
50
|
+
its(:inner) { should eq DEFAULT_INNER }
|
51
51
|
|
52
52
|
it "gets the click" do
|
53
53
|
expect(subject.style[:click]).to eq(clickable)
|
@@ -55,21 +55,21 @@ shared_examples_for "star DSL method" do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe '4 arguments' do
|
58
|
-
subject {dsl.star left, top, points, outer}
|
59
|
-
its(:left) {should eq left}
|
60
|
-
its(:top) {should eq top}
|
61
|
-
its(:points) {should eq points}
|
62
|
-
its(:outer) {should eq outer}
|
63
|
-
its(:inner) {should eq DEFAULT_INNER}
|
58
|
+
subject { dsl.star left, top, points, outer }
|
59
|
+
its(:left) { should eq left }
|
60
|
+
its(:top) { should eq top }
|
61
|
+
its(:points) { should eq points }
|
62
|
+
its(:outer) { should eq outer }
|
63
|
+
its(:inner) { should eq DEFAULT_INNER }
|
64
64
|
end
|
65
65
|
|
66
66
|
describe '4 arguments with hash' do
|
67
67
|
subject { dsl.star left, top, points, outer, click: clickable }
|
68
|
-
its(:left) {should eq left}
|
69
|
-
its(:top) {should eq top}
|
70
|
-
its(:points) {should eq points}
|
71
|
-
its(:outer) {should eq outer}
|
72
|
-
its(:inner) {should eq DEFAULT_INNER}
|
68
|
+
its(:left) { should eq left }
|
69
|
+
its(:top) { should eq top }
|
70
|
+
its(:points) { should eq points }
|
71
|
+
its(:outer) { should eq outer }
|
72
|
+
its(:inner) { should eq DEFAULT_INNER }
|
73
73
|
|
74
74
|
it "gets the click" do
|
75
75
|
expect(subject.style[:click]).to eq(clickable)
|
@@ -77,21 +77,21 @@ shared_examples_for "star DSL method" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe '5 arguments' do
|
80
|
-
subject {dsl.star left, top, points, outer, inner}
|
81
|
-
its(:left) {should eq left}
|
82
|
-
its(:top) {should eq top}
|
83
|
-
its(:points) {should eq points}
|
84
|
-
its(:outer) {should eq outer}
|
85
|
-
its(:inner) {should eq inner}
|
80
|
+
subject { dsl.star left, top, points, outer, inner }
|
81
|
+
its(:left) { should eq left }
|
82
|
+
its(:top) { should eq top }
|
83
|
+
its(:points) { should eq points }
|
84
|
+
its(:outer) { should eq outer }
|
85
|
+
its(:inner) { should eq inner }
|
86
86
|
end
|
87
87
|
|
88
88
|
describe '5 arguments with hash' do
|
89
89
|
subject { dsl.star left, top, points, outer, inner, click: clickable }
|
90
|
-
its(:left) {should eq left}
|
91
|
-
its(:top) {should eq top}
|
92
|
-
its(:points) {should eq points}
|
93
|
-
its(:outer) {should eq outer}
|
94
|
-
its(:inner) {should eq inner}
|
90
|
+
its(:left) { should eq left }
|
91
|
+
its(:top) { should eq top }
|
92
|
+
its(:points) { should eq points }
|
93
|
+
its(:outer) { should eq outer }
|
94
|
+
its(:inner) { should eq inner }
|
95
95
|
|
96
96
|
it "gets the click" do
|
97
97
|
expect(subject.style[:click]).to eq(clickable)
|
@@ -3,7 +3,7 @@ shared_examples_for "style DSL method" do
|
|
3
3
|
let(:stroke) { Shoes::COLORS[:chartreuse] }
|
4
4
|
let(:size) { 42 }
|
5
5
|
let(:fill) { Shoes::COLORS[:peru] }
|
6
|
-
let(:font)
|
6
|
+
let(:font) { "SOME FONT" }
|
7
7
|
let(:style) { {stroke: stroke, size: size, fill: fill, font: font} }
|
8
8
|
|
9
9
|
%w(Banner Title Subtitle Tagline Caption Para Inscription).each do |text_block|
|
@@ -35,23 +35,26 @@ shared_examples_for "text element DSL methods" do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe 'span' do
|
38
|
+
let(:link_array) { [dsl.link('foo'), dsl.link('foo')] }
|
39
|
+
|
38
40
|
it 'should parse the color' do
|
39
41
|
span = dsl.span 'Hello', stroke: '#ccc'
|
40
42
|
expect(span.style[:stroke]).to eq Shoes::Color.new 204, 204, 204
|
41
43
|
end
|
42
44
|
|
43
45
|
it 'should handle a splatted array of links' do
|
44
|
-
expect {dsl.span(*
|
46
|
+
expect { dsl.span(*link_array) }.not_to raise_error
|
45
47
|
end
|
46
48
|
|
47
49
|
it 'should handle a splatted array of links and parse the color' do
|
48
|
-
span = dsl.span(*
|
50
|
+
span = dsl.span(*link_array, stroke: '#ccc')
|
49
51
|
expect(span.style[:stroke]).to eq Shoes::Color.new 204, 204, 204
|
50
52
|
end
|
51
53
|
|
52
54
|
it 'should handle a splatted array of links with a block' do
|
53
55
|
link = dsl.link('foo') { "Bar" }
|
54
|
-
|
56
|
+
array = [link, link]
|
57
|
+
expect { dsl.span(*array) }.not_to raise_error
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
@@ -1,10 +1,11 @@
|
|
1
1
|
shared_context "dsl app" do
|
2
|
-
let(:input_block) {
|
2
|
+
let(:input_block) { proc {} }
|
3
3
|
let(:input_opts) { Hash.new }
|
4
4
|
let(:user_facing_app) { Shoes::App.new input_opts, &input_block }
|
5
5
|
let(:app) { user_facing_app.instance_variable_get(:@__app__) }
|
6
|
-
let(:parent)
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
let(:parent) do
|
7
|
+
Shoes::Flow.new app, app,
|
8
|
+
width: Shoes::InternalApp::DEFAULT_OPTIONS[:width],
|
9
|
+
height: Shoes::InternalApp::DEFAULT_OPTIONS[:height]
|
10
|
+
end
|
10
11
|
end
|
@@ -6,12 +6,12 @@ shared_examples "object with hover" do
|
|
6
6
|
|
7
7
|
it "registers hover" do
|
8
8
|
expect(subject).to receive(:add_mouse_hover_control)
|
9
|
-
subject.hover {
|
9
|
+
subject.hover {}
|
10
10
|
end
|
11
11
|
|
12
12
|
it "registers with leave" do
|
13
13
|
expect(subject).to receive(:add_mouse_hover_control)
|
14
|
-
subject.leave {
|
14
|
+
subject.leave {}
|
15
15
|
end
|
16
16
|
|
17
17
|
it "marks itself as hovered" do
|
@@ -24,7 +24,7 @@ shared_examples_for "object with stroke" do
|
|
24
24
|
|
25
25
|
# Be sure the subject does *not* have the stroke set previously
|
26
26
|
specify "defaults to black" do
|
27
|
-
expect(subject.stroke).to eq(Shoes::COLORS.fetch
|
27
|
+
expect(subject.stroke).to eq(Shoes::COLORS.fetch(:black))
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "strokewidth" do
|
@@ -55,6 +55,6 @@ shared_examples_for "object with fill" do
|
|
55
55
|
|
56
56
|
# Be sure the subject does *not* have the stroke set previously
|
57
57
|
specify "defaults to black" do
|
58
|
-
expect(subject.fill).to eq(Shoes::COLORS.fetch
|
58
|
+
expect(subject.fill).to eq(Shoes::COLORS.fetch(:black))
|
59
59
|
end
|
60
60
|
end
|
@@ -2,7 +2,7 @@ shared_examples_for "Slot" do
|
|
2
2
|
it "should be able to append" do
|
3
3
|
expect(subject.contents).to be_empty
|
4
4
|
our_subject = subject
|
5
|
-
app.execute_block
|
5
|
+
app.execute_block proc { our_subject.append { para "foo" } }
|
6
6
|
expect(subject.contents.size).to eq(1)
|
7
7
|
end
|
8
8
|
|
@@ -21,8 +21,8 @@ shared_examples_for "Slot" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
shared_context 'one slot child' do
|
24
|
-
let(:ele_opts) {Hash.new}
|
25
|
-
let(:element) {Shoes::FakeElement.new(nil, {height: 100,width: 50}.merge(ele_opts))}
|
24
|
+
let(:ele_opts) { Hash.new }
|
25
|
+
let(:element) { Shoes::FakeElement.new(nil, {height: 100, width: 50}.merge(ele_opts)) }
|
26
26
|
|
27
27
|
before :each do
|
28
28
|
subject.add_child element
|
@@ -31,7 +31,7 @@ end
|
|
31
31
|
|
32
32
|
shared_context 'two slot children' do
|
33
33
|
include_context 'one slot child'
|
34
|
-
let(:element2) {Shoes::FakeElement.new nil, height: 200, width: 70}
|
34
|
+
let(:element2) { Shoes::FakeElement.new nil, height: 200, width: 70 }
|
35
35
|
|
36
36
|
before :each do
|
37
37
|
subject.add_child element2
|
@@ -39,7 +39,7 @@ shared_context 'two slot children' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
shared_context 'hidden child' do
|
42
|
-
let(:hidden_element) {Shoes::FakeElement.new nil, height: 200, width: 70}
|
42
|
+
let(:hidden_element) { Shoes::FakeElement.new nil, height: 200, width: 70 }
|
43
43
|
|
44
44
|
before :each do
|
45
45
|
subject.add_child hidden_element
|
@@ -50,7 +50,7 @@ end
|
|
50
50
|
|
51
51
|
shared_context 'three slot children' do
|
52
52
|
include_context 'two slot children'
|
53
|
-
let(:element3) {Shoes::FakeElement.new(nil, height: 50, width: 20)}
|
53
|
+
let(:element3) { Shoes::FakeElement.new(nil, height: 50, width: 20) }
|
54
54
|
|
55
55
|
before :each do
|
56
56
|
subject.add_child element3
|
@@ -64,33 +64,33 @@ shared_context 'contents_alignment' do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
shared_context 'element one with top and left' do
|
67
|
-
let(:ele_top) {22}
|
68
|
-
let(:ele_left) {47}
|
69
|
-
let(:ele_opts) {{left: ele_left, top: ele_top}}
|
67
|
+
let(:ele_top) { 22 }
|
68
|
+
let(:ele_left) { 47 }
|
69
|
+
let(:ele_opts) { {left: ele_left, top: ele_top} }
|
70
70
|
end
|
71
71
|
|
72
72
|
shared_context 'slot with set height and width' do
|
73
|
-
let(:input_opts) {{width: 250, height: 300}}
|
73
|
+
let(:input_opts) { {width: 250, height: 300} }
|
74
74
|
end
|
75
75
|
|
76
76
|
shared_context 'slot with a top margin' do
|
77
|
-
let(:margin_top) {70}
|
78
|
-
let(:input_opts) {{margin_top: margin_top}}
|
77
|
+
let(:margin_top) { 70 }
|
78
|
+
let(:input_opts) { {margin_top: margin_top} }
|
79
79
|
end
|
80
80
|
|
81
81
|
shared_context 'slot with a left margin' do
|
82
|
-
let(:margin_left) {30}
|
83
|
-
let(:input_opts) {{margin_left: margin_left}}
|
82
|
+
let(:margin_left) { 30 }
|
83
|
+
let(:input_opts) { {margin_left: margin_left} }
|
84
84
|
end
|
85
85
|
|
86
86
|
shared_context 'element one with bottom and right' do
|
87
|
-
let(:ele_bottom) {24}
|
88
|
-
let(:ele_right) {49}
|
89
|
-
let(:ele_opts) {{right: ele_right, bottom: ele_bottom}}
|
87
|
+
let(:ele_bottom) { 24 }
|
88
|
+
let(:ele_right) { 49 }
|
89
|
+
let(:ele_opts) { {right: ele_right, bottom: ele_bottom} }
|
90
90
|
end
|
91
91
|
|
92
92
|
shared_examples_for 'positioning through :_position' do
|
93
|
-
let(:element) {Shoes::FakeElement.new nil, height: 100, width: 50}
|
93
|
+
let(:element) { Shoes::FakeElement.new nil, height: 100, width: 50 }
|
94
94
|
|
95
95
|
def add_child_and_align
|
96
96
|
subject.add_child element
|
@@ -124,10 +124,21 @@ shared_examples_for 'positioning through :_position' do
|
|
124
124
|
|
125
125
|
it 'is resilient to exceptions during positioning' do
|
126
126
|
allow(element).to receive(:contents_alignment).and_raise("O_o")
|
127
|
-
allow(subject).to receive(:puts)
|
127
|
+
allow(subject).to receive(:puts) # Quiet, you
|
128
128
|
add_child_and_align
|
129
129
|
end
|
130
130
|
|
131
|
+
describe 'attached' do
|
132
|
+
let(:attached_to) { double('attached slot', absolute_left: 101, absolute_top: 101) }
|
133
|
+
let(:element) { Shoes::FakeElement.new nil }
|
134
|
+
|
135
|
+
it "gets positioned where it's attached" do
|
136
|
+
element.style[:attach] = attached_to
|
137
|
+
expect(element).to receive(:_position).with(101, 101).at_least(1)
|
138
|
+
add_child_and_align
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
131
142
|
describe 'absolute dimensions' do
|
132
143
|
let(:element) { Shoes::FakeAbsoluteElement.new }
|
133
144
|
|
@@ -256,7 +267,7 @@ shared_examples_for 'growing although relatively positioned elements' do
|
|
256
267
|
include_context 'contents_alignment'
|
257
268
|
|
258
269
|
describe 'positioned at the very beginning' do
|
259
|
-
let(:ele_opts) {{top: 0}}
|
270
|
+
let(:ele_opts) { {top: 0} }
|
260
271
|
|
261
272
|
it 'grows the slot height' do
|
262
273
|
expect(subject.height).to eq element.height
|
@@ -264,7 +275,7 @@ shared_examples_for 'growing although relatively positioned elements' do
|
|
264
275
|
end
|
265
276
|
|
266
277
|
describe 'positioned with a good offset' do
|
267
|
-
let(:ele_opts) {{top: 70}}
|
278
|
+
let(:ele_opts) { {top: 70} }
|
268
279
|
|
269
280
|
it 'grows the height even further' do
|
270
281
|
expect(subject.height).to eq element.height + 70
|