shoes-core 4.0.0.pre4 → 4.0.0.pre5
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/Guardfile +5 -0
- data/bin/shoes +1 -1
- data/bin/shoes-stub +1 -1
- data/ext/install/Rakefile +15 -5
- data/ext/install/shoes.bat +1 -1
- data/lib/shoes/animation.rb +2 -2
- data/lib/shoes/arc.rb +1 -0
- data/lib/shoes/builtin_methods.rb +5 -18
- data/lib/shoes/button.rb +1 -5
- data/lib/shoes/check_button.rb +1 -5
- data/lib/shoes/color.rb +5 -274
- data/lib/shoes/color/dsl.rb +166 -0
- data/lib/shoes/color/dsl_helpers.rb +84 -0
- data/lib/shoes/color/hex_converter.rb +32 -0
- data/lib/shoes/common/background_element.rb +5 -0
- data/lib/shoes/common/hover.rb +87 -0
- data/lib/shoes/common/initialization.rb +21 -8
- data/lib/shoes/common/remove.rb +2 -0
- data/lib/shoes/common/state.rb +17 -3
- data/lib/shoes/common/style.rb +8 -0
- data/lib/shoes/configuration.rb +18 -15
- data/lib/shoes/core/version.rb +1 -1
- data/lib/shoes/dimension.rb +6 -19
- data/lib/shoes/dimensions.rb +8 -0
- data/lib/shoes/download.rb +5 -3
- data/lib/shoes/dsl.rb +3 -3
- data/lib/shoes/image.rb +1 -0
- data/lib/shoes/image_pattern.rb +1 -1
- data/lib/shoes/input_box.rb +2 -5
- data/lib/shoes/internal_app.rb +13 -2
- data/lib/shoes/line.rb +1 -0
- data/lib/shoes/link.rb +8 -0
- data/lib/shoes/list_box.rb +2 -5
- data/lib/shoes/mock/check.rb +3 -0
- data/lib/shoes/mock/image.rb +6 -0
- data/lib/shoes/mock/progress.rb +6 -0
- data/lib/shoes/mock/radio.rb +3 -0
- data/lib/shoes/mock/sound.rb +1 -1
- data/lib/shoes/oval.rb +1 -0
- data/lib/shoes/packager.rb +1 -1
- data/lib/shoes/rect.rb +1 -0
- data/lib/shoes/shape.rb +4 -0
- data/lib/shoes/slot.rb +75 -38
- data/lib/shoes/slot_contents.rb +4 -0
- data/lib/shoes/sound.rb +3 -2
- data/lib/shoes/star.rb +1 -0
- data/lib/shoes/text_block.rb +18 -2
- data/lib/shoes/text_block_dimensions.rb +19 -3
- data/lib/shoes/timer.rb +2 -2
- data/lib/shoes/ui/picker.rb +4 -4
- data/lib/shoes/version.rb +1 -1
- data/shoes-core.gemspec +1 -1
- data/spec/shoes/animation_spec.rb +2 -2
- data/spec/shoes/app_spec.rb +6 -17
- data/spec/shoes/arc_spec.rb +2 -1
- data/spec/shoes/background_spec.rb +2 -2
- data/spec/shoes/border_spec.rb +2 -2
- data/spec/shoes/builtin_methods_spec.rb +68 -56
- data/spec/shoes/button_spec.rb +3 -3
- data/spec/shoes/check_spec.rb +3 -2
- data/spec/shoes/color_spec.rb +9 -3
- data/spec/shoes/common/remove_spec.rb +0 -1
- data/spec/shoes/common/rotate_spec.rb +13 -0
- data/spec/shoes/common/style_spec.rb +12 -3
- data/spec/shoes/configuration_spec.rb +18 -3
- data/spec/shoes/constants_spec.rb +1 -0
- data/spec/shoes/dialog_spec.rb +1 -3
- data/spec/shoes/dimension_spec.rb +33 -24
- data/spec/shoes/dimensions_spec.rb +21 -31
- data/spec/shoes/download_spec.rb +14 -3
- data/spec/shoes/flow_spec.rb +6 -7
- data/spec/shoes/font_spec.rb +2 -3
- data/spec/shoes/framework_learning_spec.rb +1 -2
- data/spec/shoes/gradient_spec.rb +1 -2
- data/spec/shoes/helpers/fake_absolute_element.rb +30 -0
- data/spec/shoes/helpers/sample17_helper.rb +0 -1
- data/spec/shoes/image_spec.rb +2 -1
- data/spec/shoes/input_box_spec.rb +2 -2
- data/spec/shoes/integration_spec.rb +0 -1
- data/spec/shoes/internal_app_spec.rb +4 -5
- data/spec/shoes/keypress_spec.rb +1 -1
- data/spec/shoes/keyrelease_spec.rb +1 -2
- data/spec/shoes/line_spec.rb +3 -2
- data/spec/shoes/link_spec.rb +26 -6
- data/spec/shoes/list_box_spec.rb +2 -2
- data/spec/shoes/oval_spec.rb +2 -1
- data/spec/shoes/packager_spec.rb +1 -1
- data/spec/shoes/point_spec.rb +1 -1
- data/spec/shoes/progress_spec.rb +1 -1
- data/spec/shoes/radio_spec.rb +1 -1
- data/spec/shoes/rect_spec.rb +2 -1
- data/spec/shoes/renamed_delegate_spec.rb +0 -1
- data/spec/shoes/shape_spec.rb +1 -1
- data/spec/shoes/shared_examples/common_methods.rb +1 -1
- data/spec/shoes/shared_examples/dsl/animate.rb +1 -1
- data/spec/shoes/shared_examples/dsl/background.rb +2 -2
- data/spec/shoes/shared_examples/dsl/rgb.rb +4 -2
- data/spec/shoes/shared_examples/dsl/star.rb +0 -1
- data/spec/shoes/shared_examples/dsl/style.rb +1 -1
- data/spec/shoes/shared_examples/dsl/text_elements.rb +2 -2
- data/spec/shoes/shared_examples/dsl/video.rb +1 -1
- data/spec/shoes/shared_examples/dsl_app_context.rb +4 -1
- data/spec/shoes/shared_examples/hover.rb +78 -0
- data/spec/shoes/shared_examples/slot.rb +34 -4
- data/spec/shoes/shared_examples/state.rb +9 -2
- data/spec/shoes/shared_examples/style.rb +0 -5
- data/spec/shoes/slot_spec.rb +11 -38
- data/spec/shoes/sound_spec.rb +3 -2
- data/spec/shoes/span_spec.rb +2 -2
- data/spec/shoes/spec_helper.rb +1 -1
- data/spec/shoes/stack_spec.rb +6 -6
- data/spec/shoes/star_spec.rb +2 -1
- data/spec/shoes/text_block_dimensions_spec.rb +3 -4
- data/spec/shoes/text_block_spec.rb +16 -11
- data/spec/shoes/ui/picker_spec.rb +5 -6
- data/spec/shoes/url_spec.rb +1 -2
- data/spec/shoes/widget_spec.rb +11 -3
- data/spec/shoes_spec.rb +1 -4
- data/spec/spec_helper.rb +2 -1
- metadata +16 -9
- data/bin/shoes-guard +0 -8
- data/lib/shoes/link_hover.rb +0 -5
- data/spec/shoes/shared_examples/hover_leave.rb +0 -11
data/spec/shoes/arc_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Arc do
|
4
4
|
include_context "dsl app"
|
@@ -21,6 +21,7 @@ describe Shoes::Arc do
|
|
21
21
|
it_behaves_like "object with dimensions"
|
22
22
|
it_behaves_like "left, top as center", :start_angle, :end_angle
|
23
23
|
it_behaves_like "object with parent"
|
24
|
+
it_behaves_like "object with hover"
|
24
25
|
|
25
26
|
#it_styles_with :art_styles, :center, :dimensions, :radius
|
26
27
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Background do
|
4
4
|
include_context "dsl app"
|
@@ -9,7 +9,7 @@ describe Shoes::Background do
|
|
9
9
|
let(:height) { 200 }
|
10
10
|
|
11
11
|
let(:blue) { Shoes::COLORS[:blue] }
|
12
|
-
let(:input_opts){ {left: left, top: top, width: width, height: height, color: blue} }
|
12
|
+
let(:input_opts) { {left: left, top: top, width: width, height: height, color: blue} }
|
13
13
|
subject(:background) { Shoes::Background.new(app, parent, blue, input_opts) }
|
14
14
|
|
15
15
|
before do
|
data/spec/shoes/border_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
shared_examples_for "basic border" do
|
4
4
|
it "retains app" do
|
@@ -13,7 +13,7 @@ end
|
|
13
13
|
describe Shoes::Border do
|
14
14
|
include_context "dsl app"
|
15
15
|
let(:parent) { Shoes::FakeElement.new nil, left, top, width, height}
|
16
|
-
let(:opts){ {left: left, top: top, width: width, height: height} }
|
16
|
+
let(:opts) { {left: left, top: top, width: width, height: height} }
|
17
17
|
|
18
18
|
let(:left) { 10 }
|
19
19
|
let(:top) { 20 }
|
@@ -1,9 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::BuiltinMethods do
|
4
4
|
let(:input_blk) { Proc.new {} }
|
5
5
|
let(:app) { Shoes::App.new({}, &input_blk) }
|
6
6
|
let(:logger) { double("logger") }
|
7
|
+
let(:dialog) { double('dialog') }
|
7
8
|
|
8
9
|
before :each do
|
9
10
|
Shoes::LOG.clear
|
@@ -22,63 +23,33 @@ describe Shoes::BuiltinMethods do
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
it "sets Shoes::LOG" do
|
32
|
-
expect(Shoes::LOG).to eq([["info", "test"]])
|
33
|
-
end
|
34
|
-
|
35
|
-
it "sends message to logger" do
|
36
|
-
expect(logger).to have_received(:info)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "debug" do
|
41
|
-
before :each do
|
42
|
-
allow(logger).to receive(:debug)
|
43
|
-
app.debug("test")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets Shoes::LOG" do
|
47
|
-
expect(Shoes::LOG).to eq([["debug", "test"]])
|
48
|
-
end
|
49
|
-
|
50
|
-
it "sends message to logger" do
|
51
|
-
expect(logger).to have_received(:debug)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "warn" do
|
56
|
-
before :each do
|
57
|
-
allow(logger).to receive(:warn)
|
58
|
-
app.warn("test")
|
59
|
-
end
|
26
|
+
%w(info debug warn error).each do |level|
|
27
|
+
describe "##{level}" do
|
28
|
+
before :each do
|
29
|
+
allow(logger).to receive(level)
|
30
|
+
app.public_send(level, "test")
|
31
|
+
end
|
60
32
|
|
61
|
-
|
62
|
-
|
63
|
-
|
33
|
+
it 'sets Shoes::LOG' do
|
34
|
+
expect(Shoes::LOG).to eq([[level, 'test']])
|
35
|
+
end
|
64
36
|
|
65
|
-
|
66
|
-
|
37
|
+
it 'sends message to logger' do
|
38
|
+
expect(logger).to have_received(level)
|
39
|
+
end
|
67
40
|
end
|
68
41
|
end
|
69
42
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
it "sets Shoes::LOG" do
|
77
|
-
expect(Shoes::LOG).to eq([["error", "test"]])
|
78
|
-
end
|
43
|
+
%w(open_file save_file open_folder save_folder).each do |chooser_action|
|
44
|
+
describe "#ask_#{chooser_action}" do
|
45
|
+
before do
|
46
|
+
allow(Shoes::Dialog).to receive(:new).and_return(dialog)
|
47
|
+
expect(dialog).to receive(:dialog_chooser).and_return(dialog)
|
48
|
+
end
|
79
49
|
|
80
|
-
|
81
|
-
|
50
|
+
it 'creates a new chooser dialog' do
|
51
|
+
expect(app.public_send("ask_#{chooser_action}")).to eq(dialog)
|
52
|
+
end
|
82
53
|
end
|
83
54
|
end
|
84
55
|
|
@@ -86,9 +57,9 @@ describe Shoes::BuiltinMethods do
|
|
86
57
|
# elsewhere
|
87
58
|
describe 'are builtin methods are also available from Shoes' do
|
88
59
|
builtin_methods = [:alert, :ask, :ask_color, :ask_open_file, :ask_save_file,
|
89
|
-
|
90
|
-
|
91
|
-
|
60
|
+
:ask_open_folder, :ask_save_folder, :confirm, :color,
|
61
|
+
:debug, :error, :font, :gradient, :gray, :rgb, :info,
|
62
|
+
:pattern, :warn]
|
92
63
|
|
93
64
|
builtin_methods.each do |method|
|
94
65
|
it "responds to #{method}" do
|
@@ -96,7 +67,6 @@ describe Shoes::BuiltinMethods do
|
|
96
67
|
end
|
97
68
|
end
|
98
69
|
|
99
|
-
|
100
70
|
describe 'does not get to the nitty gritty helper_methods' do
|
101
71
|
helper_methods = [:image_file?, :image_pattern]
|
102
72
|
|
@@ -107,4 +77,46 @@ describe Shoes::BuiltinMethods do
|
|
107
77
|
end
|
108
78
|
end
|
109
79
|
end
|
80
|
+
|
81
|
+
%w(alert confirm).each do |type|
|
82
|
+
describe '##{alert}' do
|
83
|
+
let(:message) { double('message') }
|
84
|
+
|
85
|
+
before do
|
86
|
+
allow(Shoes::Dialog).to receive(:new).and_return(dialog)
|
87
|
+
expect(dialog).to receive(type).with(message).and_return(dialog)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'creates a new dialog' do
|
91
|
+
expect(app.public_send(type, message)).to eq(dialog)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#ask' do
|
97
|
+
let(:message) { double('message') }
|
98
|
+
let(:args) { double('args') }
|
99
|
+
|
100
|
+
before do
|
101
|
+
allow(Shoes::Dialog).to receive(:new).and_return(dialog)
|
102
|
+
expect(dialog).to receive(:ask).with(message, args).and_return(dialog)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'creates a new dialog' do
|
106
|
+
expect(app.ask(message, args)).to eq(dialog)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#ask_color' do
|
111
|
+
let(:title) { double('title') }
|
112
|
+
|
113
|
+
before do
|
114
|
+
allow(Shoes::Dialog).to receive(:new).and_return(dialog)
|
115
|
+
expect(dialog).to receive(:ask_color).with(title).and_return(dialog)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'creates a new dialog' do
|
119
|
+
expect(app.ask_color(title)).to eq(dialog)
|
120
|
+
end
|
121
|
+
end
|
110
122
|
end
|
data/spec/shoes/button_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Button do
|
4
4
|
include_context "dsl app"
|
5
|
-
let(:input_opts) { {:
|
6
|
-
:
|
5
|
+
let(:input_opts) { {left: left, top: top, width: width,
|
6
|
+
height: height, margin: margin, state: "disabled"} }
|
7
7
|
|
8
8
|
let(:left) { 13 }
|
9
9
|
let(:top) { 44 }
|
data/spec/shoes/check_spec.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Check do
|
4
4
|
include_context "dsl app"
|
5
5
|
|
6
|
+
let(:input_opts) { { width: 22, height: 22 } }
|
6
7
|
subject { Shoes::Check.new(app, parent, input_opts, input_block) }
|
7
8
|
|
8
9
|
it_behaves_like "checkable"
|
@@ -17,7 +18,7 @@ describe Shoes::Check do
|
|
17
18
|
let(:top) { 20 }
|
18
19
|
let(:width) { 100 }
|
19
20
|
let(:height) { 200 }
|
20
|
-
let(:input_opts){ {left: left, top: top, width: width, height: height} }
|
21
|
+
let(:input_opts) { {left: left, top: top, width: width, height: height} }
|
21
22
|
subject { Shoes::Check.new(app, parent, input_opts) }
|
22
23
|
|
23
24
|
it_behaves_like "object with dimensions"
|
data/spec/shoes/color_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Color do
|
4
4
|
describe ".create" do
|
@@ -277,6 +277,12 @@ describe "Shoes built-in colors" do
|
|
277
277
|
its(:papayawhip) { should eq(Shoes::Color.new(255, 239, 213)) }
|
278
278
|
its(:aquamarine) { should eq(Shoes::Color.new(127, 255, 212)) }
|
279
279
|
its(:tomato) { should eq(Shoes::Color.new(255, 99, 71)) }
|
280
|
+
|
281
|
+
# define colors spec here since this has the other custom colors?
|
282
|
+
it 'can use define_shoes_color to create built-in colors' do
|
283
|
+
Shoes::DSL.define_shoes_color(:test_color, 0, 1, 2)
|
284
|
+
expect(subject.test_color).to eq Shoes::Color.new(0, 1, 2)
|
285
|
+
end
|
280
286
|
end
|
281
287
|
|
282
288
|
describe "Shoes built in gray" do
|
@@ -413,11 +419,11 @@ describe Shoes::Color::DSLHelpers do
|
|
413
419
|
|
414
420
|
describe '#gradient' do
|
415
421
|
it 'raises an argument error for no arguments supplied' do
|
416
|
-
expect{subject.gradient}.to raise_error ArgumentError
|
422
|
+
expect {subject.gradient}.to raise_error ArgumentError
|
417
423
|
end
|
418
424
|
|
419
425
|
it 'raises an argument error for too many (> 2) args supplied' do
|
420
|
-
expect{subject.gradient 1, 2, 3}.to raise_error ArgumentError
|
426
|
+
expect {subject.gradient 1, 2, 3}.to raise_error ArgumentError
|
421
427
|
end
|
422
428
|
end
|
423
429
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Common::Rotate do
|
4
|
+
let(:test_class) { Class.new { include Shoes::Common::Rotate } }
|
5
|
+
|
6
|
+
subject {test_class.new}
|
7
|
+
|
8
|
+
describe '#needs_rotate?' do
|
9
|
+
it 'defaults to falsey value' do
|
10
|
+
expect(subject.needs_rotate?).to be_falsey
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -8,8 +8,9 @@ describe Shoes::Common::Style do
|
|
8
8
|
include Shoes::Common::Visibility
|
9
9
|
include Shoes::DimensionsDelegations
|
10
10
|
include Shoes::Common::Style
|
11
|
+
include Shoes::Common::Hover
|
11
12
|
|
12
|
-
attr_reader :dimensions
|
13
|
+
attr_reader :app, :dimensions
|
13
14
|
style_with :key, :left, :click, :strokewidth, :fill
|
14
15
|
|
15
16
|
STYLES = {fill: Shoes::COLORS[:blue]}
|
@@ -39,7 +40,7 @@ describe Shoes::Common::Style do
|
|
39
40
|
|
40
41
|
its(:style) { should eq(initial_style) }
|
41
42
|
let(:initial_style) { {key: 'value', left: 15, click: nil, strokewidth: 1, fill: blue,
|
42
|
-
|
43
|
+
margin: [0,0,0,0], margin_left: 0, margin_top: 0, margin_right: 0, margin_bottom: 0 } }
|
43
44
|
|
44
45
|
describe 'reading and writing through #style(hash)' do
|
45
46
|
let(:input_proc) { Proc.new {} }
|
@@ -178,7 +179,15 @@ describe Shoes::Common::Style do
|
|
178
179
|
expect(subject).to respond_to "#{style}="
|
179
180
|
end
|
180
181
|
end
|
181
|
-
|
182
182
|
end
|
183
183
|
|
184
|
+
describe 'sets hover and leave from styles' do
|
185
|
+
let(:hover_blk) { Proc.new {} }
|
186
|
+
let(:leave_blk) { Proc.new {} }
|
187
|
+
|
188
|
+
subject { StyleTester.new(app, hover: hover_blk, leave: leave_blk) }
|
189
|
+
|
190
|
+
its(:hover_blk) { should eq(hover_blk) }
|
191
|
+
its(:leave_blk) { should eq(leave_blk) }
|
192
|
+
end
|
184
193
|
end
|
@@ -18,18 +18,33 @@ describe Shoes::Configuration do
|
|
18
18
|
|
19
19
|
let(:dsl_object) { Shoes::Shape.new app, parent }
|
20
20
|
|
21
|
-
describe "#
|
21
|
+
describe "#backend_for" do
|
22
22
|
it "passes app.gui to backend" do
|
23
23
|
expect(Shoes.configuration.backend::Shape).to receive(:new).with(an_instance_of(Shoes::Shape), app.gui).and_call_original
|
24
24
|
dsl_object
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns shape backend object" do
|
28
|
-
expect(Shoes.
|
28
|
+
expect(Shoes.backend_for(dsl_object)).to be_instance_of(Shoes.configuration.backend::Shape)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "raises ArgumentError for a non-Shoes object" do
|
32
|
-
expect { Shoes.
|
32
|
+
expect { Shoes.backend_for(1..100) }.to raise_error(ArgumentError)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#backend_class' do
|
37
|
+
it 'returns the backend class for a dsl object' do
|
38
|
+
expect(Shoes.configuration.backend_class(dsl_object)).to eq(Shoes.configuration.backend::Shape)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns the backend class if fed with a class' do
|
42
|
+
expect(Shoes.configuration.backend_class(Shoes::Shape)).to eq(Shoes.configuration
|
43
|
+
.backend::Shape)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raises an error when fed with a non existant class' do
|
47
|
+
expect { Shoes.configuration.backend_class(Array) }.to raise_error(ArgumentError)
|
33
48
|
end
|
34
49
|
end
|
35
50
|
end
|
data/spec/shoes/dialog_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
# NOTE: This spec is sadly circumventing the integration specs since we couldn't
|
3
3
|
# figure out how to get rid of the alert - it stopped the running tests
|
4
4
|
|
5
5
|
main_object = self
|
6
6
|
|
7
7
|
describe Shoes::Dialog do
|
8
|
-
|
9
8
|
before :each do
|
10
9
|
@dialog = Shoes::Dialog.new
|
11
10
|
end
|
@@ -167,5 +166,4 @@ describe Shoes::Dialog do
|
|
167
166
|
expect(@app).to respond_to :ask_color
|
168
167
|
end
|
169
168
|
end
|
170
|
-
|
171
169
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Dimension do
|
4
|
-
|
5
4
|
subject {Shoes::Dimension.new parent_dimension}
|
6
5
|
let(:start) {10}
|
7
6
|
let(:extent) {21}
|
@@ -218,7 +217,6 @@ describe Shoes::Dimension do
|
|
218
217
|
end
|
219
218
|
|
220
219
|
describe '#margins' do
|
221
|
-
|
222
220
|
let(:margin_start) {11}
|
223
221
|
let(:margin_end) {17}
|
224
222
|
|
@@ -358,12 +356,9 @@ describe Shoes::Dimension do
|
|
358
356
|
before :each do
|
359
357
|
parent.start = parent_start
|
360
358
|
parent.extent = parent_extent
|
361
|
-
parent.margin_start = margin
|
362
|
-
parent.margin_end = margin
|
363
359
|
end
|
364
360
|
|
365
361
|
describe 'it takes some parent values if no values are set' do
|
366
|
-
its(:start) {should eq parent_start}
|
367
362
|
its(:extent) {should eq parent_extent}
|
368
363
|
|
369
364
|
its(:margin_start) {should eq 0}
|
@@ -372,22 +367,28 @@ describe Shoes::Dimension do
|
|
372
367
|
context 'with parent absolute_start set' do
|
373
368
|
before :each do
|
374
369
|
parent.absolute_start = 11
|
375
|
-
|
376
|
-
# This would be set by positioning code
|
377
|
-
subject.absolute_start = parent.absolute_start + margin
|
378
370
|
end
|
379
371
|
|
380
|
-
its(:absolute_start) {should eq parent.
|
381
|
-
its(:element_start) {should eq parent.
|
372
|
+
its(:absolute_start) {should eq parent.element_start}
|
373
|
+
its(:element_start) {should eq parent.element_start}
|
382
374
|
its(:element_end) {should eq parent.element_end}
|
383
375
|
end
|
376
|
+
|
377
|
+
context 'but it takes the parent margins into account' do
|
378
|
+
before :each do
|
379
|
+
parent.margin_start = margin
|
380
|
+
parent.margin_end = margin
|
381
|
+
end
|
382
|
+
|
383
|
+
its(:extent) {is_expected.to eq 17}
|
384
|
+
end
|
384
385
|
end
|
385
386
|
|
386
387
|
describe 'otherwise it takes its own values' do
|
387
388
|
before :each do
|
388
389
|
subject.start = start
|
389
390
|
subject.extent = extent
|
390
|
-
|
391
|
+
parent.absolute_start = 17
|
391
392
|
end
|
392
393
|
|
393
394
|
its(:start) {should eq start}
|
@@ -396,36 +397,44 @@ describe Shoes::Dimension do
|
|
396
397
|
|
397
398
|
it 'can still handle special values like a negative extent' do
|
398
399
|
subject.extent = -10
|
399
|
-
expect(subject.extent).to eq(
|
400
|
+
expect(subject.extent).to eq(parent.element_extent - 10)
|
400
401
|
end
|
401
402
|
|
402
403
|
it 'can also still handle special values like relative values' do
|
403
404
|
subject.extent = 0.8
|
404
405
|
expect(subject.extent).to be_within(ONE_PIXEL).of(0.8 * parent.element_extent)
|
405
406
|
end
|
407
|
+
|
408
|
+
it 'takes the margins of parent into account' do
|
409
|
+
parent.margin_start = 10
|
410
|
+
expect(subject.absolute_start).to eq 27
|
411
|
+
end
|
406
412
|
end
|
407
413
|
|
408
414
|
describe 'it obeys parent bounds' do
|
409
415
|
let(:parent_dimension) { double 'parent_dimension',
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
+
element_start: 10,
|
417
|
+
element_end: 20,
|
418
|
+
absolute_start: 10,
|
419
|
+
absolute_end: 20,
|
420
|
+
extent: 10,
|
421
|
+
element_extent: 10 }
|
416
422
|
|
417
423
|
subject {Shoes::ParentDimension.new parent_dimension}
|
418
424
|
|
419
|
-
it "
|
420
|
-
subject.
|
421
|
-
expect(subject.extent).to eq(6)
|
425
|
+
it "gets the parent element_extent" do
|
426
|
+
expect(subject.extent).to eq(10)
|
422
427
|
end
|
423
428
|
|
424
|
-
it "can't
|
425
|
-
subject.
|
429
|
+
it "can't extend beyond the parent" do
|
430
|
+
subject.extent = 25
|
426
431
|
expect(subject.extent).to eq(10)
|
427
432
|
end
|
433
|
+
|
434
|
+
it 'can get smaller than the parent' do
|
435
|
+
subject.extent = 5
|
436
|
+
expect(subject.extent).to eq(5)
|
437
|
+
end
|
428
438
|
end
|
429
439
|
end
|
430
|
-
|
431
440
|
end
|