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
data/spec/shoes/download_spec.rb
CHANGED
@@ -5,15 +5,15 @@ describe Shoes::Download do
|
|
5
5
|
|
6
6
|
let(:name) { "http://www.google.com/logos/nasa50th.gif" }
|
7
7
|
let(:response_body) { "NASA 50th logo" }
|
8
|
-
let(:response_status) {["200", "OK"]}
|
9
|
-
let(:response_headers) { { "content-length" => "42" }}
|
8
|
+
let(:response_status) { ["200", "OK"] }
|
9
|
+
let(:response_headers) { { "content-length" => "42" } }
|
10
10
|
let(:opts) { {save: "nasa50th.gif"} }
|
11
11
|
|
12
12
|
subject(:download) { Shoes::Download.new app, parent, name, opts, &input_block }
|
13
13
|
|
14
|
-
let(:percent) {download.percent}
|
15
|
-
let(:length) {download.length}
|
16
|
-
let(:content_length) {download.content_length}
|
14
|
+
let(:percent) { download.percent }
|
15
|
+
let(:length) { download.length }
|
16
|
+
let(:content_length) { download.content_length }
|
17
17
|
|
18
18
|
before do
|
19
19
|
expect(app.current_slot).to receive(:create_bound_block).at_least(1) { |blk| blk ? blk : nil }
|
@@ -64,9 +64,9 @@ describe Shoes::Download do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
context 'with a progress proc' do
|
67
|
-
let(:progress_proc) {
|
67
|
+
let(:progress_proc) { proc {} }
|
68
68
|
let(:opts) { {save: "nasa50th.gif", progress: progress_proc} }
|
69
|
-
subject(:download) {Shoes::Download.new app, parent, name, opts}
|
69
|
+
subject(:download) { Shoes::Download.new app, parent, name, opts }
|
70
70
|
|
71
71
|
before :each do
|
72
72
|
allow(download.gui).to receive :eval_block
|
@@ -76,9 +76,9 @@ describe Shoes::Download do
|
|
76
76
|
|
77
77
|
context 'with content length' do
|
78
78
|
it 'calls the progress proc from start, download and finish' do
|
79
|
-
expect(download.gui).to have_received(:eval_block)
|
80
|
-
|
81
|
-
|
79
|
+
expect(download.gui).to have_received(:eval_block)
|
80
|
+
.with(progress_proc, download)
|
81
|
+
.exactly(3).times
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -86,9 +86,9 @@ describe Shoes::Download do
|
|
86
86
|
let(:response_headers) { Hash.new }
|
87
87
|
|
88
88
|
it 'does not call on progress, but called from content length and finish' do
|
89
|
-
expect(download.gui).to have_received(:eval_block)
|
90
|
-
with(progress_proc, download)
|
91
|
-
twice
|
89
|
+
expect(download.gui).to have_received(:eval_block)
|
90
|
+
.with(progress_proc, download)
|
91
|
+
.twice
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'can call percent just fine thanks' do
|
@@ -98,8 +98,8 @@ describe Shoes::Download do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
describe 'after it is finished' do
|
101
|
-
let(:result) {download}
|
102
|
-
let(:response) {download.response}
|
101
|
+
let(:result) { download }
|
102
|
+
let(:response) { download.response }
|
103
103
|
|
104
104
|
before :each do
|
105
105
|
allow(download.gui).to receive(:eval_block)
|
@@ -136,7 +136,7 @@ describe Shoes::Download do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
context 'with a finish proc' do
|
139
|
-
let(:finish_proc) {
|
139
|
+
let(:finish_proc) { proc {} }
|
140
140
|
let(:opts) { {save: "nasa50th.gif", finish: finish_proc} }
|
141
141
|
subject(:download) { Shoes::Download.new app, parent, name, opts }
|
142
142
|
|
@@ -181,7 +181,7 @@ describe Shoes::Download do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
describe 'with custom error blocks' do
|
184
|
-
let(:error_proc) {
|
184
|
+
let(:error_proc) { proc {} }
|
185
185
|
let(:opts) { {save: "nasa50th.gif", error: error_proc} }
|
186
186
|
|
187
187
|
it 'gets called' do
|
data/spec/shoes/flow_spec.rb
CHANGED
@@ -65,7 +65,7 @@ describe Shoes::Flow do
|
|
65
65
|
it_behaves_like 'positioning in the same line'
|
66
66
|
|
67
67
|
describe 'exact fit' do
|
68
|
-
let(:input_opts) {{width: element.width + element2.width}}
|
68
|
+
let(:input_opts) { {width: element.width + element2.width} }
|
69
69
|
it_behaves_like 'positioning in the same line'
|
70
70
|
end
|
71
71
|
end
|
@@ -99,7 +99,7 @@ describe Shoes::Flow do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
describe 'with margins and two elements not fitting next to each other' do
|
102
|
-
let(:input_opts) {{ width: element.width + 10, margin: 27 }}
|
102
|
+
let(:input_opts) { { width: element.width + 10, margin: 27 } }
|
103
103
|
it_behaves_like 'taking care of margin'
|
104
104
|
end
|
105
105
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class Shoes
|
2
2
|
class FakeAbsoluteElement
|
3
|
+
include Common::Attachable
|
3
4
|
include Common::Inspect
|
4
|
-
include Common::Visibility
|
5
5
|
include Common::Positioning
|
6
6
|
include Common::Remove
|
7
|
+
include Common::Visibility
|
7
8
|
|
8
9
|
include Shoes::DimensionsDelegations
|
9
10
|
|
@@ -11,7 +12,7 @@ class Shoes
|
|
11
12
|
@dimensions = AbsoluteDimensions.new 0, 0, 100, 100
|
12
13
|
end
|
13
14
|
|
14
|
-
def add_child(
|
15
|
+
def add_child(_element)
|
15
16
|
true
|
16
17
|
end
|
17
18
|
|
@@ -1,11 +1,12 @@
|
|
1
1
|
class Shoes
|
2
2
|
class FakeElement < Dimensions
|
3
|
+
include Common::Attachable
|
3
4
|
include Common::Inspect
|
4
|
-
include Common::Visibility
|
5
5
|
include Common::Positioning
|
6
6
|
include Common::Remove
|
7
|
+
include Common::Visibility
|
7
8
|
|
8
|
-
def add_child(
|
9
|
+
def add_child(_element)
|
9
10
|
true
|
10
11
|
end
|
11
12
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shoes::InputBox do
|
4
4
|
include_context "dsl app"
|
5
|
-
let(:input_opts) {{left: left, top: top, width: width, height: height}}
|
5
|
+
let(:input_opts) { {left: left, top: top, width: width, height: height} }
|
6
6
|
let(:left) { 10 }
|
7
7
|
let(:top) { 20 }
|
8
8
|
let(:width) { 100 }
|
@@ -39,7 +39,7 @@ describe Shoes::InputBox do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe 'non string text' do
|
42
|
-
let(:text) {42}
|
42
|
+
let(:text) { 42 }
|
43
43
|
|
44
44
|
it 'is converted to a string (convenience + error in backend)' do
|
45
45
|
expect(subject.text).to eq '42'
|
@@ -66,7 +66,7 @@ describe Shoes::InternalApp do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
describe '#inspect' do
|
69
|
-
let(:input_opts) {{title: 'Dupa'}}
|
69
|
+
let(:input_opts) { {title: 'Dupa'} }
|
70
70
|
|
71
71
|
it 'shows the title in inspect' do
|
72
72
|
expect(subject.inspect).to include 'Dupa'
|
@@ -75,12 +75,12 @@ describe Shoes::InternalApp do
|
|
75
75
|
|
76
76
|
describe '#clear' do
|
77
77
|
context 'when called after the initial input block' do
|
78
|
-
let(:input_block)
|
79
|
-
|
78
|
+
let(:input_block) do
|
79
|
+
proc do
|
80
80
|
para "CONTENT"
|
81
81
|
para "JUST FOR TESTING"
|
82
82
|
end
|
83
|
-
|
83
|
+
end
|
84
84
|
|
85
85
|
before :each do
|
86
86
|
expect(subject.contents.size).to eq(2)
|
@@ -93,22 +93,22 @@ describe Shoes::InternalApp do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'when called in the initial input_block' do
|
96
|
-
let(:input_block)
|
97
|
-
|
96
|
+
let(:input_block) do
|
97
|
+
proc do
|
98
98
|
para 'Hello there'
|
99
99
|
clear do
|
100
100
|
para 'see you'
|
101
101
|
end
|
102
102
|
end
|
103
|
-
|
103
|
+
end
|
104
104
|
|
105
105
|
it 'does not raise an error' do
|
106
|
-
expect {subject}.not_to raise_error
|
106
|
+
expect { subject }.not_to raise_error
|
107
107
|
end
|
108
108
|
|
109
109
|
context 'when called inside a slot' do
|
110
|
-
let(:input_block)
|
111
|
-
|
110
|
+
let(:input_block) do
|
111
|
+
proc do
|
112
112
|
button 'I am here'
|
113
113
|
stack do
|
114
114
|
button 'Hi there'
|
@@ -116,7 +116,7 @@ describe Shoes::InternalApp do
|
|
116
116
|
clear
|
117
117
|
end
|
118
118
|
end
|
119
|
-
|
119
|
+
end
|
120
120
|
|
121
121
|
it 'does not delete the slot, or an element outside the slot' do
|
122
122
|
expect(subject.contents.size).to eq 2
|
@@ -125,12 +125,12 @@ describe Shoes::InternalApp do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
context 'when called before a button in an initial input block' do
|
128
|
-
let(:input_block)
|
129
|
-
|
128
|
+
let(:input_block) do
|
129
|
+
proc do
|
130
130
|
clear
|
131
131
|
button 'My Button'
|
132
132
|
end
|
133
|
-
|
133
|
+
end
|
134
134
|
|
135
135
|
it 'allows a button to be created' do
|
136
136
|
expect(subject.contents.size).to eq(1)
|
data/spec/shoes/link_spec.rb
CHANGED
@@ -4,24 +4,30 @@ describe Shoes::Link do
|
|
4
4
|
let(:gui) { double("gui").as_null_object }
|
5
5
|
let(:user_facing_app) { double("user facing app") }
|
6
6
|
let(:element_styles) { Hash.new }
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
let(:app) do
|
9
|
+
double("app", gui: gui, style: {}, element_styles: element_styles,
|
10
|
+
warn: true, add_mouse_hover_control: nil)
|
11
|
+
end
|
12
|
+
|
9
13
|
let(:parent) { double("parent") }
|
10
14
|
let(:internal_app) { double("internal app", app: app, gui: gui, style: {}, element_styles: {}) }
|
11
15
|
let(:texts) { ["text", "goes", "first"] }
|
16
|
+
let(:text_block) { double 'text block', visible?: true, hidden?: false }
|
12
17
|
|
13
|
-
subject
|
18
|
+
subject do
|
14
19
|
link = Shoes::Link.new(app, texts, color: :blue)
|
15
20
|
link.parent = parent
|
21
|
+
link.text_block = text_block
|
16
22
|
link
|
17
|
-
|
23
|
+
end
|
18
24
|
|
19
25
|
before do
|
20
26
|
allow(user_facing_app).to receive(:style) do |clazz, styles|
|
21
27
|
element_styles[clazz] = styles
|
22
28
|
end
|
23
29
|
|
24
|
-
allow(
|
30
|
+
allow(subject).to receive(:eval_hover_block) do |blk|
|
25
31
|
blk.call(subject) if blk
|
26
32
|
end
|
27
33
|
end
|
@@ -45,8 +51,9 @@ describe Shoes::Link do
|
|
45
51
|
end
|
46
52
|
|
47
53
|
context "overriding styles" do
|
48
|
-
subject
|
49
|
-
|
54
|
+
subject do
|
55
|
+
Shoes::Link.new(app, texts, underline: false, bg: Shoes::COLORS[:green])
|
56
|
+
end
|
50
57
|
|
51
58
|
it "should include defaults" do
|
52
59
|
expect(subject.style).to include(stroke: Shoes::COLORS[:blue])
|
@@ -63,7 +70,7 @@ describe Shoes::Link do
|
|
63
70
|
|
64
71
|
context "with a block" do
|
65
72
|
let(:callable) { double("callable") }
|
66
|
-
subject { Shoes::Link.new(internal_app, texts, {},
|
73
|
+
subject { Shoes::Link.new(internal_app, texts, {}, proc { callable.call }) }
|
67
74
|
|
68
75
|
it "sets up for the click" do
|
69
76
|
expect(callable).to receive(:call)
|
@@ -82,7 +89,7 @@ describe Shoes::Link do
|
|
82
89
|
|
83
90
|
context "with click option as Proc" do
|
84
91
|
let(:callable) { double("callable", call: nil) }
|
85
|
-
subject { Shoes::Link.new(internal_app, texts, click:
|
92
|
+
subject { Shoes::Link.new(internal_app, texts, click: proc { callable.call }) }
|
86
93
|
|
87
94
|
it "calls the block" do
|
88
95
|
expect(callable).to receive(:call)
|
@@ -106,13 +113,7 @@ describe Shoes::Link do
|
|
106
113
|
end
|
107
114
|
|
108
115
|
describe 'visibility' do
|
109
|
-
let(:text_block) {double 'text block', visible?: true, hidden?: false}
|
110
|
-
|
111
116
|
describe 'with a containing text block' do
|
112
|
-
before :each do
|
113
|
-
subject.text_block = text_block
|
114
|
-
end
|
115
|
-
|
116
117
|
it 'forwards #visible? calls' do
|
117
118
|
subject.visible?
|
118
119
|
expect(text_block).to have_received :visible?
|
@@ -126,19 +127,17 @@ describe Shoes::Link do
|
|
126
127
|
|
127
128
|
describe 'without a containing text block' do
|
128
129
|
it 'does not crash on #visibie?' do
|
129
|
-
expect {subject.visible?}.not_to raise_error
|
130
|
+
expect { subject.visible? }.not_to raise_error
|
130
131
|
end
|
131
132
|
|
132
133
|
it 'does not crash on #hidden?' do
|
133
|
-
expect {subject.hidden?}.not_to raise_error
|
134
|
+
expect { subject.hidden? }.not_to raise_error
|
134
135
|
end
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
138
139
|
# #979
|
139
140
|
describe 'containing text block' do
|
140
|
-
let(:text_block) {double 'text block'}
|
141
|
-
|
142
141
|
before :each do
|
143
142
|
subject.parent = text_block
|
144
143
|
end
|
data/spec/shoes/list_box_spec.rb
CHANGED
@@ -2,10 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shoes::ListBox do
|
4
4
|
include_context "dsl app"
|
5
|
-
let(:input_opts)
|
6
|
-
|
5
|
+
let(:input_opts) do
|
6
|
+
{ items: items, left: left, top: top, width: width, height: height }
|
7
|
+
end
|
7
8
|
|
8
|
-
let(:items) {["Wine", "Vodka", "Water"]}
|
9
|
+
let(:items) { ["Wine", "Vodka", "Water"] }
|
9
10
|
|
10
11
|
let(:left) { 10 }
|
11
12
|
let(:top) { 20 }
|
@@ -49,7 +50,7 @@ describe Shoes::ListBox do
|
|
49
50
|
|
50
51
|
it "updates the gui when self-modifying array methods like map! are called" do
|
51
52
|
expect(list_box.gui).to receive(:update_items)
|
52
|
-
list_box.items.map! {"replaced!"}
|
53
|
+
list_box.items.map! { "replaced!" }
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
@@ -59,8 +60,8 @@ describe Shoes::ListBox do
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def expect_gui_choose_with(string)
|
62
|
-
expect_any_instance_of(Shoes.configuration.backend::ListBox)
|
63
|
-
|
63
|
+
expect_any_instance_of(Shoes.configuration.backend::ListBox)
|
64
|
+
.to receive(:choose).with string
|
64
65
|
end
|
65
66
|
|
66
67
|
it "should call @gui.choose when we choose something" do
|
@@ -75,8 +76,8 @@ describe Shoes::ListBox do
|
|
75
76
|
end
|
76
77
|
|
77
78
|
it "should delegate #text to the backend" do
|
78
|
-
expect_any_instance_of(Shoes.configuration.backend::ListBox)
|
79
|
-
|
79
|
+
expect_any_instance_of(Shoes.configuration.backend::ListBox)
|
80
|
+
.to receive(:text).and_return("Sneakers & Sandals")
|
80
81
|
expect(list_box.text).to eq("Sneakers & Sandals")
|
81
82
|
end
|
82
83
|
|
data/spec/shoes/oval_spec.rb
CHANGED
data/spec/shoes/point_spec.rb
CHANGED
@@ -19,9 +19,9 @@ describe Shoes::Point do
|
|
19
19
|
|
20
20
|
describe "equality" do
|
21
21
|
it "requires x and y to be equal" do
|
22
|
-
expect(subject).to eq(Shoes::Point.new
|
23
|
-
expect(subject).not_to eq(Shoes::Point.new
|
24
|
-
expect(subject).not_to eq(Shoes::Point.new
|
22
|
+
expect(subject).to eq(Shoes::Point.new(40, 50))
|
23
|
+
expect(subject).not_to eq(Shoes::Point.new(41, 50))
|
24
|
+
expect(subject).not_to eq(Shoes::Point.new(40, 51))
|
25
25
|
end
|
26
26
|
|
27
27
|
it "works with other (x,y) objects" do
|
@@ -35,8 +35,8 @@ describe RenamedDelegate do
|
|
35
35
|
ToDelegate.public_instance_methods(false),
|
36
36
|
'key' => 'shoes', 'something' => 'awesome'
|
37
37
|
|
38
|
-
let(:delegate) {double('delegate').as_null_object}
|
39
|
-
subject {TestClass.new delegate}
|
38
|
+
let(:delegate) { double('delegate').as_null_object }
|
39
|
+
subject { TestClass.new delegate }
|
40
40
|
|
41
41
|
def test_renaming(new_name, old_name)
|
42
42
|
subject.public_send new_name
|
data/spec/shoes/shape_spec.rb
CHANGED
@@ -5,22 +5,22 @@ describe Shoes::Shape do
|
|
5
5
|
|
6
6
|
let(:left) { 0 }
|
7
7
|
let(:top) { 0 }
|
8
|
-
let(:style) { {left: left, top: top} }
|
9
|
-
let(:draw) {
|
8
|
+
let(:style) { {translate_left: 0, translate_top: 0, left: left, top: top} }
|
9
|
+
let(:draw) { proc {} }
|
10
10
|
|
11
11
|
subject { Shoes::Shape.new app, parent, style, draw }
|
12
12
|
|
13
13
|
it_behaves_like "object with style" do
|
14
14
|
let(:subject_without_style) { Shoes::Shape.new(app, parent) }
|
15
|
-
let(:subject_with_style) { Shoes::Shape.new(app, parent,
|
15
|
+
let(:subject_with_style) { Shoes::Shape.new(app, parent, arg_styles) }
|
16
16
|
end
|
17
17
|
|
18
18
|
it_behaves_like "movable object"
|
19
19
|
it_behaves_like "clickable object"
|
20
20
|
|
21
21
|
describe "octagon" do
|
22
|
-
let(:draw)
|
23
|
-
|
22
|
+
let(:draw) do
|
23
|
+
proc do
|
24
24
|
xs = [200, 300, 370, 370, 300, 200, 130, 130]
|
25
25
|
ys = [100, 100, 170, 270, 340, 340, 270, 170]
|
26
26
|
move_to xs.first, ys.first
|
@@ -28,8 +28,8 @@ describe Shoes::Shape do
|
|
28
28
|
line_to(x, y)
|
29
29
|
end
|
30
30
|
line_to xs.first, ys.first
|
31
|
-
|
32
|
-
|
31
|
+
end
|
32
|
+
end
|
33
33
|
|
34
34
|
its(:left) { should eq(0) }
|
35
35
|
its(:top) { should eq(0) }
|
@@ -66,12 +66,12 @@ describe Shoes::Shape do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
describe "curve" do
|
69
|
-
let(:draw)
|
70
|
-
|
69
|
+
let(:draw) do
|
70
|
+
proc do
|
71
71
|
move_to 10, 10
|
72
72
|
curve_to 20, 30, 100, 200, 50, 50
|
73
|
-
|
74
|
-
|
73
|
+
end
|
74
|
+
end
|
75
75
|
|
76
76
|
its(:left_bound) { should eq(10) }
|
77
77
|
its(:top_bound) { should eq(10) }
|
@@ -84,17 +84,17 @@ describe Shoes::Shape do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "arc" do
|
87
|
-
let(:draw)
|
88
|
-
|
87
|
+
let(:draw) do
|
88
|
+
proc do
|
89
89
|
arc_to 10, 10, 100, 100, Shoes::PI, Shoes::TWO_PI
|
90
|
-
|
91
|
-
|
90
|
+
end
|
91
|
+
end
|
92
92
|
|
93
93
|
it_behaves_like "movable object"
|
94
94
|
end
|
95
95
|
|
96
96
|
describe "in_bounds?" do
|
97
|
-
let(:draw) {
|
97
|
+
let(:draw) { proc { line_to 100, 100 } }
|
98
98
|
|
99
99
|
it "is in bounds" do
|
100
100
|
expect(subject.in_bounds?(10, 10)).to be true
|
@@ -106,13 +106,13 @@ describe Shoes::Shape do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
describe "accesses app" do
|
109
|
-
let(:draw)
|
110
|
-
|
109
|
+
let(:draw) do
|
110
|
+
proc do
|
111
111
|
background Shoes::COLORS[:red]
|
112
112
|
stroke Shoes::COLORS[:blue]
|
113
113
|
rect 10, 10, 100, 100
|
114
|
-
|
115
|
-
|
114
|
+
end
|
115
|
+
end
|
116
116
|
|
117
117
|
it_behaves_like "movable object"
|
118
118
|
end
|