shoes-core 4.0.0.pre7 → 4.0.0.pre8

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.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/lib/shoes/arc.rb +10 -13
  3. data/lib/shoes/arrow.rb +1 -11
  4. data/lib/shoes/background.rb +0 -3
  5. data/lib/shoes/border.rb +0 -3
  6. data/lib/shoes/button.rb +4 -1
  7. data/lib/shoes/check_button.rb +0 -1
  8. data/lib/shoes/common/art_element.rb +21 -0
  9. data/lib/shoes/common/background_element.rb +10 -0
  10. data/lib/shoes/common/clickable.rb +2 -0
  11. data/lib/shoes/common/rotate.rb +1 -2
  12. data/lib/shoes/common/ui_element.rb +10 -1
  13. data/lib/shoes/core/version.rb +1 -1
  14. data/lib/shoes/download.rb +47 -29
  15. data/lib/shoes/dsl.rb +99 -40
  16. data/lib/shoes/font.rb +0 -4
  17. data/lib/shoes/http_request.rb +91 -0
  18. data/lib/shoes/image.rb +0 -1
  19. data/lib/shoes/input_box.rb +0 -1
  20. data/lib/shoes/internal_app.rb +1 -1
  21. data/lib/shoes/line.rb +25 -11
  22. data/lib/shoes/link.rb +10 -4
  23. data/lib/shoes/list_box.rb +0 -1
  24. data/lib/shoes/mock/app.rb +6 -0
  25. data/lib/shoes/mock/clickable.rb +3 -0
  26. data/lib/shoes/mock/font.rb +0 -4
  27. data/lib/shoes/oval.rb +3 -13
  28. data/lib/shoes/progress.rb +0 -1
  29. data/lib/shoes/rect.rb +1 -11
  30. data/lib/shoes/shape.rb +16 -8
  31. data/lib/shoes/slot.rb +2 -1
  32. data/lib/shoes/star.rb +8 -11
  33. data/lib/shoes/text_block.rb +0 -1
  34. data/lib/shoes/ui/picker.rb +29 -8
  35. data/lib/shoes/version.rb +1 -1
  36. metadata +8 -231
  37. data/Guardfile +0 -5
  38. data/Rakefile +0 -1
  39. data/bin/shoes-stub +0 -62
  40. data/ext/install/Rakefile +0 -39
  41. data/ext/install/shoes.bat +0 -17
  42. data/lib/rubygems_plugin.rb +0 -24
  43. data/shoes-core.gemspec +0 -22
  44. data/spec/shoes/animation_spec.rb +0 -71
  45. data/spec/shoes/app_spec.rb +0 -454
  46. data/spec/shoes/arc_spec.rb +0 -52
  47. data/spec/shoes/arrow_spec.rb +0 -28
  48. data/spec/shoes/background_spec.rb +0 -47
  49. data/spec/shoes/border_spec.rb +0 -46
  50. data/spec/shoes/builtin_methods_spec.rb +0 -122
  51. data/spec/shoes/button_spec.rb +0 -55
  52. data/spec/shoes/check_spec.rb +0 -36
  53. data/spec/shoes/color_spec.rb +0 -429
  54. data/spec/shoes/common/attachable_spec.rb +0 -32
  55. data/spec/shoes/common/inspect_spec.rb +0 -26
  56. data/spec/shoes/common/remove_spec.rb +0 -37
  57. data/spec/shoes/common/rotate_spec.rb +0 -13
  58. data/spec/shoes/common/style_normalizer_spec.rb +0 -28
  59. data/spec/shoes/common/style_spec.rb +0 -197
  60. data/spec/shoes/common/translate_spec.rb +0 -27
  61. data/spec/shoes/configuration_spec.rb +0 -51
  62. data/spec/shoes/constants_spec.rb +0 -39
  63. data/spec/shoes/dialog_spec.rb +0 -169
  64. data/spec/shoes/dimension_spec.rb +0 -451
  65. data/spec/shoes/dimensions_spec.rb +0 -868
  66. data/spec/shoes/download_spec.rb +0 -198
  67. data/spec/shoes/flow_spec.rb +0 -132
  68. data/spec/shoes/font_spec.rb +0 -36
  69. data/spec/shoes/framework_learning_spec.rb +0 -31
  70. data/spec/shoes/gradient_spec.rb +0 -31
  71. data/spec/shoes/helpers/fake_absolute_element.rb +0 -31
  72. data/spec/shoes/helpers/fake_element.rb +0 -25
  73. data/spec/shoes/helpers/inspect_helpers.rb +0 -5
  74. data/spec/shoes/helpers/sample17_helper.rb +0 -65
  75. data/spec/shoes/image_spec.rb +0 -69
  76. data/spec/shoes/images/shoe.jpg +0 -0
  77. data/spec/shoes/input_box_spec.rb +0 -80
  78. data/spec/shoes/integration_spec.rb +0 -19
  79. data/spec/shoes/internal_app_spec.rb +0 -148
  80. data/spec/shoes/keypress_spec.rb +0 -11
  81. data/spec/shoes/keyrelease_spec.rb +0 -11
  82. data/spec/shoes/line_spec.rb +0 -120
  83. data/spec/shoes/link_spec.rb +0 -149
  84. data/spec/shoes/list_box_spec.rb +0 -87
  85. data/spec/shoes/logger/ruby_spec.rb +0 -8
  86. data/spec/shoes/logger_spec.rb +0 -45
  87. data/spec/shoes/oval_spec.rb +0 -25
  88. data/spec/shoes/packager_spec.rb +0 -25
  89. data/spec/shoes/point_spec.rb +0 -99
  90. data/spec/shoes/progress_spec.rb +0 -54
  91. data/spec/shoes/radio_spec.rb +0 -32
  92. data/spec/shoes/rect_spec.rb +0 -40
  93. data/spec/shoes/renamed_delegate_spec.rb +0 -69
  94. data/spec/shoes/shape_spec.rb +0 -119
  95. data/spec/shoes/shared_examples/button.rb +0 -6
  96. data/spec/shoes/shared_examples/changeable.rb +0 -26
  97. data/spec/shoes/shared_examples/clickable.rb +0 -5
  98. data/spec/shoes/shared_examples/common_methods.rb +0 -35
  99. data/spec/shoes/shared_examples/dimensions.rb +0 -32
  100. data/spec/shoes/shared_examples/dsl.rb +0 -44
  101. data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
  102. data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
  103. data/spec/shoes/shared_examples/dsl/background.rb +0 -26
  104. data/spec/shoes/shared_examples/dsl/border.rb +0 -10
  105. data/spec/shoes/shared_examples/dsl/button.rb +0 -5
  106. data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
  107. data/spec/shoes/shared_examples/dsl/check.rb +0 -11
  108. data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
  109. data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
  110. data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
  111. data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
  112. data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
  113. data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
  114. data/spec/shoes/shared_examples/dsl/image.rb +0 -21
  115. data/spec/shoes/shared_examples/dsl/line.rb +0 -9
  116. data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
  117. data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
  118. data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
  119. data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
  120. data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
  121. data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
  122. data/spec/shoes/shared_examples/dsl/rgb.rb +0 -28
  123. data/spec/shoes/shared_examples/dsl/shape.rb +0 -61
  124. data/spec/shoes/shared_examples/dsl/star.rb +0 -110
  125. data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
  126. data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
  127. data/spec/shoes/shared_examples/dsl/style.rb +0 -32
  128. data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -84
  129. data/spec/shoes/shared_examples/dsl/video.rb +0 -5
  130. data/spec/shoes/shared_examples/dsl_app_context.rb +0 -11
  131. data/spec/shoes/shared_examples/hover.rb +0 -78
  132. data/spec/shoes/shared_examples/parent.rb +0 -6
  133. data/spec/shoes/shared_examples/scroll.rb +0 -41
  134. data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
  135. data/spec/shoes/shared_examples/slot.rb +0 -441
  136. data/spec/shoes/shared_examples/state.rb +0 -26
  137. data/spec/shoes/shared_examples/style.rb +0 -77
  138. data/spec/shoes/slot_spec.rb +0 -176
  139. data/spec/shoes/sound_spec.rb +0 -16
  140. data/spec/shoes/span_spec.rb +0 -112
  141. data/spec/shoes/spec_helper.rb +0 -24
  142. data/spec/shoes/stack_spec.rb +0 -79
  143. data/spec/shoes/star_spec.rb +0 -49
  144. data/spec/shoes/text_block_dimensions_spec.rb +0 -77
  145. data/spec/shoes/text_block_spec.rb +0 -314
  146. data/spec/shoes/text_spec.rb +0 -22
  147. data/spec/shoes/ui/picker_spec.rb +0 -69
  148. data/spec/shoes/url_spec.rb +0 -67
  149. data/spec/shoes/widget_spec.rb +0 -78
  150. data/spec/shoes_spec.rb +0 -41
  151. data/spec/spec_helper.rb +0 -27
@@ -1,169 +0,0 @@
1
- require 'spec_helper'
2
- # NOTE: This spec is sadly circumventing the integration specs since we couldn't
3
- # figure out how to get rid of the alert - it stopped the running tests
4
-
5
- main_object = self
6
-
7
- describe Shoes::Dialog do
8
- before :each do
9
- @dialog = Shoes::Dialog.new
10
- end
11
-
12
- it 'is not nil' do
13
- expect(@dialog).not_to be_nil
14
- end
15
-
16
- describe '#alert' do
17
- it 'returns nil' do
18
- expect(@dialog.alert('something')).to be_nil
19
- end
20
- end
21
-
22
- describe '#confirm' do
23
- it 'responds to it' do
24
- expect(@dialog).to respond_to :confirm
25
- end
26
- end
27
-
28
- describe '#ask_open_file' do
29
- it 'responds to it' do
30
- expect(@dialog).to respond_to :dialog_chooser
31
- end
32
- end
33
-
34
- describe '#ask_save_file' do
35
- it 'responds to it' do
36
- expect(@dialog).to respond_to :dialog_chooser
37
- end
38
- end
39
-
40
- describe '#ask_open_folder' do
41
- it 'responds to it' do
42
- expect(@dialog).to respond_to :dialog_chooser
43
- end
44
- end
45
-
46
- describe '#ask_save_folder' do
47
- it 'responds to it' do
48
- expect(@dialog).to respond_to :dialog_chooser
49
- end
50
- end
51
-
52
- describe '#ask' do
53
- it 'responds to it' do
54
- expect(@dialog).to respond_to :ask
55
- end
56
-
57
- it 'runs ask dialog' do
58
- # Prevent the backend from actually running by stubbing out this method
59
- allow_any_instance_of(Shoes.backend::App).to receive(:wait_until_closed)
60
-
61
- result = @dialog.ask("What?", {})
62
- expect(result).to be_nil
63
- end
64
- end
65
-
66
- describe '#ask_color' do
67
- it 'responds to it' do
68
- expect(@dialog).to respond_to :ask_color
69
- end
70
- end
71
-
72
- describe 'nothing monkey patched on to Object' do
73
- it 'is not monkey patched on to object' do
74
- expect(Object.new).not_to respond_to :alert
75
- end
76
-
77
- it 'is not monkey patched on to object' do
78
- expect(Object.new).not_to respond_to :confirm
79
- end
80
-
81
- it 'is not monkey patched on to object' do
82
- expect(Object.new).not_to respond_to :dialog_chooser
83
- end
84
-
85
- it 'is not monkey patched on to object' do
86
- expect(Object.new).not_to respond_to :ask
87
- end
88
-
89
- it 'is not monkey patched on to object' do
90
- expect(Object.new).not_to respond_to :ask_color
91
- end
92
- end
93
-
94
- describe 'the main object' do
95
- it 'knows of #alert' do
96
- expect(main_object).to respond_to :alert
97
- end
98
-
99
- it 'knows of #confirm' do
100
- expect(main_object).to respond_to :confirm
101
- end
102
-
103
- it 'knows of #confirm?' do
104
- expect(main_object).to respond_to :confirm?
105
- end
106
-
107
- it 'knows of #ask_open_file' do
108
- expect(main_object).to respond_to :ask_open_file
109
- end
110
-
111
- it 'knows of #ask_save_file' do
112
- expect(main_object).to respond_to :ask_save_file
113
- end
114
-
115
- it 'knows of #ask_open_folder' do
116
- expect(main_object).to respond_to :ask_open_folder
117
- end
118
-
119
- it 'knows of #ask_save_folder' do
120
- expect(main_object).to respond_to :ask_save_folder
121
- end
122
-
123
- it 'knows of #ask' do
124
- expect(main_object).to respond_to :ask
125
- end
126
-
127
- it 'knows of #ask' do
128
- expect(main_object).to respond_to :ask_color
129
- end
130
- end
131
-
132
- describe 'Shoes::App' do
133
- before :each do
134
- @app = Shoes::App.new
135
- end
136
-
137
- it 'knows about #alert' do
138
- expect(@app).to respond_to :alert
139
- end
140
-
141
- it 'knows about #confirm' do
142
- expect(@app).to respond_to :confirm
143
- end
144
-
145
- it 'knows about #ask_open_file' do
146
- expect(@app).to respond_to :ask_open_file
147
- end
148
-
149
- it 'knows about #ask_save_file' do
150
- expect(@app).to respond_to :ask_save_file
151
- end
152
-
153
- it 'knows about #ask_open_folder' do
154
- expect(@app).to respond_to :ask_open_folder
155
- end
156
-
157
- it 'knows about #ask_save_folder' do
158
- expect(@app).to respond_to :ask_save_folder
159
- end
160
-
161
- it 'knows about #ask_save_folder' do
162
- expect(@app).to respond_to :ask
163
- end
164
-
165
- it 'knows about #ask_save_color' do
166
- expect(@app).to respond_to :ask_color
167
- end
168
- end
169
- end
@@ -1,451 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Dimension do
4
- subject { Shoes::Dimension.new parent_dimension }
5
- let(:start) { 10 }
6
- let(:extent) { 21 }
7
- let(:parent_element_start) { 34 }
8
- let(:parent_element_end) { 83 }
9
- let(:parent_element_extent) { 600 }
10
- let(:parent_dimension) do
11
- double 'parent_dimension',
12
- element_start: parent_element_start,
13
- element_end: parent_element_end,
14
- element_extent: parent_element_extent
15
- end
16
-
17
- ONE_PIXEL = 1 unless const_defined?(:ONE_PIXEL) && ONE_PIXEL == 1
18
-
19
- describe 'initialization' do
20
- describe 'without arguments (even no parent)' do
21
- subject { Shoes::Dimension.new nil }
22
-
23
- its(:start) { should eq nil }
24
- its(:end) { should eq nil }
25
- its(:extent) { should eq nil }
26
- its(:margin_start) { should eq 0 }
27
- its(:margin_end) { should eq 0 }
28
- its(:displace_start) { should eq 0 }
29
- it { is_expected.not_to be_positioned }
30
- it { is_expected.not_to be_absolute_position }
31
- end
32
-
33
- describe 'with a parent and being positioned itself' do
34
- subject { Shoes::Dimension.new parent_dimension }
35
-
36
- TESTING_OFFSET = 11
37
-
38
- before :each do
39
- subject.absolute_start = parent_element_start + TESTING_OFFSET
40
- subject.extent = 10
41
- end
42
-
43
- its(:start) { should eq TESTING_OFFSET }
44
- its(:end) { should eq parent_element_end - subject.element_end }
45
- end
46
-
47
- describe 'start as center' do
48
- subject { Shoes::Dimension.new parent_dimension, true }
49
-
50
- it 'takes start as the center' do
51
- subject.extent = 100
52
- subject.start = 60
53
- expect(subject.start).to eq 10
54
- end
55
- end
56
- end
57
-
58
- describe '#extent' do
59
- let(:parent_element_extent) { 600 }
60
- let(:parent_extent) { 580 }
61
-
62
- let(:parent) do
63
- double 'parent', element_extent: parent_element_extent,
64
- extent: parent_extent
65
- end
66
-
67
- subject { Shoes::Dimension.new parent }
68
-
69
- it 'gets and sets' do
70
- subject.extent = extent
71
- expect(subject.extent).to eq extent
72
- end
73
-
74
- describe 'negative values' do
75
- it 'subtracts them from the parent taking margins into account' do
76
- subject.extent = -70
77
- expect(subject.extent).to eq parent_element_extent - 70
78
- end
79
- end
80
-
81
- describe 'relative values from the parent taking margins into account' do
82
- it 'takes them relative to the parent for smaller values' do
83
- subject.extent = 0.8
84
- expect(subject.extent).to be_within(ONE_PIXEL).of 0.8 *
85
- parent_element_extent
86
- end
87
-
88
- it 'handles negative relative values' do
89
- subject.extent = -0.3
90
- expect(subject.extent).to be_within(ONE_PIXEL).of 0.7 *
91
- parent_element_extent
92
- end
93
-
94
- it 'equal parent extent for 1.0' do
95
- subject.extent = 1.0
96
- expect(subject.extent).to eq parent_element_extent
97
- end
98
-
99
- it 'does not take them relative to the parent for bigger values' do
100
- subject.extent = 1.3
101
- expect(subject.extent).to eq 1.3
102
- end
103
- end
104
-
105
- describe 'string values' do
106
- it 'handles pure number strings' do
107
- subject.extent = '100'
108
- expect(subject.extent).to eq 100
109
- end
110
-
111
- it 'handles px strings' do
112
- subject.extent = '80px'
113
- expect(subject.extent).to eq 80
114
- end
115
-
116
- it 'takes care of some px white space' do
117
- subject.extent = '70 px'
118
- expect(subject.extent).to eq 70
119
- end
120
-
121
- it 'also handles negative values' do
122
- subject.extent = '-50px'
123
- expect(subject.extent).to eq parent_element_extent - 50
124
- end
125
-
126
- it 'handles percent as relative value' do
127
- subject.extent = '75%'
128
- expect(subject.extent).to be_within(ONE_PIXEL).of 0.75 *
129
- parent_element_extent
130
- end
131
-
132
- it 'handles negative percent values' do
133
- subject.extent = '-10%'
134
- expect(subject.extent).to be_within(ONE_PIXEL).of 0.9 *
135
- parent_element_extent
136
- end
137
-
138
- it 'handles percent values with floats' do
139
- subject.extent = '20.5%'
140
- expect(subject.extent).to be_within(ONE_PIXEL).of 0.205 *
141
- parent_element_extent
142
- end
143
-
144
- it 'returns nil for invalid strings' do
145
- subject.extent = 'hell0'
146
- expect(subject.extent).to be_nil
147
- end
148
- end
149
- end
150
-
151
- describe '#start' do
152
- let(:start) { 23 }
153
-
154
- before :each do
155
- subject.start = start
156
- end
157
-
158
- its(:start) { should eq start }
159
- it { is_expected.to be_absolute_position }
160
-
161
- it 'can set a start relative to parent element_extent' do
162
- subject.start = 0.3
163
- expected = 0.3 * parent_element_extent
164
- expect(subject.start).to be_within(ONE_PIXEL).of expected
165
- end
166
-
167
- # might be surprising if people do calculations that result in a float
168
- # and all of a sudden they have 10.4 and the button is nowhere to be found
169
- it 'uses literal float values for values over 1.0' do
170
- subject.start = 1.01
171
- expect(subject.start).to eq 1.01
172
- end
173
-
174
- context '#without a parent' do
175
- let(:parent_dimension) { nil }
176
-
177
- it 'just takes the relative value' do
178
- subject.start = 0.8
179
- expect(subject.start).to eq 0.8
180
- end
181
- end
182
- end
183
-
184
- describe 'with no parent but set dimensions' do
185
- subject { Shoes::Dimension.new }
186
-
187
- before :each do
188
- subject.absolute_start = 23
189
- subject.extent = 45
190
- end
191
-
192
- its(:end) { should be_nil }
193
- its(:start) { should be_nil }
194
- end
195
-
196
- describe '#absolute_start' do
197
- let(:absolute_start) { 8 }
198
-
199
- before :each do
200
- subject.absolute_start = absolute_start
201
- end
202
-
203
- it 'gets and sets absolute_start' do
204
- expect(subject.absolute_start).to eq absolute_start
205
- end
206
-
207
- it { is_expected.to be_positioned }
208
- end
209
-
210
- describe '#absolute_end' do
211
- it 'is the sum of start and extent' do
212
- subject.absolute_start = 7
213
- subject.extent = 22
214
- expect(subject.absolute_end).to eq 29 - ONE_PIXEL # pixel counting adjustment
215
- end
216
-
217
- it 'returns nil if absolute_start is nil but extent is set' do
218
- subject.absolute_start = nil
219
- subject.extent = 100
220
- expect(subject.absolute_end).to be_nil
221
- end
222
- end
223
-
224
- describe '#margins' do
225
- let(:margin_start) { 11 }
226
- let(:margin_end) { 17 }
227
-
228
- before :each do
229
- subject.margin_start = margin_start
230
- subject.margin_end = margin_end
231
- end
232
-
233
- its(:margin_start) { should eq margin_start }
234
- its(:margin_end) { should eq margin_end }
235
-
236
- context 'absolute_start set' do
237
- let(:absolute_start) { 7 }
238
-
239
- before :each do
240
- subject.absolute_start = absolute_start
241
- end
242
-
243
- it 'does not influence absolute_start' do
244
- expect(subject.absolute_start).to eq absolute_start
245
- end
246
-
247
- it 'does influence element_start' do
248
- expect(subject.element_start).to eq absolute_start + margin_start
249
- end
250
-
251
- context 'extent set' do
252
- let(:extent) { 67 }
253
-
254
- before :each do
255
- subject.extent = extent
256
- end
257
-
258
- it 'does not influence absolute_end' do
259
- expect(subject.absolute_end).to eq absolute_start + extent - ONE_PIXEL
260
- end
261
-
262
- it 'does influence element_end' do
263
- expect(subject.element_end).to eq absolute_start + extent -
264
- margin_end - ONE_PIXEL
265
- end
266
- end
267
-
268
- context 'element_extent set' do
269
- let(:element_extent) { 77 }
270
-
271
- before :each do
272
- subject.element_extent = element_extent
273
- end
274
-
275
- its(:element_extent) { should eq element_extent }
276
- its(:extent) { should eq element_extent + margin_start + margin_end }
277
- its(:element_end) do
278
- should eq subject.element_start + element_extent - ONE_PIXEL
279
- end
280
- end
281
-
282
- describe 'relative margins' do
283
- let(:margin_start) { 0.1 }
284
- let(:margin_end) { 0.2 }
285
-
286
- its(:margin_start) do
287
- should be_within(ONE_PIXEL).of 0.1 * parent_element_extent
288
- end
289
-
290
- its(:margin_end) do
291
- should be_within(ONE_PIXEL).of 0.2 * parent_element_extent
292
- end
293
- end
294
- end
295
- end
296
-
297
- describe '#in_bounds?' do
298
- let(:absolute_start) { 20 }
299
- let(:extent) { 100 }
300
- let(:absolute_end) { 20 + 100 - ONE_PIXEL } # -1 due to pixel counting adjustment
301
-
302
- before :each do
303
- subject.absolute_start = absolute_start
304
- subject.extent = extent
305
- end
306
-
307
- its(:absolute_end) { should eq absolute_end }
308
-
309
- it { is_expected.to be_in_bounds absolute_start }
310
- it { is_expected.to be_in_bounds absolute_end }
311
- it { is_expected.to be_in_bounds absolute_start + ONE_PIXEL }
312
- it { is_expected.to be_in_bounds absolute_end - ONE_PIXEL }
313
- it { is_expected.to be_in_bounds 40 }
314
- it { is_expected.to be_in_bounds 105 }
315
- it { is_expected.to be_in_bounds 20.021 }
316
- it { is_expected.not_to be_in_bounds absolute_end + ONE_PIXEL }
317
- it { is_expected.not_to be_in_bounds absolute_start - ONE_PIXEL }
318
- it { is_expected.not_to be_in_bounds(-5) }
319
- it { is_expected.not_to be_in_bounds 0 }
320
- it { is_expected.not_to be_in_bounds 150 }
321
- it { is_expected.not_to be_in_bounds 123_178 }
322
- end
323
-
324
- it 'can displace the placement' do
325
- subject.displace_start = 5
326
- subject.absolute_start = 10
327
- expect(subject.element_start).to eq 15
328
- end
329
-
330
- describe 'start/end/margin and other values parse simple string values' do
331
- it 'parses a normal number' do
332
- subject.start = '50'
333
- expect(subject.start).to eq 50
334
- end
335
-
336
- it 'parses pixel values' do
337
- subject.start = '77px'
338
- expect(subject.start).to eq 77
339
- end
340
-
341
- it 'parses negative values' do
342
- subject.start = '-13'
343
- expect(subject.start).to eq(-13)
344
- end
345
-
346
- it 'even parses negative values with px' do
347
- subject.start = '-22px'
348
- expect(subject.start).to eq(-22)
349
- end
350
-
351
- it 'returns nil for unknown values' do
352
- subject.start = []
353
- expect(subject.start).to be_nil
354
- end
355
- end
356
-
357
- describe Shoes::ParentDimension do
358
- let(:parent) { Shoes::Dimension.new }
359
- let(:parent_start) { 7 }
360
- let(:parent_extent) { 27 }
361
- let(:margin) { 5 }
362
-
363
- subject { Shoes::ParentDimension.new parent }
364
-
365
- before :each do
366
- parent.start = parent_start
367
- parent.extent = parent_extent
368
- end
369
-
370
- describe 'it takes some parent values if no values are set' do
371
- its(:extent) { should eq parent_extent }
372
-
373
- its(:margin_start) { should eq 0 }
374
- its(:margin_end) { should eq 0 }
375
-
376
- context 'with parent absolute_start set' do
377
- before :each do
378
- parent.absolute_start = 11
379
- end
380
-
381
- its(:absolute_start) { should eq parent.element_start }
382
- its(:element_start) { should eq parent.element_start }
383
- its(:element_end) { should eq parent.element_end }
384
- end
385
-
386
- context 'but it takes the parent margins into account' do
387
- before :each do
388
- parent.margin_start = margin
389
- parent.margin_end = margin
390
- end
391
-
392
- its(:extent) { is_expected.to eq 17 }
393
- end
394
- end
395
-
396
- describe 'otherwise it takes its own values' do
397
- before :each do
398
- subject.start = start
399
- subject.extent = extent
400
- parent.absolute_start = 17
401
- end
402
-
403
- its(:start) { should eq start }
404
- its(:extent) { should eq extent }
405
- its(:absolute_start) { should eq 17 }
406
-
407
- it 'can still handle special values like a negative extent' do
408
- subject.extent = -10
409
- expect(subject.extent).to eq(parent.element_extent - 10)
410
- end
411
-
412
- it 'can also still handle special values like relative values' do
413
- subject.extent = 0.8
414
- expect(subject.extent).to be_within(ONE_PIXEL).of(0.8 * parent.element_extent)
415
- end
416
-
417
- it 'takes the margins of parent into account' do
418
- parent.margin_start = 10
419
- expect(subject.absolute_start).to eq 27
420
- end
421
- end
422
-
423
- describe 'it obeys parent bounds' do
424
- let(:parent_dimension) do
425
- double 'parent_dimension',
426
- element_start: 10,
427
- element_end: 20,
428
- absolute_start: 10,
429
- absolute_end: 20,
430
- extent: 10,
431
- element_extent: 10
432
- end
433
-
434
- subject { Shoes::ParentDimension.new parent_dimension }
435
-
436
- it "gets the parent element_extent" do
437
- expect(subject.extent).to eq(10)
438
- end
439
-
440
- it "can't extend beyond the parent" do
441
- subject.extent = 25
442
- expect(subject.extent).to eq(10)
443
- end
444
-
445
- it 'can get smaller than the parent' do
446
- subject.extent = 5
447
- expect(subject.extent).to eq(5)
448
- end
449
- end
450
- end
451
- end