shoes-core 4.0.0.pre6 → 4.0.0.pre7
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/shoes/widget.rb
CHANGED
@@ -60,8 +60,8 @@ class Shoes
|
|
60
60
|
|
61
61
|
def self.dsl_method_name(klass)
|
62
62
|
klass.to_s[/(^|::)(\w+)$/, 2]
|
63
|
-
|
64
|
-
|
63
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
64
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/lib/shoes/window.rb
ADDED
data/spec/shoes/app_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::App do
|
4
|
-
let(:input_blk) {
|
4
|
+
let(:input_blk) { proc {} }
|
5
5
|
let(:opts) { Hash.new }
|
6
6
|
subject(:app) { Shoes::App.new(opts, &input_blk) }
|
7
7
|
|
@@ -20,7 +20,7 @@ describe Shoes::App do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "initialize" do
|
23
|
-
let(:input_blk) {
|
23
|
+
let(:input_blk) { proc {} }
|
24
24
|
|
25
25
|
it "initializes style hash", :qt do
|
26
26
|
style = Shoes::App.new.style
|
@@ -82,8 +82,8 @@ describe Shoes::App do
|
|
82
82
|
it 'initializes a flow with the right parameters' do
|
83
83
|
expect(Shoes::Flow).to receive(:new).with(anything, anything,
|
84
84
|
width: opts[:width],
|
85
|
-
height: opts[:height])
|
86
|
-
|
85
|
+
height: opts[:height])
|
86
|
+
.and_call_original
|
87
87
|
subject
|
88
88
|
end
|
89
89
|
end
|
@@ -117,7 +117,7 @@ describe Shoes::App do
|
|
117
117
|
default_styles = Shoes::Common::Style::DEFAULT_STYLES
|
118
118
|
|
119
119
|
default_styles.each do |key, value|
|
120
|
-
describe
|
120
|
+
describe key.to_s do
|
121
121
|
it "defaults to #{value}" do
|
122
122
|
expect(subject.style[key]).to eq(value)
|
123
123
|
end
|
@@ -200,13 +200,13 @@ describe Shoes::App do
|
|
200
200
|
describe 'Execution context' do
|
201
201
|
it 'starts with self as the execution context' do
|
202
202
|
my_self = nil
|
203
|
-
app = Shoes.app
|
203
|
+
app = Shoes.app { my_self = self }
|
204
204
|
expect(my_self).to eq app
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
208
|
describe '#append' do
|
209
|
-
let(:input_blk) {
|
209
|
+
let(:input_blk) { proc { append { para 'Hi' } } }
|
210
210
|
|
211
211
|
it 'understands append' do
|
212
212
|
expect(subject).to respond_to :append
|
@@ -260,11 +260,11 @@ describe Shoes::App do
|
|
260
260
|
|
261
261
|
describe '#clear' do
|
262
262
|
let(:input_blk) do
|
263
|
-
|
263
|
+
proc do
|
264
264
|
para 'Hello'
|
265
265
|
end
|
266
266
|
end
|
267
|
-
let(:internal_app) {subject.instance_variable_get(:@__app__)}
|
267
|
+
let(:internal_app) { subject.instance_variable_get(:@__app__) }
|
268
268
|
|
269
269
|
it 'has initial contents' do
|
270
270
|
expect(subject.contents).to_not be_empty
|
@@ -352,9 +352,9 @@ describe Shoes::App do
|
|
352
352
|
Shoes::App.subscribe_to_dsl_methods(self)
|
353
353
|
end
|
354
354
|
|
355
|
-
let(:subscribed_instance) {TestSubscribeClass.new subject}
|
355
|
+
let(:subscribed_instance) { TestSubscribeClass.new subject }
|
356
356
|
|
357
|
-
AUTO_SUBSCRIBED_CLASSES = [Shoes::App, Shoes::URL, Shoes::Widget]
|
357
|
+
AUTO_SUBSCRIBED_CLASSES = [Shoes::App, Shoes::URL, Shoes::Widget].freeze
|
358
358
|
SUBSCRIBED_CLASSES = AUTO_SUBSCRIBED_CLASSES + [TestSubscribeClass]
|
359
359
|
|
360
360
|
describe '.subscribe_to_dsl_methods' do
|
@@ -389,22 +389,22 @@ describe Shoes::App do
|
|
389
389
|
end
|
390
390
|
|
391
391
|
describe 'DELEGATE_METHODS' do
|
392
|
-
subject {Shoes::App::DELEGATE_METHODS}
|
392
|
+
subject { Shoes::App::DELEGATE_METHODS }
|
393
393
|
|
394
394
|
describe 'does not include general ruby object methods' do
|
395
|
-
it {is_expected.not_to include :new, :initialize}
|
395
|
+
it { is_expected.not_to include :new, :initialize }
|
396
396
|
end
|
397
397
|
|
398
398
|
describe 'it has access to Shoes app and DSL methods' do
|
399
|
-
it {is_expected.to include :para, :rect, :stack, :flow, :image, :location}
|
399
|
+
it { is_expected.to include :para, :rect, :stack, :flow, :image, :location }
|
400
400
|
end
|
401
401
|
|
402
402
|
describe 'it does not have access to private methods' do
|
403
|
-
it {is_expected.not_to include :pop_style, :style_normalizer, :create}
|
403
|
+
it { is_expected.not_to include :pop_style, :style_normalizer, :create }
|
404
404
|
end
|
405
405
|
|
406
406
|
describe 'there are blacklisted methods that wreck havoc' do
|
407
|
-
it {is_expected.not_to include :parent, :app}
|
407
|
+
it { is_expected.not_to include :parent, :app }
|
408
408
|
end
|
409
409
|
end
|
410
410
|
end
|
data/spec/shoes/arc_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Shoes::Arc do
|
|
23
23
|
it_behaves_like "object with parent"
|
24
24
|
it_behaves_like "object with hover"
|
25
25
|
|
26
|
-
#it_styles_with :art_styles, :center, :dimensions, :radius
|
26
|
+
# it_styles_with :art_styles, :center, :dimensions, :radius
|
27
27
|
|
28
28
|
it "is a Shoes::Arc" do
|
29
29
|
expect(arc.class).to be(Shoes::Arc)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Arrow do
|
4
|
+
include_context "dsl app"
|
5
|
+
|
6
|
+
let(:parent) { app }
|
7
|
+
let(:left) { 44 }
|
8
|
+
let(:top) { 66 }
|
9
|
+
let(:width) { 111 }
|
10
|
+
let(:height) { 111 }
|
11
|
+
subject(:arrow) { Shoes::Arrow.new(app, parent, left, top, width) }
|
12
|
+
|
13
|
+
describe '#style' do
|
14
|
+
it 'restyles handed in fill colors (even the weird ones)' do
|
15
|
+
subject.style fill: 'fff'
|
16
|
+
expect(subject.style[:fill]).to eq Shoes::Color.new 255, 255, 255
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it_behaves_like "object with style" do
|
21
|
+
let(:subject_without_style) { Shoes::Arrow.new(app, parent, left, top, width) }
|
22
|
+
let(:subject_with_style) { Shoes::Arrow.new(app, parent, left, top, width, arg_styles) }
|
23
|
+
end
|
24
|
+
it_behaves_like "object with dimensions"
|
25
|
+
it_behaves_like "movable object"
|
26
|
+
it_behaves_like 'object with parent'
|
27
|
+
it_behaves_like "object with hover"
|
28
|
+
end
|
@@ -8,7 +8,7 @@ describe Shoes::Background do
|
|
8
8
|
let(:width) { 100 }
|
9
9
|
let(:height) { 200 }
|
10
10
|
|
11
|
-
let(:blue)
|
11
|
+
let(:blue) { Shoes::COLORS[:blue] }
|
12
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
|
|
@@ -43,5 +43,5 @@ describe Shoes::Background do
|
|
43
43
|
it_behaves_like "object with negative dimensions"
|
44
44
|
end
|
45
45
|
|
46
|
-
it {is_expected.not_to be_takes_up_space}
|
46
|
+
it { is_expected.not_to be_takes_up_space }
|
47
47
|
end
|
data/spec/shoes/border_spec.rb
CHANGED
@@ -12,7 +12,7 @@ end
|
|
12
12
|
|
13
13
|
describe Shoes::Border do
|
14
14
|
include_context "dsl app"
|
15
|
-
let(:parent) { Shoes::FakeElement.new nil, left, top, width, height}
|
15
|
+
let(:parent) { Shoes::FakeElement.new nil, left, top, width, height }
|
16
16
|
let(:opts) { {left: left, top: top, width: width, height: height} }
|
17
17
|
|
18
18
|
let(:left) { 10 }
|
@@ -20,7 +20,7 @@ describe Shoes::Border do
|
|
20
20
|
let(:width) { 100 }
|
21
21
|
let(:height) { 200 }
|
22
22
|
|
23
|
-
let(:blue)
|
23
|
+
let(:blue) { Shoes::COLORS[:blue] }
|
24
24
|
|
25
25
|
subject { Shoes::Border.new(app, parent, blue, opts) }
|
26
26
|
|
@@ -42,5 +42,5 @@ describe Shoes::Border do
|
|
42
42
|
it_behaves_like "object with negative dimensions"
|
43
43
|
end
|
44
44
|
|
45
|
-
it {is_expected.not_to be_takes_up_space}
|
45
|
+
it { is_expected.not_to be_takes_up_space }
|
46
46
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::BuiltinMethods do
|
4
|
-
let(:input_blk) {
|
4
|
+
let(:input_blk) { proc {} }
|
5
5
|
let(:app) { Shoes::App.new({}, &input_blk) }
|
6
6
|
let(:logger) { double("logger") }
|
7
7
|
let(:dialog) { double('dialog') }
|
@@ -80,7 +80,7 @@ describe Shoes::BuiltinMethods do
|
|
80
80
|
|
81
81
|
%w(alert confirm).each do |type|
|
82
82
|
describe '##{alert}' do
|
83
|
-
|
83
|
+
let(:message) { double('message') }
|
84
84
|
|
85
85
|
before do
|
86
86
|
allow(Shoes::Dialog).to receive(:new).and_return(dialog)
|
data/spec/shoes/button_spec.rb
CHANGED
@@ -2,8 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shoes::Button do
|
4
4
|
include_context "dsl app"
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
let(:input_opts) do
|
7
|
+
{ left: left, top: top, width: width, height: height, margin: margin, state: "disabled" }
|
8
|
+
end
|
7
9
|
|
8
10
|
let(:left) { 13 }
|
9
11
|
let(:top) { 44 }
|
data/spec/shoes/color_spec.rb
CHANGED
@@ -30,22 +30,22 @@ describe Shoes::Color do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
context "with wrong number of arguments" do
|
33
|
-
subject {
|
33
|
+
subject { -> { Shoes::Color.new(10, 10) } }
|
34
34
|
it_behaves_like "color with bad arguments"
|
35
35
|
end
|
36
36
|
|
37
37
|
context "with too many hex chars" do
|
38
|
-
subject {
|
38
|
+
subject { -> { Shoes::Color.new("a1b2c3d") } }
|
39
39
|
it_behaves_like "color with bad arguments"
|
40
40
|
end
|
41
41
|
|
42
42
|
context "with too few hex chars" do
|
43
|
-
subject {
|
43
|
+
subject { -> { Shoes::Color.new("a1") } }
|
44
44
|
it_behaves_like "color with bad arguments"
|
45
45
|
end
|
46
46
|
|
47
47
|
context "with invalid hex chars" do
|
48
|
-
subject {
|
48
|
+
subject { -> { Shoes::Color.new("#g01234") } }
|
49
49
|
it_behaves_like "color with bad arguments"
|
50
50
|
end
|
51
51
|
|
@@ -212,8 +212,8 @@ describe Shoes::Color do
|
|
212
212
|
|
213
213
|
describe "comparable" do
|
214
214
|
let(:color1) { Shoes::Color.new(255, 69, 0) }
|
215
|
-
let(:red) {Shoes::Color.new 255, 0, 0}
|
216
|
-
let(:green) {Shoes::Color.new 0, 255, 0}
|
215
|
+
let(:red) { Shoes::Color.new 255, 0, 0 }
|
216
|
+
let(:green) { Shoes::Color.new 0, 255, 0 }
|
217
217
|
|
218
218
|
it "is equal when values are equal" do
|
219
219
|
color2 = Shoes::Color.new(255, 69, 0)
|
@@ -241,11 +241,11 @@ describe Shoes::Color do
|
|
241
241
|
# shoes 3 compatibility behavior
|
242
242
|
describe 'different colors' do
|
243
243
|
it 'takes the total of rgb values to compare, less is less' do
|
244
|
-
expect(create_rgb
|
244
|
+
expect(create_rgb(100, 200, 0)).to be < create_rgb(50, 100, 151)
|
245
245
|
end
|
246
246
|
|
247
247
|
it 'takes the total of rgb values to compare, more is more' do
|
248
|
-
expect(create_rgb
|
248
|
+
expect(create_rgb(0, 200, 200)).to be > create_rgb(150, 150, 99)
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
@@ -397,7 +397,7 @@ describe Shoes::Color::DSLHelpers do
|
|
397
397
|
include Shoes::Color::DSLHelpers
|
398
398
|
end
|
399
399
|
|
400
|
-
subject {ColorDSLHelperTest.new}
|
400
|
+
subject { ColorDSLHelperTest.new }
|
401
401
|
|
402
402
|
describe '#pattern' do
|
403
403
|
it 'creates an image pattern when fed a string for which a file exists' do
|
@@ -408,7 +408,7 @@ describe Shoes::Color::DSLHelpers do
|
|
408
408
|
end
|
409
409
|
|
410
410
|
it 'raises an argument error for bad input like a single number' do
|
411
|
-
expect {subject.pattern(1)}.to raise_error(ArgumentError)
|
411
|
+
expect { subject.pattern(1) }.to raise_error(ArgumentError)
|
412
412
|
end
|
413
413
|
|
414
414
|
it 'creates a gradient given 2 arguments' do
|
@@ -419,11 +419,11 @@ describe Shoes::Color::DSLHelpers do
|
|
419
419
|
|
420
420
|
describe '#gradient' do
|
421
421
|
it 'raises an argument error for no arguments supplied' do
|
422
|
-
expect {subject.gradient}.to raise_error ArgumentError
|
422
|
+
expect { subject.gradient }.to raise_error ArgumentError
|
423
423
|
end
|
424
424
|
|
425
425
|
it 'raises an argument error for too many (> 2) args supplied' do
|
426
|
-
expect {subject.gradient 1, 2, 3}.to raise_error ArgumentError
|
426
|
+
expect { subject.gradient 1, 2, 3 }.to raise_error ArgumentError
|
427
427
|
end
|
428
428
|
end
|
429
429
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Common::Attachable do
|
4
|
+
include_context "dsl app"
|
5
|
+
|
6
|
+
subject do
|
7
|
+
Class.new do
|
8
|
+
include Shoes::Common::Attachable
|
9
|
+
|
10
|
+
attr_reader :style
|
11
|
+
|
12
|
+
def initialize(app, attached_to)
|
13
|
+
@app = app
|
14
|
+
@style = { attach: attached_to }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:slot) { double('slot') }
|
20
|
+
|
21
|
+
it "isn't attached" do
|
22
|
+
expect(subject.new(app, nil).attached_to).to eq(nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "attaches" do
|
26
|
+
expect(subject.new(app, slot).attached_to).to eq(slot)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "attaches to Shoes::Window" do
|
30
|
+
expect(subject.new(app, Shoes::Window).attached_to).to eq(app.top_slot)
|
31
|
+
end
|
32
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "Shoes::Common::Inspect" do
|
4
|
-
let(:test_class)
|
5
|
-
Class.new
|
4
|
+
let(:test_class) do
|
5
|
+
Class.new do
|
6
6
|
include Shoes::Common::Inspect
|
7
7
|
def self.name
|
8
8
|
"Shoes::InspectableObject"
|
9
9
|
end
|
10
|
-
|
11
|
-
|
10
|
+
end
|
11
|
+
end
|
12
12
|
|
13
13
|
describe "when included" do
|
14
14
|
include InspectHelpers
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Common::Remove do
|
4
|
-
let(:parent) {double 'parent', add_child: true, remove_child: true}
|
5
|
-
let(:gui) {double 'gui', remove: true}
|
6
|
-
let(:test_class) {Class.new {include Shoes::Common::Remove}}
|
4
|
+
let(:parent) { double 'parent', add_child: true, remove_child: true }
|
5
|
+
let(:gui) { double 'gui', remove: true }
|
6
|
+
let(:test_class) { Class.new { include Shoes::Common::Remove } }
|
7
7
|
|
8
|
-
subject {test_class.new}
|
8
|
+
subject { test_class.new }
|
9
9
|
|
10
10
|
before :each do
|
11
11
|
allow(subject).to receive_messages parent: parent, gui: gui
|
@@ -27,7 +27,7 @@ describe Shoes::Common::Remove do
|
|
27
27
|
describe 'if the gui does not respond to clear' do
|
28
28
|
# need to stub clear and respond_to because we get a non stubbed method
|
29
29
|
# otherwise on our spies when verifying...
|
30
|
-
let(:gui) {double 'no clear gui', clear: true, respond_to?: false}
|
30
|
+
let(:gui) { double 'no clear gui', clear: true, respond_to?: false }
|
31
31
|
|
32
32
|
it 'does not call clear on the gui' do
|
33
33
|
expect(gui).not_to have_received(:clear)
|
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Common::StyleNormalizer do
|
4
|
-
subject {Shoes::Common::StyleNormalizer.new}
|
4
|
+
subject { Shoes::Common::StyleNormalizer.new }
|
5
5
|
|
6
6
|
it 'does not modify a simple hash' do
|
7
7
|
input = {left: 100, width: 233}
|
8
|
-
expect(subject.normalize
|
8
|
+
expect(subject.normalize(input)).to eq input
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'turns hexcodes for fill into colors' do
|
12
12
|
input = {fill: 'ffffff'}
|
13
13
|
expected = {fill: Shoes::Color.new(255, 255, 255)}
|
14
|
-
expect(subject.normalize
|
14
|
+
expect(subject.normalize(input)).to eq expected
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'turns hexcodes for stroke into colors' do
|
18
18
|
input = {stroke: 'ffffff'}
|
19
19
|
expected = {stroke: Shoes::Color.new(255, 255, 255)}
|
20
|
-
expect(subject.normalize
|
20
|
+
expect(subject.normalize(input)).to eq expected
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'does not modify the original hash' do
|
@@ -13,10 +13,10 @@ describe Shoes::Common::Style do
|
|
13
13
|
attr_reader :app, :dimensions
|
14
14
|
style_with :key, :left, :click, :strokewidth, :fill
|
15
15
|
|
16
|
-
STYLES = {fill: Shoes::COLORS[:blue]}
|
16
|
+
STYLES = { fill: Shoes::COLORS[:blue] }.freeze
|
17
17
|
|
18
18
|
def initialize(app, styles = {})
|
19
|
-
@app = app #needed for style init
|
19
|
+
@app = app # needed for style init
|
20
20
|
@dimensions = Shoes::Dimensions.new(@app, left: 15)
|
21
21
|
|
22
22
|
# Would normally be done by Common::Initialization
|
@@ -36,14 +36,18 @@ describe Shoes::Common::Style do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
subject {StyleTester.new(app)}
|
39
|
+
subject { StyleTester.new(app) }
|
40
40
|
|
41
41
|
its(:style) { should eq(initial_style) }
|
42
|
-
let(:initial_style)
|
43
|
-
|
42
|
+
let(:initial_style) do
|
43
|
+
{
|
44
|
+
key: 'value', left: 15, click: nil, strokewidth: 1, fill: blue, margin: [0, 0, 0, 0],
|
45
|
+
margin_left: 0, margin_top: 0, margin_right: 0, margin_bottom: 0
|
46
|
+
}
|
47
|
+
end
|
44
48
|
|
45
49
|
describe 'reading and writing through #style(hash)' do
|
46
|
-
let(:input_proc) {
|
50
|
+
let(:input_proc) { proc {} }
|
47
51
|
let(:changed_style) { {key: 'changed value'} }
|
48
52
|
|
49
53
|
before :each do
|
@@ -138,7 +142,7 @@ describe Shoes::Common::Style do
|
|
138
142
|
end
|
139
143
|
|
140
144
|
describe "style priorities" do
|
141
|
-
subject {StyleTester.new(app, key: 'pumpkin')}
|
145
|
+
subject { StyleTester.new(app, key: 'pumpkin') }
|
142
146
|
let(:green) { Shoes::COLORS[:green] }
|
143
147
|
|
144
148
|
it 'uses arguments-styles over element-styles' do
|
@@ -150,7 +154,7 @@ describe Shoes::Common::Style do
|
|
150
154
|
end
|
151
155
|
|
152
156
|
describe "with app level styles applied" do
|
153
|
-
let(:app) { Shoes::App.new}
|
157
|
+
let(:app) { Shoes::App.new }
|
154
158
|
|
155
159
|
it "should override class level defaults with app level styles provided those app styles are supported by the class" do
|
156
160
|
app.style(fill: green)
|
@@ -164,7 +168,7 @@ describe Shoes::Common::Style do
|
|
164
168
|
end
|
165
169
|
end
|
166
170
|
|
167
|
-
#related priority specs are tested individually in spec/shared_examples/style
|
171
|
+
# related priority specs are tested individually in spec/shared_examples/style
|
168
172
|
end
|
169
173
|
|
170
174
|
describe 'StyleWith' do
|
@@ -182,8 +186,8 @@ describe Shoes::Common::Style do
|
|
182
186
|
end
|
183
187
|
|
184
188
|
describe 'sets hover and leave from styles' do
|
185
|
-
let(:hover_blk) {
|
186
|
-
let(:leave_blk) {
|
189
|
+
let(:hover_blk) { proc {} }
|
190
|
+
let(:leave_blk) { proc {} }
|
187
191
|
|
188
192
|
subject { StyleTester.new(app, hover: hover_blk, leave: leave_blk) }
|
189
193
|
|