motion-kit 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -3
- data/lib/motion-kit-cocoa/constraints/constraint.rb +22 -12
- data/lib/motion-kit-cocoa/constraints/constraints_layout.rb +17 -17
- data/lib/motion-kit/layouts/base_layout.rb +30 -13
- data/lib/motion-kit/version.rb +1 -1
- data/spec/ios/calayer_spec.rb +1 -0
- data/spec/ios/constraints_helpers/center_constraints_spec.rb +31 -29
- data/spec/ios/constraints_helpers/relative_corners_spec.rb +27 -25
- data/spec/ios/constraints_helpers/relative_location_spec.rb +7 -5
- data/spec/ios/constraints_helpers/simple_constraints_spec.rb +195 -194
- data/spec/ios/constraints_helpers/size_constraints_spec.rb +6 -5
- data/spec/ios/constraints_helpers/view_lookup_constraints_spec.rb +10 -8
- data/spec/ios/relative_layout.spec.rb +2 -2
- data/spec/osx/constraints_helpers/size_constraints_spec.rb +84 -29
- metadata +2 -2
@@ -3,13 +3,14 @@ describe 'Constraints - Size helpers' do
|
|
3
3
|
before do
|
4
4
|
@layout = MK::Layout.new
|
5
5
|
@constraint = nil
|
6
|
-
@
|
7
|
-
@
|
6
|
+
@view = UIView.new
|
7
|
+
@parent_view = UIView.new
|
8
|
+
@parent_view.addSubview(@view)
|
8
9
|
@another_view = nil
|
9
10
|
end
|
10
11
|
|
11
12
|
it 'should support `size 10`' do
|
12
|
-
@
|
13
|
+
@layout.context(@view) do
|
13
14
|
@layout.constraints do
|
14
15
|
@constraint = @layout.size(10)
|
15
16
|
end
|
@@ -317,7 +318,7 @@ describe 'Constraints - Size helpers' do
|
|
317
318
|
@constraint.attribute2.should == [:width, :height]
|
318
319
|
end
|
319
320
|
it 'should support `max_size("50%")`' do
|
320
|
-
@
|
321
|
+
@layout.context(@parent_view) do
|
321
322
|
@view = @layout.add(UIView.new) do
|
322
323
|
@layout.constraints do
|
323
324
|
@constraint = @layout.max_size('50%')
|
@@ -333,7 +334,7 @@ describe 'Constraints - Size helpers' do
|
|
333
334
|
@constraint.attribute2.should == [:width, :height]
|
334
335
|
end
|
335
336
|
it 'should support `max_size("50% + 1").of(:another_view)`' do
|
336
|
-
@
|
337
|
+
@layout.context(@parent_view) do
|
337
338
|
@view = @layout.add(UIView.new) do
|
338
339
|
@layout.constraints do
|
339
340
|
@constraint = @layout.max_size('50% + 1').of(:another_view)
|
@@ -3,13 +3,15 @@ describe 'Constraints - view_lookup method' do
|
|
3
3
|
before do
|
4
4
|
@layout = MK::Layout.new
|
5
5
|
@constraint = nil
|
6
|
-
@view =
|
6
|
+
@view = UIView.new
|
7
|
+
@parent_view = UIView.new
|
8
|
+
@parent_view.addSubview(@view)
|
7
9
|
@another_view = nil
|
8
10
|
end
|
9
11
|
|
10
12
|
it 'should support :superview' do
|
11
|
-
@
|
12
|
-
@
|
13
|
+
@layout.context(@parent_view) do
|
14
|
+
@layout.context(@view) do
|
13
15
|
@layout.constraints do
|
14
16
|
@constraint = @layout.left.equals(:superview).plus(10)
|
15
17
|
end
|
@@ -28,15 +30,15 @@ describe 'Constraints - view_lookup method' do
|
|
28
30
|
resolved[0].firstItem.should.be.kind_of(UIView)
|
29
31
|
resolved[0].firstAttribute.should == NSLayoutAttributeLeft
|
30
32
|
resolved[0].relation.should == NSLayoutRelationEqual
|
31
|
-
resolved[0].secondItem.should == @
|
33
|
+
resolved[0].secondItem.should == @parent_view
|
32
34
|
resolved[0].secondAttribute.should == NSLayoutAttributeLeft
|
33
35
|
resolved[0].multiplier.should == 1
|
34
36
|
resolved[0].constant.should == 10
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'should support :another_view' do
|
38
|
-
@
|
39
|
-
@
|
40
|
+
@layout.context(@parent_view) do
|
41
|
+
@layout.context(@view) do
|
40
42
|
@layout.constraints do
|
41
43
|
@constraint = @layout.left.equals(:another_view).plus(10)
|
42
44
|
end
|
@@ -63,9 +65,9 @@ describe 'Constraints - view_lookup method' do
|
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'should support @another_view' do
|
66
|
-
@
|
68
|
+
@layout.context(@parent_view) do
|
67
69
|
@another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
|
68
|
-
@
|
70
|
+
@layout.context(@view) do
|
69
71
|
@layout.constraints do
|
70
72
|
@constraint = @layout.left.equals(@another_view).plus(10)
|
71
73
|
end
|
@@ -13,7 +13,7 @@ describe 'Relative Layouts' do
|
|
13
13
|
@subject.get(:test).frame.origin.y.should == 0
|
14
14
|
end
|
15
15
|
it "with frame w = h = 100" do
|
16
|
-
@subject.get(:test).frame.size.width.should ==
|
16
|
+
@subject.get(:test).frame.size.width.should == UIScreen.mainScreen.bounds.size.width
|
17
17
|
@subject.get(:test).frame.size.height.should == 100
|
18
18
|
end
|
19
19
|
end
|
@@ -24,7 +24,7 @@ describe 'Relative Layouts' do
|
|
24
24
|
@subject.get(:test2).frame.origin.y.should == 100
|
25
25
|
end
|
26
26
|
it "with frame w = 100, h = 50" do
|
27
|
-
@subject.get(:test2).frame.size.width.should ==
|
27
|
+
@subject.get(:test2).frame.size.width.should == UIScreen.mainScreen.bounds.size.width
|
28
28
|
@subject.get(:test2).frame.size.height.should == 50
|
29
29
|
end
|
30
30
|
end
|
@@ -1,18 +1,21 @@
|
|
1
|
-
describe 'Size
|
1
|
+
describe 'Constraints - Size helpers' do
|
2
2
|
|
3
3
|
before do
|
4
4
|
@layout = MK::Layout.new
|
5
5
|
@constraint = nil
|
6
|
-
@view =
|
6
|
+
@view = NSView.new
|
7
|
+
@parent_view = NSView.new
|
8
|
+
@parent_view.addSubview(@view)
|
7
9
|
@another_view = nil
|
8
10
|
end
|
9
11
|
|
10
12
|
it 'should support `size 10`' do
|
11
|
-
@layout.context(
|
13
|
+
@layout.context(@view) do
|
12
14
|
@layout.constraints do
|
13
15
|
@constraint = @layout.size(10)
|
14
16
|
end
|
15
17
|
end
|
18
|
+
|
16
19
|
@constraint.constant.should == [10, 10]
|
17
20
|
@constraint.relationship.should == :equal
|
18
21
|
@constraint.multiplier.should == [1, 1]
|
@@ -20,12 +23,14 @@ describe 'Size constraints helpers' do
|
|
20
23
|
@constraint.attribute.should == [:width, :height]
|
21
24
|
@constraint.attribute2.should == [:width, :height]
|
22
25
|
end
|
26
|
+
|
23
27
|
it 'should support `min_size 10`' do
|
24
|
-
@layout.context(
|
28
|
+
@layout.context(@view) do
|
25
29
|
@layout.constraints do
|
26
30
|
@constraint = @layout.min_size(10)
|
27
31
|
end
|
28
32
|
end
|
33
|
+
|
29
34
|
@constraint.constant.should == [10, 10]
|
30
35
|
@constraint.relationship.should == :gte
|
31
36
|
@constraint.multiplier.should == [1, 1]
|
@@ -33,12 +38,14 @@ describe 'Size constraints helpers' do
|
|
33
38
|
@constraint.attribute.should == [:width, :height]
|
34
39
|
@constraint.attribute2.should == [:width, :height]
|
35
40
|
end
|
41
|
+
|
36
42
|
it 'should support `max_size 10`' do
|
37
|
-
@layout.context(
|
43
|
+
@layout.context(@view) do
|
38
44
|
@layout.constraints do
|
39
45
|
@constraint = @layout.max_size(10)
|
40
46
|
end
|
41
47
|
end
|
48
|
+
|
42
49
|
@constraint.constant.should == [10, 10]
|
43
50
|
@constraint.relationship.should == :lte
|
44
51
|
@constraint.multiplier.should == [1, 1]
|
@@ -46,12 +53,14 @@ describe 'Size constraints helpers' do
|
|
46
53
|
@constraint.attribute.should == [:width, :height]
|
47
54
|
@constraint.attribute2.should == [:width, :height]
|
48
55
|
end
|
56
|
+
|
49
57
|
it 'should support `size [10, 10]`' do
|
50
|
-
@layout.context(
|
58
|
+
@layout.context(@view) do
|
51
59
|
@layout.constraints do
|
52
60
|
@constraint = @layout.size([10, 10])
|
53
61
|
end
|
54
62
|
end
|
63
|
+
|
55
64
|
@constraint.constant.should == [10, 10]
|
56
65
|
@constraint.relationship.should == :equal
|
57
66
|
@constraint.multiplier.should == [1, 1]
|
@@ -59,12 +68,14 @@ describe 'Size constraints helpers' do
|
|
59
68
|
@constraint.attribute.should == [:width, :height]
|
60
69
|
@constraint.attribute2.should == [:width, :height]
|
61
70
|
end
|
71
|
+
|
62
72
|
it 'should support `min_size [10, 10]`' do
|
63
|
-
@layout.context(
|
73
|
+
@layout.context(@view) do
|
64
74
|
@layout.constraints do
|
65
75
|
@constraint = @layout.min_size([10, 10])
|
66
76
|
end
|
67
77
|
end
|
78
|
+
|
68
79
|
@constraint.constant.should == [10, 10]
|
69
80
|
@constraint.relationship.should == :gte
|
70
81
|
@constraint.multiplier.should == [1, 1]
|
@@ -72,12 +83,14 @@ describe 'Size constraints helpers' do
|
|
72
83
|
@constraint.attribute.should == [:width, :height]
|
73
84
|
@constraint.attribute2.should == [:width, :height]
|
74
85
|
end
|
86
|
+
|
75
87
|
it 'should support `max_size [10, 10]`' do
|
76
|
-
@layout.context(
|
88
|
+
@layout.context(@view) do
|
77
89
|
@layout.constraints do
|
78
90
|
@constraint = @layout.max_size([10, 10])
|
79
91
|
end
|
80
92
|
end
|
93
|
+
|
81
94
|
@constraint.constant.should == [10, 10]
|
82
95
|
@constraint.relationship.should == :lte
|
83
96
|
@constraint.multiplier.should == [1, 1]
|
@@ -85,12 +98,14 @@ describe 'Size constraints helpers' do
|
|
85
98
|
@constraint.attribute.should == [:width, :height]
|
86
99
|
@constraint.attribute2.should == [:width, :height]
|
87
100
|
end
|
101
|
+
|
88
102
|
it 'should support `size w: 10, h: 10`' do
|
89
|
-
@layout.context(
|
103
|
+
@layout.context(@view) do
|
90
104
|
@layout.constraints do
|
91
105
|
@constraint = @layout.size(w: 10, h: 10)
|
92
106
|
end
|
93
107
|
end
|
108
|
+
|
94
109
|
@constraint.constant.should == [10, 10]
|
95
110
|
@constraint.relationship.should == :equal
|
96
111
|
@constraint.multiplier.should == [1, 1]
|
@@ -98,12 +113,14 @@ describe 'Size constraints helpers' do
|
|
98
113
|
@constraint.attribute.should == [:width, :height]
|
99
114
|
@constraint.attribute2.should == [:width, :height]
|
100
115
|
end
|
116
|
+
|
101
117
|
it 'should support `min_size w: 10, h: 10`' do
|
102
|
-
@layout.context(
|
118
|
+
@layout.context(@view) do
|
103
119
|
@layout.constraints do
|
104
120
|
@constraint = @layout.min_size(w: 10, h: 10)
|
105
121
|
end
|
106
122
|
end
|
123
|
+
|
107
124
|
@constraint.constant.should == [10, 10]
|
108
125
|
@constraint.relationship.should == :gte
|
109
126
|
@constraint.multiplier.should == [1, 1]
|
@@ -111,12 +128,14 @@ describe 'Size constraints helpers' do
|
|
111
128
|
@constraint.attribute.should == [:width, :height]
|
112
129
|
@constraint.attribute2.should == [:width, :height]
|
113
130
|
end
|
131
|
+
|
114
132
|
it 'should support `max_size w: 10, h: 10`' do
|
115
|
-
@layout.context(
|
133
|
+
@layout.context(@view) do
|
116
134
|
@layout.constraints do
|
117
135
|
@constraint = @layout.max_size(w: 10, h: 10)
|
118
136
|
end
|
119
137
|
end
|
138
|
+
|
120
139
|
@constraint.constant.should == [10, 10]
|
121
140
|
@constraint.relationship.should == :lte
|
122
141
|
@constraint.multiplier.should == [1, 1]
|
@@ -124,12 +143,14 @@ describe 'Size constraints helpers' do
|
|
124
143
|
@constraint.attribute.should == [:width, :height]
|
125
144
|
@constraint.attribute2.should == [:width, :height]
|
126
145
|
end
|
146
|
+
|
127
147
|
it 'should support `size.equals(:another_view[, :size])`' do
|
128
|
-
@layout.context(
|
148
|
+
@layout.context(@view) do
|
129
149
|
@layout.constraints do
|
130
150
|
@constraint = @layout.size.equals(:another_view)
|
131
151
|
end
|
132
152
|
end
|
153
|
+
|
133
154
|
@constraint.constant.should == [0, 0]
|
134
155
|
@constraint.relationship.should == :equal
|
135
156
|
@constraint.multiplier.should == [1, 1]
|
@@ -137,12 +158,14 @@ describe 'Size constraints helpers' do
|
|
137
158
|
@constraint.attribute.should == [:width, :height]
|
138
159
|
@constraint.attribute2.should == [:width, :height]
|
139
160
|
end
|
161
|
+
|
140
162
|
it 'should support `size.equals(:another_view).plus(10).plus([5, 10])`' do
|
141
|
-
@layout.context(
|
163
|
+
@layout.context(@view) do
|
142
164
|
@layout.constraints do
|
143
165
|
@constraint = @layout.size.equals(:another_view).plus(10).plus([5, 10])
|
144
166
|
end
|
145
167
|
end
|
168
|
+
|
146
169
|
@constraint.constant.should == [15, 20]
|
147
170
|
@constraint.relationship.should == :equal
|
148
171
|
@constraint.multiplier.should == [1, 1]
|
@@ -150,12 +173,14 @@ describe 'Size constraints helpers' do
|
|
150
173
|
@constraint.attribute.should == [:width, :height]
|
151
174
|
@constraint.attribute2.should == [:width, :height]
|
152
175
|
end
|
176
|
+
|
153
177
|
it 'should support `min_size.equals(:another_view[, :size])`' do
|
154
|
-
@layout.context(
|
178
|
+
@layout.context(@view) do
|
155
179
|
@layout.constraints do
|
156
180
|
@constraint = @layout.min_size.equals(:another_view)
|
157
181
|
end
|
158
182
|
end
|
183
|
+
|
159
184
|
@constraint.constant.should == [0, 0]
|
160
185
|
@constraint.relationship.should == :gte
|
161
186
|
@constraint.multiplier.should == [1, 1]
|
@@ -163,12 +188,14 @@ describe 'Size constraints helpers' do
|
|
163
188
|
@constraint.attribute.should == [:width, :height]
|
164
189
|
@constraint.attribute2.should == [:width, :height]
|
165
190
|
end
|
191
|
+
|
166
192
|
it 'should support `max_size.equals(:another_view[, :size])`' do
|
167
|
-
@layout.context(
|
193
|
+
@layout.context(@view) do
|
168
194
|
@layout.constraints do
|
169
195
|
@constraint = @layout.max_size.equals(:another_view)
|
170
196
|
end
|
171
197
|
end
|
198
|
+
|
172
199
|
@constraint.constant.should == [0, 0]
|
173
200
|
@constraint.relationship.should == :lte
|
174
201
|
@constraint.multiplier.should == [1, 1]
|
@@ -176,12 +203,14 @@ describe 'Size constraints helpers' do
|
|
176
203
|
@constraint.attribute.should == [:width, :height]
|
177
204
|
@constraint.attribute2.should == [:width, :height]
|
178
205
|
end
|
206
|
+
|
179
207
|
it 'should support `size.equals(:another_view).plus(10)`' do
|
180
|
-
@layout.context(
|
208
|
+
@layout.context(@view) do
|
181
209
|
@layout.constraints do
|
182
210
|
@constraint = @layout.size.equals(:another_view).plus(10)
|
183
211
|
end
|
184
212
|
end
|
213
|
+
|
185
214
|
@constraint.constant.should == [10, 10]
|
186
215
|
@constraint.relationship.should == :equal
|
187
216
|
@constraint.multiplier.should == [1, 1]
|
@@ -189,12 +218,14 @@ describe 'Size constraints helpers' do
|
|
189
218
|
@constraint.attribute.should == [:width, :height]
|
190
219
|
@constraint.attribute2.should == [:width, :height]
|
191
220
|
end
|
221
|
+
|
192
222
|
it 'should support `min_size.equals(:another_view).plus(10)`' do
|
193
|
-
@layout.context(
|
223
|
+
@layout.context(@view) do
|
194
224
|
@layout.constraints do
|
195
225
|
@constraint = @layout.min_size.equals(:another_view).plus(10)
|
196
226
|
end
|
197
227
|
end
|
228
|
+
|
198
229
|
@constraint.constant.should == [10, 10]
|
199
230
|
@constraint.relationship.should == :gte
|
200
231
|
@constraint.multiplier.should == [1, 1]
|
@@ -202,12 +233,14 @@ describe 'Size constraints helpers' do
|
|
202
233
|
@constraint.attribute.should == [:width, :height]
|
203
234
|
@constraint.attribute2.should == [:width, :height]
|
204
235
|
end
|
236
|
+
|
205
237
|
it 'should support `max_size.equals(:another_view).plus(10)`' do
|
206
|
-
@layout.context(
|
238
|
+
@layout.context(@view) do
|
207
239
|
@layout.constraints do
|
208
240
|
@constraint = @layout.max_size.equals(:another_view).plus(10)
|
209
241
|
end
|
210
242
|
end
|
243
|
+
|
211
244
|
@constraint.constant.should == [10, 10]
|
212
245
|
@constraint.relationship.should == :lte
|
213
246
|
@constraint.multiplier.should == [1, 1]
|
@@ -215,12 +248,14 @@ describe 'Size constraints helpers' do
|
|
215
248
|
@constraint.attribute.should == [:width, :height]
|
216
249
|
@constraint.attribute2.should == [:width, :height]
|
217
250
|
end
|
251
|
+
|
218
252
|
it 'should support `size.equals(:another_view).plus([10, 10])`' do
|
219
|
-
@layout.context(
|
253
|
+
@layout.context(@view) do
|
220
254
|
@layout.constraints do
|
221
255
|
@constraint = @layout.size.equals(:another_view).plus([10, 10])
|
222
256
|
end
|
223
257
|
end
|
258
|
+
|
224
259
|
@constraint.constant.should == [10, 10]
|
225
260
|
@constraint.relationship.should == :equal
|
226
261
|
@constraint.multiplier.should == [1, 1]
|
@@ -228,12 +263,14 @@ describe 'Size constraints helpers' do
|
|
228
263
|
@constraint.attribute.should == [:width, :height]
|
229
264
|
@constraint.attribute2.should == [:width, :height]
|
230
265
|
end
|
266
|
+
|
231
267
|
it 'should support `min_size.equals(:another_view).plus([10, 10])`' do
|
232
|
-
@layout.context(
|
268
|
+
@layout.context(@view) do
|
233
269
|
@layout.constraints do
|
234
270
|
@constraint = @layout.min_size.equals(:another_view).plus([10, 10])
|
235
271
|
end
|
236
272
|
end
|
273
|
+
|
237
274
|
@constraint.constant.should == [10, 10]
|
238
275
|
@constraint.relationship.should == :gte
|
239
276
|
@constraint.multiplier.should == [1, 1]
|
@@ -241,12 +278,14 @@ describe 'Size constraints helpers' do
|
|
241
278
|
@constraint.attribute.should == [:width, :height]
|
242
279
|
@constraint.attribute2.should == [:width, :height]
|
243
280
|
end
|
281
|
+
|
244
282
|
it 'should support `max_size.equals(:another_view).plus(w: 10, h: 10)`' do
|
245
|
-
@layout.context(
|
283
|
+
@layout.context(@view) do
|
246
284
|
@layout.constraints do
|
247
285
|
@constraint = @layout.max_size.equals(:another_view).plus(w: 10, h: 10)
|
248
286
|
end
|
249
287
|
end
|
288
|
+
|
250
289
|
@constraint.constant.should == [10, 10]
|
251
290
|
@constraint.relationship.should == :lte
|
252
291
|
@constraint.multiplier.should == [1, 1]
|
@@ -254,12 +293,14 @@ describe 'Size constraints helpers' do
|
|
254
293
|
@constraint.attribute.should == [:width, :height]
|
255
294
|
@constraint.attribute2.should == [:width, :height]
|
256
295
|
end
|
296
|
+
|
257
297
|
it 'should support `size.equals(:another_view).times(2).plus(10)`' do
|
258
|
-
@layout.context(
|
298
|
+
@layout.context(@view) do
|
259
299
|
@layout.constraints do
|
260
300
|
@constraint = @layout.size.equals(:another_view).times(2).plus(10)
|
261
301
|
end
|
262
302
|
end
|
303
|
+
|
263
304
|
@constraint.constant.should == [10, 10]
|
264
305
|
@constraint.relationship.should == :equal
|
265
306
|
@constraint.multiplier.should == [2, 2]
|
@@ -267,12 +308,14 @@ describe 'Size constraints helpers' do
|
|
267
308
|
@constraint.attribute.should == [:width, :height]
|
268
309
|
@constraint.attribute2.should == [:width, :height]
|
269
310
|
end
|
311
|
+
|
270
312
|
it 'should support `min_size.equals(:another_view).times(2).plus(10)`' do
|
271
|
-
@layout.context(
|
313
|
+
@layout.context(@view) do
|
272
314
|
@layout.constraints do
|
273
315
|
@constraint = @layout.min_size.equals(:another_view).times(2).plus(10)
|
274
316
|
end
|
275
317
|
end
|
318
|
+
|
276
319
|
@constraint.constant.should == [10, 10]
|
277
320
|
@constraint.relationship.should == :gte
|
278
321
|
@constraint.multiplier.should == [2, 2]
|
@@ -280,12 +323,14 @@ describe 'Size constraints helpers' do
|
|
280
323
|
@constraint.attribute.should == [:width, :height]
|
281
324
|
@constraint.attribute2.should == [:width, :height]
|
282
325
|
end
|
326
|
+
|
283
327
|
it 'should support `max_size.equals(:another_view).times(2).plus(10)`' do
|
284
|
-
@layout.context(
|
328
|
+
@layout.context(@view) do
|
285
329
|
@layout.constraints do
|
286
330
|
@constraint = @layout.max_size.equals(:another_view).times(2).plus(10)
|
287
331
|
end
|
288
332
|
end
|
333
|
+
|
289
334
|
@constraint.constant.should == [10, 10]
|
290
335
|
@constraint.relationship.should == :lte
|
291
336
|
@constraint.multiplier.should == [2, 2]
|
@@ -293,12 +338,14 @@ describe 'Size constraints helpers' do
|
|
293
338
|
@constraint.attribute.should == [:width, :height]
|
294
339
|
@constraint.attribute2.should == [:width, :height]
|
295
340
|
end
|
341
|
+
|
296
342
|
it 'should support `size.equals(:another_view).times([2, 2]).plus(10)`' do
|
297
|
-
@layout.context(
|
343
|
+
@layout.context(@view) do
|
298
344
|
@layout.constraints do
|
299
345
|
@constraint = @layout.size.equals(:another_view).times([2, 2]).plus(10)
|
300
346
|
end
|
301
347
|
end
|
348
|
+
|
302
349
|
@constraint.constant.should == [10, 10]
|
303
350
|
@constraint.relationship.should == :equal
|
304
351
|
@constraint.multiplier.should == [2, 2]
|
@@ -306,12 +353,14 @@ describe 'Size constraints helpers' do
|
|
306
353
|
@constraint.attribute.should == [:width, :height]
|
307
354
|
@constraint.attribute2.should == [:width, :height]
|
308
355
|
end
|
356
|
+
|
309
357
|
it 'should support `min_size.equals(:another_view).times([2, 2]).plus(10)`' do
|
310
|
-
@layout.context(
|
358
|
+
@layout.context(@view) do
|
311
359
|
@layout.constraints do
|
312
360
|
@constraint = @layout.min_size.equals(:another_view).times([2, 2]).plus(10)
|
313
361
|
end
|
314
362
|
end
|
363
|
+
|
315
364
|
@constraint.constant.should == [10, 10]
|
316
365
|
@constraint.relationship.should == :gte
|
317
366
|
@constraint.multiplier.should == [2, 2]
|
@@ -319,12 +368,14 @@ describe 'Size constraints helpers' do
|
|
319
368
|
@constraint.attribute.should == [:width, :height]
|
320
369
|
@constraint.attribute2.should == [:width, :height]
|
321
370
|
end
|
371
|
+
|
322
372
|
it 'should support `max_size.equals(:another_view).times(w: 2, h: 2).plus(10)`' do
|
323
|
-
@layout.context(
|
373
|
+
@layout.context(@view) do
|
324
374
|
@layout.constraints do
|
325
375
|
@constraint = @layout.max_size.equals(:another_view).times(w: 2, h: 2).plus(10)
|
326
376
|
end
|
327
377
|
end
|
378
|
+
|
328
379
|
@constraint.constant.should == [10, 10]
|
329
380
|
@constraint.relationship.should == :lte
|
330
381
|
@constraint.multiplier.should == [2, 2]
|
@@ -332,12 +383,14 @@ describe 'Size constraints helpers' do
|
|
332
383
|
@constraint.attribute.should == [:width, :height]
|
333
384
|
@constraint.attribute2.should == [:width, :height]
|
334
385
|
end
|
386
|
+
|
335
387
|
it 'should support `size.equals(:another_view).times(2).times([3, 4])`' do
|
336
|
-
@layout.context(
|
388
|
+
@layout.context(@view) do
|
337
389
|
@layout.constraints do
|
338
390
|
@constraint = @layout.size.equals(:another_view).times(2).times([3, 4])
|
339
391
|
end
|
340
392
|
end
|
393
|
+
|
341
394
|
@constraint.constant.should == [0, 0]
|
342
395
|
@constraint.relationship.should == :equal
|
343
396
|
@constraint.multiplier.should == [6, 8]
|
@@ -345,12 +398,14 @@ describe 'Size constraints helpers' do
|
|
345
398
|
@constraint.attribute.should == [:width, :height]
|
346
399
|
@constraint.attribute2.should == [:width, :height]
|
347
400
|
end
|
401
|
+
|
348
402
|
it 'should support `size.equals(:another_view).divided_by(2)`' do
|
349
|
-
@layout.context(
|
403
|
+
@layout.context(@view) do
|
350
404
|
@layout.constraints do
|
351
405
|
@constraint = @layout.size.equals(:another_view).divided_by(2)
|
352
406
|
end
|
353
407
|
end
|
408
|
+
|
354
409
|
@constraint.constant.should == [0, 0]
|
355
410
|
@constraint.relationship.should == :equal
|
356
411
|
@constraint.multiplier.should == [0.5, 0.5]
|