motion-kit 0.11.1 → 0.11.2

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.
@@ -3,12 +3,14 @@ describe 'Constraints - Relative corners helpers' do
3
3
  before do
4
4
  @layout = MK::Layout.new
5
5
  @constraint = nil
6
- @view = nil
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 `top_left [10, 10]`' do
11
- @view = @layout.context(UIView.new) do
13
+ @layout.context(@view) do
12
14
  @layout.constraints do
13
15
  @constraint = @layout.top_left([10, 10])
14
16
  end
@@ -26,21 +28,21 @@ describe 'Constraints - Relative corners helpers' do
26
28
  resolved[0].firstItem.should == @view
27
29
  resolved[0].firstAttribute.should == NSLayoutAttributeLeft
28
30
  resolved[0].relation.should == NSLayoutRelationEqual
29
- resolved[0].secondItem.should == nil
30
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
31
+ resolved[0].secondItem.should == @parent_view
32
+ resolved[0].secondAttribute.should == NSLayoutAttributeLeft
31
33
  resolved[0].multiplier.should == 1
32
34
  resolved[0].constant.should == 10
33
35
 
34
36
  resolved[1].firstItem.should == @view
35
37
  resolved[1].firstAttribute.should == NSLayoutAttributeTop
36
38
  resolved[1].relation.should == NSLayoutRelationEqual
37
- resolved[1].secondItem.should == nil
38
- resolved[1].secondAttribute.should == NSLayoutAttributeNotAnAttribute
39
+ resolved[1].secondItem.should == @parent_view
40
+ resolved[1].secondAttribute.should == NSLayoutAttributeTop
39
41
  resolved[1].multiplier.should == 1
40
42
  resolved[1].constant.should == 10
41
43
  end
42
44
  it 'should support `top_left.equals(:another_view).plus(10).plus([5, 10])`' do
43
- @view = @layout.context(UIView.new) do
45
+ @layout.context(@view) do
44
46
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
45
47
  @layout.constraints do
46
48
  @constraint = @layout.top_left.equals(:another_view).plus(10).plus([5, 10])
@@ -74,7 +76,7 @@ describe 'Constraints - Relative corners helpers' do
74
76
  end
75
77
 
76
78
  it 'should support `top_right [10, 10]`' do
77
- @view = @layout.context(UIView.new) do
79
+ @layout.context(@view) do
78
80
  @layout.constraints do
79
81
  @constraint = @layout.top_right([10, 10])
80
82
  end
@@ -92,21 +94,21 @@ describe 'Constraints - Relative corners helpers' do
92
94
  resolved[0].firstItem.should == @view
93
95
  resolved[0].firstAttribute.should == NSLayoutAttributeRight
94
96
  resolved[0].relation.should == NSLayoutRelationEqual
95
- resolved[0].secondItem.should == nil
96
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
97
+ resolved[0].secondItem.should == @parent_view
98
+ resolved[0].secondAttribute.should == NSLayoutAttributeRight
97
99
  resolved[0].multiplier.should == 1
98
100
  resolved[0].constant.should == 10
99
101
 
100
102
  resolved[1].firstItem.should == @view
101
103
  resolved[1].firstAttribute.should == NSLayoutAttributeTop
102
104
  resolved[1].relation.should == NSLayoutRelationEqual
103
- resolved[1].secondItem.should == nil
104
- resolved[1].secondAttribute.should == NSLayoutAttributeNotAnAttribute
105
+ resolved[1].secondItem.should == @parent_view
106
+ resolved[1].secondAttribute.should == NSLayoutAttributeTop
105
107
  resolved[1].multiplier.should == 1
106
108
  resolved[1].constant.should == 10
107
109
  end
108
110
  it 'should support `top_right.equals(:another_view).plus(10).plus([5, 10])`' do
109
- @view = @layout.context(UIView.new) do
111
+ @layout.context(@view) do
110
112
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
111
113
  @layout.constraints do
112
114
  @constraint = @layout.top_right.equals(:another_view).plus(10).plus([5, 10])
@@ -140,7 +142,7 @@ describe 'Constraints - Relative corners helpers' do
140
142
  end
141
143
 
142
144
  it 'should support `bottom_left [10, 10]`' do
143
- @view = @layout.context(UIView.new) do
145
+ @layout.context(@view) do
144
146
  @layout.constraints do
145
147
  @constraint = @layout.bottom_left([10, 10])
146
148
  end
@@ -158,21 +160,21 @@ describe 'Constraints - Relative corners helpers' do
158
160
  resolved[0].firstItem.should == @view
159
161
  resolved[0].firstAttribute.should == NSLayoutAttributeLeft
160
162
  resolved[0].relation.should == NSLayoutRelationEqual
161
- resolved[0].secondItem.should == nil
162
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
163
+ resolved[0].secondItem.should == @parent_view
164
+ resolved[0].secondAttribute.should == NSLayoutAttributeLeft
163
165
  resolved[0].multiplier.should == 1
164
166
  resolved[0].constant.should == 10
165
167
 
166
168
  resolved[1].firstItem.should == @view
167
169
  resolved[1].firstAttribute.should == NSLayoutAttributeBottom
168
170
  resolved[1].relation.should == NSLayoutRelationEqual
169
- resolved[1].secondItem.should == nil
170
- resolved[1].secondAttribute.should == NSLayoutAttributeNotAnAttribute
171
+ resolved[1].secondItem.should == @parent_view
172
+ resolved[1].secondAttribute.should == NSLayoutAttributeBottom
171
173
  resolved[1].multiplier.should == 1
172
174
  resolved[1].constant.should == 10
173
175
  end
174
176
  it 'should support `bottom_left.equals(:another_view).plus(10).plus([5, 10])`' do
175
- @view = @layout.context(UIView.new) do
177
+ @layout.context(@view) do
176
178
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
177
179
  @layout.constraints do
178
180
  @constraint = @layout.bottom_left.equals(:another_view).plus(10).plus([5, 10])
@@ -206,7 +208,7 @@ describe 'Constraints - Relative corners helpers' do
206
208
  end
207
209
 
208
210
  it 'should support `bottom_right [10, 10]`' do
209
- @view = @layout.context(UIView.new) do
211
+ @layout.context(@view) do
210
212
  @layout.constraints do
211
213
  @constraint = @layout.bottom_right([10, 10])
212
214
  end
@@ -224,21 +226,21 @@ describe 'Constraints - Relative corners helpers' do
224
226
  resolved[0].firstItem.should == @view
225
227
  resolved[0].firstAttribute.should == NSLayoutAttributeRight
226
228
  resolved[0].relation.should == NSLayoutRelationEqual
227
- resolved[0].secondItem.should == nil
228
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
229
+ resolved[0].secondItem.should == @parent_view
230
+ resolved[0].secondAttribute.should == NSLayoutAttributeRight
229
231
  resolved[0].multiplier.should == 1
230
232
  resolved[0].constant.should == 10
231
233
 
232
234
  resolved[1].firstItem.should == @view
233
235
  resolved[1].firstAttribute.should == NSLayoutAttributeBottom
234
236
  resolved[1].relation.should == NSLayoutRelationEqual
235
- resolved[1].secondItem.should == nil
236
- resolved[1].secondAttribute.should == NSLayoutAttributeNotAnAttribute
237
+ resolved[1].secondItem.should == @parent_view
238
+ resolved[1].secondAttribute.should == NSLayoutAttributeBottom
237
239
  resolved[1].multiplier.should == 1
238
240
  resolved[1].constant.should == 10
239
241
  end
240
242
  it 'should support `bottom_right.equals(:another_view).plus(10).plus([5, 10])`' do
241
- @view = @layout.context(UIView.new) do
243
+ @layout.context(@view) do
242
244
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
243
245
  @layout.constraints do
244
246
  @constraint = @layout.bottom_right.equals(:another_view).plus(10).plus([5, 10])
@@ -3,12 +3,14 @@ describe 'Constraints - Relative location helpers' do
3
3
  before do
4
4
  @layout = MK::Layout.new
5
5
  @constraint = nil
6
- @view = nil
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 `above(:another_view)`' do
11
- @view = @layout.context(UIView.new) do
13
+ @layout.context(@view) do
12
14
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
13
15
  @layout.constraints do
14
16
  @constraint = @layout.above(:another_view)
@@ -33,7 +35,7 @@ describe 'Constraints - Relative location helpers' do
33
35
  resolved[0].constant.should == 0
34
36
  end
35
37
  it 'should support `below(:another_view)`' do
36
- @view = @layout.context(UIView.new) do
38
+ @layout.context(@view) do
37
39
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
38
40
  @layout.constraints do
39
41
  @constraint = @layout.below(:another_view)
@@ -58,7 +60,7 @@ describe 'Constraints - Relative location helpers' do
58
60
  resolved[0].constant.should == 0
59
61
  end
60
62
  it 'should support `before(:another_view)`' do
61
- @view = @layout.context(UIView.new) do
63
+ @layout.context(@view) do
62
64
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
63
65
  @layout.constraints do
64
66
  @constraint = @layout.before(:another_view)
@@ -83,7 +85,7 @@ describe 'Constraints - Relative location helpers' do
83
85
  resolved[0].constant.should == 0
84
86
  end
85
87
  it 'should support `after(:another_view)`' do
86
- @view = @layout.context(UIView.new) do
88
+ @layout.context(@view) do
87
89
  @another_view = @layout.add UIView.alloc.initWithFrame([[1, 1], [2, 2]]), :another_view
88
90
  @layout.constraints do
89
91
  @constraint = @layout.after(:another_view)
@@ -3,13 +3,15 @@ describe 'Constraints - Simple helpers' do
3
3
  before do
4
4
  @layout = MotionKit::Layout.new
5
5
  @constraint = nil
6
- @view = nil
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
  describe '`x/left` support' do
11
13
  it 'should support `x 10`' do
12
- @view = @layout.context(UIView.new) do
14
+ @layout.context(@view) do
13
15
  @layout.constraints do
14
16
  @constraint = @layout.x(10)
15
17
  end
@@ -27,13 +29,13 @@ describe 'Constraints - Simple helpers' do
27
29
  resolved[0].firstItem.should.be.kind_of(UIView)
28
30
  resolved[0].firstAttribute.should == NSLayoutAttributeLeft
29
31
  resolved[0].relation.should == NSLayoutRelationEqual
30
- resolved[0].secondItem.should == nil
31
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
32
+ resolved[0].secondItem.should == @parent_view
33
+ resolved[0].secondAttribute.should == NSLayoutAttributeLeft
32
34
  resolved[0].multiplier.should == 1
33
35
  resolved[0].constant.should == 10
34
36
  end
35
37
  it 'should update the constraint' do
36
- @view = @layout.context(UIView.new) do
38
+ @layout.context(@view) do
37
39
  @layout.constraints do
38
40
  @constraint = @layout.x(10)
39
41
  end
@@ -49,7 +51,7 @@ describe 'Constraints - Simple helpers' do
49
51
  resolved[0].constant.should == 100
50
52
  end
51
53
  it 'should support `x.is == 10`' do
52
- @view = @layout.context(UIView.new) do
54
+ @layout.context(@view) do
53
55
  @layout.constraints do
54
56
  @constraint = @layout.x.is == 10
55
57
  end
@@ -63,7 +65,7 @@ describe 'Constraints - Simple helpers' do
63
65
  @constraint.attribute2.should == :left
64
66
  end
65
67
  it 'should support `x.is <= 10`' do
66
- @view = @layout.context(UIView.new) do
68
+ @layout.context(@view) do
67
69
  @layout.constraints do
68
70
  @constraint = @layout.x.is <= 10
69
71
  end
@@ -77,7 +79,7 @@ describe 'Constraints - Simple helpers' do
77
79
  @constraint.attribute2.should == :left
78
80
  end
79
81
  it 'should support `min_x.is == 10`' do
80
- @view = @layout.context(UIView.new) do
82
+ @layout.context(@view) do
81
83
  @layout.constraints do
82
84
  @constraint = @layout.min_x.is == 10
83
85
  end
@@ -91,17 +93,16 @@ describe 'Constraints - Simple helpers' do
91
93
  @constraint.attribute2.should == :left
92
94
  end
93
95
  it 'should NOT support `min_x.is >= 10`' do
94
- @layout.context(UIView.new) do
95
- @layout.constraints do
96
- -> do
97
- @layout.min_x.is >= 10
98
- end.should.raise(MotionKit::InvalidRelationshipError)
96
+ -> do
97
+ @layout.context(@view) do
98
+ @layout.constraints do
99
+ p @layout.min_x.is <= 10
100
+ end
99
101
  end
100
- end
101
-
102
+ end.should.raise(MotionKit::InvalidRelationshipError)
102
103
  end
103
104
  it 'should support `(x.is >= 10).priority(:low)`' do
104
- @view = @layout.context(UIView.new) do
105
+ @layout.context(@view) do
105
106
  @layout.constraints do
106
107
  @constraint = (@layout.x.is >= 10).priority(:low)
107
108
  end
@@ -116,7 +117,7 @@ describe 'Constraints - Simple helpers' do
116
117
  @constraint.priority.should == :low
117
118
  end
118
119
  it 'should support `min_x 10`' do
119
- @view = @layout.context(UIView.new) do
120
+ @layout.context(@view) do
120
121
  @layout.constraints do
121
122
  @constraint = @layout.min_x(10)
122
123
  end
@@ -130,7 +131,7 @@ describe 'Constraints - Simple helpers' do
130
131
  @constraint.attribute2.should == :left
131
132
  end
132
133
  it 'should support `min_x.equals "50%"`' do
133
- @superview = @layout.context(UIView.new) do
134
+ @layout.context(@parent_view) do
134
135
  @view = @layout.add(UIView.new) do
135
136
  @layout.constraints do
136
137
  @constraint = @layout.min_x('50%')
@@ -146,7 +147,7 @@ describe 'Constraints - Simple helpers' do
146
147
  @constraint.attribute2.should == :left
147
148
  end
148
149
  it 'should support `min_x.equals("50%").of(:another_view)`' do
149
- @superview = @layout.context(UIView.new) do
150
+ @layout.context(@parent_view) do
150
151
  @view = @layout.add(UIView.new) do
151
152
  @layout.constraints do
152
153
  @constraint = @layout.min_x.equals('50%').of(:another_view)
@@ -163,7 +164,7 @@ describe 'Constraints - Simple helpers' do
163
164
  @constraint.attribute2.should == :left
164
165
  end
165
166
  it 'should support `min_x.equals("50%").of(:another_view, :right)`' do
166
- @superview = @layout.context(UIView.new) do
167
+ @layout.context(@parent_view) do
167
168
  @view = @layout.add(UIView.new) do
168
169
  @layout.constraints do
169
170
  @constraint = @layout.min_x.equals('50%').of(:another_view, :right)
@@ -180,7 +181,7 @@ describe 'Constraints - Simple helpers' do
180
181
  @constraint.attribute2.should == :right
181
182
  end
182
183
  it 'should support `max_x 10`' do
183
- @view = @layout.context(UIView.new) do
184
+ @layout.context(@view) do
184
185
  @layout.constraints do
185
186
  @constraint = @layout.max_x(10)
186
187
  end
@@ -194,7 +195,7 @@ describe 'Constraints - Simple helpers' do
194
195
  @constraint.attribute2.should == :left
195
196
  end
196
197
  it 'should support `x.equals(:another_view[, :left])`' do
197
- @view = @layout.context(UIView.new) do
198
+ @layout.context(@view) do
198
199
  @layout.constraints do
199
200
  @constraint = @layout.x.equals(:another_view)
200
201
  end
@@ -209,7 +210,7 @@ describe 'Constraints - Simple helpers' do
209
210
  @constraint.attribute2.should == :left
210
211
  end
211
212
  it 'should support `x.equals(:another_view).plus(10).plus(20)`' do
212
- @view = @layout.context(UIView.new) do
213
+ @layout.context(@view) do
213
214
  @layout.constraints do
214
215
  @constraint = @layout.x.equals(:another_view).plus(10).plus(20)
215
216
  end
@@ -224,7 +225,7 @@ describe 'Constraints - Simple helpers' do
224
225
  @constraint.attribute2.should == :left
225
226
  end
226
227
  it 'should support `x.equals(:another_view).minus(10)`' do
227
- @view = @layout.context(UIView.new) do
228
+ @layout.context(@view) do
228
229
  @layout.constraints do
229
230
  @constraint = @layout.x.equals(:another_view).minus(10)
230
231
  end
@@ -239,7 +240,7 @@ describe 'Constraints - Simple helpers' do
239
240
  @constraint.attribute2.should == :left
240
241
  end
241
242
  it 'should support `min_x.equals(:another_view[, :left])`' do
242
- @view = @layout.context(UIView.new) do
243
+ @layout.context(@view) do
243
244
  @layout.constraints do
244
245
  @constraint = @layout.min_x.equals(:another_view)
245
246
  end
@@ -254,7 +255,7 @@ describe 'Constraints - Simple helpers' do
254
255
  @constraint.attribute2.should == :left
255
256
  end
256
257
  it 'should support `max_x.equals(:another_view[, :left])`' do
257
- @view = @layout.context(UIView.new) do
258
+ @layout.context(@view) do
258
259
  @layout.constraints do
259
260
  @constraint = @layout.max_x.equals(:another_view)
260
261
  end
@@ -269,7 +270,7 @@ describe 'Constraints - Simple helpers' do
269
270
  @constraint.attribute2.should == :left
270
271
  end
271
272
  it 'should support `x.equals(:another_view, :right)`' do
272
- @view = @layout.context(UIView.new) do
273
+ @layout.context(@view) do
273
274
  @layout.constraints do
274
275
  @constraint = @layout.x.equals(:another_view, :right)
275
276
  end
@@ -284,7 +285,7 @@ describe 'Constraints - Simple helpers' do
284
285
  @constraint.attribute2.should == :right
285
286
  end
286
287
  it 'should support `min_x.equals(:another_view, :right)`' do
287
- @view = @layout.context(UIView.new) do
288
+ @layout.context(@view) do
288
289
  @layout.constraints do
289
290
  @constraint = @layout.min_x.equals(:another_view, :right)
290
291
  end
@@ -299,7 +300,7 @@ describe 'Constraints - Simple helpers' do
299
300
  @constraint.attribute2.should == :right
300
301
  end
301
302
  it 'should support `max_x.equals(:another_view, :right)`' do
302
- @view = @layout.context(UIView.new) do
303
+ @layout.context(@view) do
303
304
  @layout.constraints do
304
305
  @constraint = @layout.max_x.equals(:another_view, :right)
305
306
  end
@@ -314,7 +315,7 @@ describe 'Constraints - Simple helpers' do
314
315
  @constraint.attribute2.should == :right
315
316
  end
316
317
  it 'should support `x.equals(:another_view, :right).plus(10)`' do
317
- @view = @layout.context(UIView.new) do
318
+ @layout.context(@view) do
318
319
  @layout.constraints do
319
320
  @constraint = @layout.x.equals(:another_view, :right).plus(10)
320
321
  end
@@ -329,7 +330,7 @@ describe 'Constraints - Simple helpers' do
329
330
  @constraint.attribute2.should == :right
330
331
  end
331
332
  it 'should support `min_x.equals(:another_view, :right).plus(10)`' do
332
- @view = @layout.context(UIView.new) do
333
+ @layout.context(@view) do
333
334
  @layout.constraints do
334
335
  @constraint = @layout.min_x.equals(:another_view, :right).plus(10)
335
336
  end
@@ -344,7 +345,7 @@ describe 'Constraints - Simple helpers' do
344
345
  @constraint.attribute2.should == :right
345
346
  end
346
347
  it 'should support `max_x.equals(:another_view, :right).plus(10)`' do
347
- @view = @layout.context(UIView.new) do
348
+ @layout.context(@view) do
348
349
  @layout.constraints do
349
350
  @constraint = @layout.max_x.equals(:another_view, :right).plus(10)
350
351
  end
@@ -359,7 +360,7 @@ describe 'Constraints - Simple helpers' do
359
360
  @constraint.attribute2.should == :right
360
361
  end
361
362
  it 'should support `x.equals(:another_view).times(2).plus(10)`' do
362
- @view = @layout.context(UIView.new) do
363
+ @layout.context(@view) do
363
364
  @layout.constraints do
364
365
  @constraint = @layout.x.equals(:another_view).times(2).plus(10)
365
366
  end
@@ -374,7 +375,7 @@ describe 'Constraints - Simple helpers' do
374
375
  @constraint.attribute2.should == :left
375
376
  end
376
377
  it 'should support `x.equals(:another_view).times(2).times(3)`' do
377
- @view = @layout.context(UIView.new) do
378
+ @layout.context(@view) do
378
379
  @layout.constraints do
379
380
  @constraint = @layout.x.equals(:another_view).times(2).times(3)
380
381
  end
@@ -389,7 +390,7 @@ describe 'Constraints - Simple helpers' do
389
390
  @constraint.attribute2.should == :left
390
391
  end
391
392
  it 'should support `x.equals(:another_view).divided_by(2)`' do
392
- @view = @layout.context(UIView.new) do
393
+ @layout.context(@view) do
393
394
  @layout.constraints do
394
395
  @constraint = @layout.x.equals(:another_view).divided_by(2)
395
396
  end
@@ -404,7 +405,7 @@ describe 'Constraints - Simple helpers' do
404
405
  @constraint.attribute2.should == :left
405
406
  end
406
407
  it 'should support `min_x.equals(:another_view).times(2).plus(10)`' do
407
- @view = @layout.context(UIView.new) do
408
+ @layout.context(@view) do
408
409
  @layout.constraints do
409
410
  @constraint = @layout.min_x.equals(:another_view).times(2).plus(10)
410
411
  end
@@ -419,7 +420,7 @@ describe 'Constraints - Simple helpers' do
419
420
  @constraint.attribute2.should == :left
420
421
  end
421
422
  it 'should support `max_x.equals(:another_view).times(2).plus(10)`' do
422
- @view = @layout.context(UIView.new) do
423
+ @layout.context(@view) do
423
424
  @layout.constraints do
424
425
  @constraint = @layout.max_x.equals(:another_view).times(2).plus(10)
425
426
  end
@@ -434,7 +435,7 @@ describe 'Constraints - Simple helpers' do
434
435
  @constraint.attribute2.should == :left
435
436
  end
436
437
  it 'should support `left.equals(:another_view).times(2).plus(10)`' do
437
- @view = @layout.context(UIView.new) do
438
+ @layout.context(@view) do
438
439
  @layout.constraints do
439
440
  @constraint = @layout.left.equals(:another_view).times(2).plus(10)
440
441
  end
@@ -449,7 +450,7 @@ describe 'Constraints - Simple helpers' do
449
450
  @constraint.attribute2.should == :left
450
451
  end
451
452
  it 'should support `min_left.equals(:another_view).times(2).plus(10)`' do
452
- @view = @layout.context(UIView.new) do
453
+ @layout.context(@view) do
453
454
  @layout.constraints do
454
455
  @constraint = @layout.min_left.equals(:another_view).times(2).plus(10)
455
456
  end
@@ -464,7 +465,7 @@ describe 'Constraints - Simple helpers' do
464
465
  @constraint.attribute2.should == :left
465
466
  end
466
467
  it 'should support `max_left.equals(:another_view).times(2).plus(10)`' do
467
- @view = @layout.context(UIView.new) do
468
+ @layout.context(@view) do
468
469
  @layout.constraints do
469
470
  @constraint = @layout.max_left.equals(:another_view).times(2).plus(10)
470
471
  end
@@ -492,7 +493,7 @@ describe 'Constraints - Simple helpers' do
492
493
 
493
494
  describe '`center_x` support' do
494
495
  it 'should support `center_x 10`' do
495
- @view = @layout.context(UIView.new) do
496
+ @layout.context(@view) do
496
497
  @layout.constraints do
497
498
  @constraint = @layout.center_x(10)
498
499
  end
@@ -510,13 +511,13 @@ describe 'Constraints - Simple helpers' do
510
511
  resolved[0].firstItem.should.be.kind_of(UIView)
511
512
  resolved[0].firstAttribute.should == NSLayoutAttributeCenterX
512
513
  resolved[0].relation.should == NSLayoutRelationEqual
513
- resolved[0].secondItem.should == nil
514
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
514
+ resolved[0].secondItem.should == @parent_view
515
+ resolved[0].secondAttribute.should == NSLayoutAttributeCenterX
515
516
  resolved[0].multiplier.should == 1
516
517
  resolved[0].constant.should == 10
517
518
  end
518
519
  it 'should support `min_center_x 10`' do
519
- @view = @layout.context(UIView.new) do
520
+ @layout.context(@view) do
520
521
  @layout.constraints do
521
522
  @constraint = @layout.min_center_x(10)
522
523
  end
@@ -530,7 +531,7 @@ describe 'Constraints - Simple helpers' do
530
531
  @constraint.attribute2.should == :center_x
531
532
  end
532
533
  it 'should support `max_center_x 10`' do
533
- @view = @layout.context(UIView.new) do
534
+ @layout.context(@view) do
534
535
  @layout.constraints do
535
536
  @constraint = @layout.max_center_x(10)
536
537
  end
@@ -544,7 +545,7 @@ describe 'Constraints - Simple helpers' do
544
545
  @constraint.attribute2.should == :center_x
545
546
  end
546
547
  it 'should support `center_x.equals(:another_view[, :center_x])`' do
547
- @view = @layout.context(UIView.new) do
548
+ @layout.context(@view) do
548
549
  @layout.constraints do
549
550
  @constraint = @layout.center_x.equals(:another_view)
550
551
  end
@@ -559,7 +560,7 @@ describe 'Constraints - Simple helpers' do
559
560
  @constraint.attribute2.should == :center_x
560
561
  end
561
562
  it 'should support `min_center_x.equals(:another_view[, :center_x])`' do
562
- @view = @layout.context(UIView.new) do
563
+ @layout.context(@view) do
563
564
  @layout.constraints do
564
565
  @constraint = @layout.min_center_x.equals(:another_view)
565
566
  end
@@ -574,7 +575,7 @@ describe 'Constraints - Simple helpers' do
574
575
  @constraint.attribute2.should == :center_x
575
576
  end
576
577
  it 'should support `max_center_x.equals(:another_view[, :center_x])`' do
577
- @view = @layout.context(UIView.new) do
578
+ @layout.context(@view) do
578
579
  @layout.constraints do
579
580
  @constraint = @layout.max_center_x.equals(:another_view)
580
581
  end
@@ -589,7 +590,7 @@ describe 'Constraints - Simple helpers' do
589
590
  @constraint.attribute2.should == :center_x
590
591
  end
591
592
  it 'should support `center_x.equals(:another_view, :right)`' do
592
- @view = @layout.context(UIView.new) do
593
+ @layout.context(@view) do
593
594
  @layout.constraints do
594
595
  @constraint = @layout.center_x.equals(:another_view, :right)
595
596
  end
@@ -604,7 +605,7 @@ describe 'Constraints - Simple helpers' do
604
605
  @constraint.attribute2.should == :right
605
606
  end
606
607
  it 'should support `min_center_x.equals(:another_view, :right)`' do
607
- @view = @layout.context(UIView.new) do
608
+ @layout.context(@view) do
608
609
  @layout.constraints do
609
610
  @constraint = @layout.min_center_x.equals(:another_view, :right)
610
611
  end
@@ -619,7 +620,7 @@ describe 'Constraints - Simple helpers' do
619
620
  @constraint.attribute2.should == :right
620
621
  end
621
622
  it 'should support `max_center_x.equals(:another_view, :right)`' do
622
- @view = @layout.context(UIView.new) do
623
+ @layout.context(@view) do
623
624
  @layout.constraints do
624
625
  @constraint = @layout.max_center_x.equals(:another_view, :right)
625
626
  end
@@ -634,7 +635,7 @@ describe 'Constraints - Simple helpers' do
634
635
  @constraint.attribute2.should == :right
635
636
  end
636
637
  it 'should support `center_x.equals(:another_view, :right).plus(10)`' do
637
- @view = @layout.context(UIView.new) do
638
+ @layout.context(@view) do
638
639
  @layout.constraints do
639
640
  @constraint = @layout.center_x.equals(:another_view, :right).plus(10)
640
641
  end
@@ -649,7 +650,7 @@ describe 'Constraints - Simple helpers' do
649
650
  @constraint.attribute2.should == :right
650
651
  end
651
652
  it 'should support `min_center_x.equals(:another_view, :right).plus(10)`' do
652
- @view = @layout.context(UIView.new) do
653
+ @layout.context(@view) do
653
654
  @layout.constraints do
654
655
  @constraint = @layout.min_center_x.equals(:another_view, :right).plus(10)
655
656
  end
@@ -664,7 +665,7 @@ describe 'Constraints - Simple helpers' do
664
665
  @constraint.attribute2.should == :right
665
666
  end
666
667
  it 'should support `max_center_x.equals(:another_view, :right).plus(10)`' do
667
- @view = @layout.context(UIView.new) do
668
+ @layout.context(@view) do
668
669
  @layout.constraints do
669
670
  @constraint = @layout.max_center_x.equals(:another_view, :right).plus(10)
670
671
  end
@@ -679,7 +680,7 @@ describe 'Constraints - Simple helpers' do
679
680
  @constraint.attribute2.should == :right
680
681
  end
681
682
  it 'should support `center_x.equals(:another_view).times(2).plus(10)`' do
682
- @view = @layout.context(UIView.new) do
683
+ @layout.context(@view) do
683
684
  @layout.constraints do
684
685
  @constraint = @layout.center_x.equals(:another_view).times(2).plus(10)
685
686
  end
@@ -694,7 +695,7 @@ describe 'Constraints - Simple helpers' do
694
695
  @constraint.attribute2.should == :center_x
695
696
  end
696
697
  it 'should support `min_center_x.equals(:another_view).times(2).plus(10)`' do
697
- @view = @layout.context(UIView.new) do
698
+ @layout.context(@view) do
698
699
  @layout.constraints do
699
700
  @constraint = @layout.min_center_x.equals(:another_view).times(2).plus(10)
700
701
  end
@@ -709,7 +710,7 @@ describe 'Constraints - Simple helpers' do
709
710
  @constraint.attribute2.should == :center_x
710
711
  end
711
712
  it 'should support `max_center_x.equals(:another_view).times(2).plus(10)`' do
712
- @view = @layout.context(UIView.new) do
713
+ @layout.context(@view) do
713
714
  @layout.constraints do
714
715
  @constraint = @layout.max_center_x.equals(:another_view).times(2).plus(10)
715
716
  end
@@ -737,7 +738,7 @@ describe 'Constraints - Simple helpers' do
737
738
 
738
739
  describe '`right` support' do
739
740
  it 'should support `right 10`' do
740
- @view = @layout.context(UIView.new) do
741
+ @layout.context(@view) do
741
742
  @layout.constraints do
742
743
  @constraint = @layout.right(10)
743
744
  end
@@ -755,13 +756,13 @@ describe 'Constraints - Simple helpers' do
755
756
  resolved[0].firstItem.should.be.kind_of(UIView)
756
757
  resolved[0].firstAttribute.should == NSLayoutAttributeRight
757
758
  resolved[0].relation.should == NSLayoutRelationEqual
758
- resolved[0].secondItem.should == nil
759
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
759
+ resolved[0].secondItem.should == @parent_view
760
+ resolved[0].secondAttribute.should == NSLayoutAttributeRight
760
761
  resolved[0].multiplier.should == 1
761
762
  resolved[0].constant.should == 10
762
763
  end
763
764
  it 'should support `min_right 10`' do
764
- @view = @layout.context(UIView.new) do
765
+ @layout.context(@view) do
765
766
  @layout.constraints do
766
767
  @constraint = @layout.min_right(10)
767
768
  end
@@ -775,7 +776,7 @@ describe 'Constraints - Simple helpers' do
775
776
  @constraint.attribute2.should == :right
776
777
  end
777
778
  it 'should support `max_right 10`' do
778
- @view = @layout.context(UIView.new) do
779
+ @layout.context(@view) do
779
780
  @layout.constraints do
780
781
  @constraint = @layout.max_right(10)
781
782
  end
@@ -789,7 +790,7 @@ describe 'Constraints - Simple helpers' do
789
790
  @constraint.attribute2.should == :right
790
791
  end
791
792
  it 'should support `right.equals(:another_view[, :right])`' do
792
- @view = @layout.context(UIView.new) do
793
+ @layout.context(@view) do
793
794
  @layout.constraints do
794
795
  @constraint = @layout.right.equals(:another_view)
795
796
  end
@@ -804,7 +805,7 @@ describe 'Constraints - Simple helpers' do
804
805
  @constraint.attribute2.should == :right
805
806
  end
806
807
  it 'should support `min_right.equals(:another_view[, :right])`' do
807
- @view = @layout.context(UIView.new) do
808
+ @layout.context(@view) do
808
809
  @layout.constraints do
809
810
  @constraint = @layout.min_right.equals(:another_view)
810
811
  end
@@ -819,7 +820,7 @@ describe 'Constraints - Simple helpers' do
819
820
  @constraint.attribute2.should == :right
820
821
  end
821
822
  it 'should support `max_right.equals(:another_view[, :right])`' do
822
- @view = @layout.context(UIView.new) do
823
+ @layout.context(@view) do
823
824
  @layout.constraints do
824
825
  @constraint = @layout.max_right.equals(:another_view)
825
826
  end
@@ -834,7 +835,7 @@ describe 'Constraints - Simple helpers' do
834
835
  @constraint.attribute2.should == :right
835
836
  end
836
837
  it 'should support `right.equals(:another_view, :left)`' do
837
- @view = @layout.context(UIView.new) do
838
+ @layout.context(@view) do
838
839
  @layout.constraints do
839
840
  @constraint = @layout.right.equals(:another_view, :left)
840
841
  end
@@ -849,7 +850,7 @@ describe 'Constraints - Simple helpers' do
849
850
  @constraint.attribute2.should == :left
850
851
  end
851
852
  it 'should support `min_right.equals(:another_view, :left)`' do
852
- @view = @layout.context(UIView.new) do
853
+ @layout.context(@view) do
853
854
  @layout.constraints do
854
855
  @constraint = @layout.min_right.equals(:another_view, :left)
855
856
  end
@@ -864,7 +865,7 @@ describe 'Constraints - Simple helpers' do
864
865
  @constraint.attribute2.should == :left
865
866
  end
866
867
  it 'should support `max_right.equals(:another_view, :left)`' do
867
- @view = @layout.context(UIView.new) do
868
+ @layout.context(@view) do
868
869
  @layout.constraints do
869
870
  @constraint = @layout.max_right.equals(:another_view, :left)
870
871
  end
@@ -879,7 +880,7 @@ describe 'Constraints - Simple helpers' do
879
880
  @constraint.attribute2.should == :left
880
881
  end
881
882
  it 'should support `right.equals(:another_view, :left).plus(10)`' do
882
- @view = @layout.context(UIView.new) do
883
+ @layout.context(@view) do
883
884
  @layout.constraints do
884
885
  @constraint = @layout.right.equals(:another_view, :left).plus(10)
885
886
  end
@@ -894,7 +895,7 @@ describe 'Constraints - Simple helpers' do
894
895
  @constraint.attribute2.should == :left
895
896
  end
896
897
  it 'should support `min_right.equals(:another_view, :left).plus(10)`' do
897
- @view = @layout.context(UIView.new) do
898
+ @layout.context(@view) do
898
899
  @layout.constraints do
899
900
  @constraint = @layout.min_right.equals(:another_view, :left).plus(10)
900
901
  end
@@ -909,7 +910,7 @@ describe 'Constraints - Simple helpers' do
909
910
  @constraint.attribute2.should == :left
910
911
  end
911
912
  it 'should support `max_right.equals(:another_view, :left).plus(10)`' do
912
- @view = @layout.context(UIView.new) do
913
+ @layout.context(@view) do
913
914
  @layout.constraints do
914
915
  @constraint = @layout.max_right.equals(:another_view, :left).plus(10)
915
916
  end
@@ -924,7 +925,7 @@ describe 'Constraints - Simple helpers' do
924
925
  @constraint.attribute2.should == :left
925
926
  end
926
927
  it 'should support `right.equals(:another_view).times(2).plus(10)`' do
927
- @view = @layout.context(UIView.new) do
928
+ @layout.context(@view) do
928
929
  @layout.constraints do
929
930
  @constraint = @layout.right.equals(:another_view).times(2).plus(10)
930
931
  end
@@ -939,7 +940,7 @@ describe 'Constraints - Simple helpers' do
939
940
  @constraint.attribute2.should == :right
940
941
  end
941
942
  it 'should support `min_right.equals(:another_view).times(2).plus(10)`' do
942
- @view = @layout.context(UIView.new) do
943
+ @layout.context(@view) do
943
944
  @layout.constraints do
944
945
  @constraint = @layout.min_right.equals(:another_view).times(2).plus(10)
945
946
  end
@@ -954,7 +955,7 @@ describe 'Constraints - Simple helpers' do
954
955
  @constraint.attribute2.should == :right
955
956
  end
956
957
  it 'should support `max_right.equals(:another_view).times(2).plus(10)`' do
957
- @view = @layout.context(UIView.new) do
958
+ @layout.context(@view) do
958
959
  @layout.constraints do
959
960
  @constraint = @layout.max_right.equals(:another_view).times(2).plus(10)
960
961
  end
@@ -982,7 +983,7 @@ describe 'Constraints - Simple helpers' do
982
983
 
983
984
  describe '`y/top` support' do
984
985
  it 'should support `y 10`' do
985
- @view = @layout.context(UIView.new) do
986
+ @layout.context(@view) do
986
987
  @layout.constraints do
987
988
  @constraint = @layout.y(10)
988
989
  end
@@ -1000,13 +1001,13 @@ describe 'Constraints - Simple helpers' do
1000
1001
  resolved[0].firstItem.should.be.kind_of(UIView)
1001
1002
  resolved[0].firstAttribute.should == NSLayoutAttributeTop
1002
1003
  resolved[0].relation.should == NSLayoutRelationEqual
1003
- resolved[0].secondItem.should == nil
1004
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
1004
+ resolved[0].secondItem.should == @parent_view
1005
+ resolved[0].secondAttribute.should == NSLayoutAttributeTop
1005
1006
  resolved[0].multiplier.should == 1
1006
1007
  resolved[0].constant.should == 10
1007
1008
  end
1008
1009
  it 'should support `min_y 10`' do
1009
- @view = @layout.context(UIView.new) do
1010
+ @layout.context(@view) do
1010
1011
  @layout.constraints do
1011
1012
  @constraint = @layout.min_y(10)
1012
1013
  end
@@ -1020,7 +1021,7 @@ describe 'Constraints - Simple helpers' do
1020
1021
  @constraint.attribute2.should == :top
1021
1022
  end
1022
1023
  it 'should support `max_y 10`' do
1023
- @view = @layout.context(UIView.new) do
1024
+ @layout.context(@view) do
1024
1025
  @layout.constraints do
1025
1026
  @constraint = @layout.max_y(10)
1026
1027
  end
@@ -1034,7 +1035,7 @@ describe 'Constraints - Simple helpers' do
1034
1035
  @constraint.attribute2.should == :top
1035
1036
  end
1036
1037
  it 'should support `y.equals(:another_view[, :top])`' do
1037
- @view = @layout.context(UIView.new) do
1038
+ @layout.context(@view) do
1038
1039
  @layout.constraints do
1039
1040
  @constraint = @layout.y.equals(:another_view)
1040
1041
  end
@@ -1049,7 +1050,7 @@ describe 'Constraints - Simple helpers' do
1049
1050
  @constraint.attribute2.should == :top
1050
1051
  end
1051
1052
  it 'should support `min_y.equals(:another_view[, :top])`' do
1052
- @view = @layout.context(UIView.new) do
1053
+ @layout.context(@view) do
1053
1054
  @layout.constraints do
1054
1055
  @constraint = @layout.min_y.equals(:another_view)
1055
1056
  end
@@ -1064,7 +1065,7 @@ describe 'Constraints - Simple helpers' do
1064
1065
  @constraint.attribute2.should == :top
1065
1066
  end
1066
1067
  it 'should support `max_y.equals(:another_view[, :top])`' do
1067
- @view = @layout.context(UIView.new) do
1068
+ @layout.context(@view) do
1068
1069
  @layout.constraints do
1069
1070
  @constraint = @layout.max_y.equals(:another_view)
1070
1071
  end
@@ -1079,7 +1080,7 @@ describe 'Constraints - Simple helpers' do
1079
1080
  @constraint.attribute2.should == :top
1080
1081
  end
1081
1082
  it 'should support `y.equals(:another_view, :bottom)`' do
1082
- @view = @layout.context(UIView.new) do
1083
+ @layout.context(@view) do
1083
1084
  @layout.constraints do
1084
1085
  @constraint = @layout.y.equals(:another_view, :bottom)
1085
1086
  end
@@ -1094,7 +1095,7 @@ describe 'Constraints - Simple helpers' do
1094
1095
  @constraint.attribute2.should == :bottom
1095
1096
  end
1096
1097
  it 'should support `min_y.equals(:another_view, :bottom)`' do
1097
- @view = @layout.context(UIView.new) do
1098
+ @layout.context(@view) do
1098
1099
  @layout.constraints do
1099
1100
  @constraint = @layout.min_y.equals(:another_view, :bottom)
1100
1101
  end
@@ -1109,7 +1110,7 @@ describe 'Constraints - Simple helpers' do
1109
1110
  @constraint.attribute2.should == :bottom
1110
1111
  end
1111
1112
  it 'should support `max_y.equals(:another_view, :bottom)`' do
1112
- @view = @layout.context(UIView.new) do
1113
+ @layout.context(@view) do
1113
1114
  @layout.constraints do
1114
1115
  @constraint = @layout.max_y.equals(:another_view, :bottom)
1115
1116
  end
@@ -1124,7 +1125,7 @@ describe 'Constraints - Simple helpers' do
1124
1125
  @constraint.attribute2.should == :bottom
1125
1126
  end
1126
1127
  it 'should support `y.equals(:another_view, :bottom).plus(10)`' do
1127
- @view = @layout.context(UIView.new) do
1128
+ @layout.context(@view) do
1128
1129
  @layout.constraints do
1129
1130
  @constraint = @layout.y.equals(:another_view, :bottom).plus(10)
1130
1131
  end
@@ -1139,7 +1140,7 @@ describe 'Constraints - Simple helpers' do
1139
1140
  @constraint.attribute2.should == :bottom
1140
1141
  end
1141
1142
  it 'should support `min_y.equals(:another_view, :bottom).plus(10)`' do
1142
- @view = @layout.context(UIView.new) do
1143
+ @layout.context(@view) do
1143
1144
  @layout.constraints do
1144
1145
  @constraint = @layout.min_y.equals(:another_view, :bottom).plus(10)
1145
1146
  end
@@ -1154,7 +1155,7 @@ describe 'Constraints - Simple helpers' do
1154
1155
  @constraint.attribute2.should == :bottom
1155
1156
  end
1156
1157
  it 'should support `max_y.equals(:another_view, :bottom).plus(10)`' do
1157
- @view = @layout.context(UIView.new) do
1158
+ @layout.context(@view) do
1158
1159
  @layout.constraints do
1159
1160
  @constraint = @layout.max_y.equals(:another_view, :bottom).plus(10)
1160
1161
  end
@@ -1169,7 +1170,7 @@ describe 'Constraints - Simple helpers' do
1169
1170
  @constraint.attribute2.should == :bottom
1170
1171
  end
1171
1172
  it 'should support `y.equals(:another_view).times(2).plus(10)`' do
1172
- @view = @layout.context(UIView.new) do
1173
+ @layout.context(@view) do
1173
1174
  @layout.constraints do
1174
1175
  @constraint = @layout.y.equals(:another_view).times(2).plus(10)
1175
1176
  end
@@ -1184,7 +1185,7 @@ describe 'Constraints - Simple helpers' do
1184
1185
  @constraint.attribute2.should == :top
1185
1186
  end
1186
1187
  it 'should support `min_y.equals(:another_view).times(2).plus(10)`' do
1187
- @view = @layout.context(UIView.new) do
1188
+ @layout.context(@view) do
1188
1189
  @layout.constraints do
1189
1190
  @constraint = @layout.min_y.equals(:another_view).times(2).plus(10)
1190
1191
  end
@@ -1199,7 +1200,7 @@ describe 'Constraints - Simple helpers' do
1199
1200
  @constraint.attribute2.should == :top
1200
1201
  end
1201
1202
  it 'should support `max_y.equals(:another_view).times(2).plus(10)`' do
1202
- @view = @layout.context(UIView.new) do
1203
+ @layout.context(@view) do
1203
1204
  @layout.constraints do
1204
1205
  @constraint = @layout.max_y.equals(:another_view).times(2).plus(10)
1205
1206
  end
@@ -1214,7 +1215,7 @@ describe 'Constraints - Simple helpers' do
1214
1215
  @constraint.attribute2.should == :top
1215
1216
  end
1216
1217
  it 'should support `top.equals(:another_view).times(2).plus(10)`' do
1217
- @view = @layout.context(UIView.new) do
1218
+ @layout.context(@view) do
1218
1219
  @layout.constraints do
1219
1220
  @constraint = @layout.top.equals(:another_view).times(2).plus(10)
1220
1221
  end
@@ -1229,7 +1230,7 @@ describe 'Constraints - Simple helpers' do
1229
1230
  @constraint.attribute2.should == :top
1230
1231
  end
1231
1232
  it 'should support `min_top.equals(:another_view).times(2).plus(10)`' do
1232
- @view = @layout.context(UIView.new) do
1233
+ @layout.context(@view) do
1233
1234
  @layout.constraints do
1234
1235
  @constraint = @layout.min_top.equals(:another_view).times(2).plus(10)
1235
1236
  end
@@ -1244,7 +1245,7 @@ describe 'Constraints - Simple helpers' do
1244
1245
  @constraint.attribute2.should == :top
1245
1246
  end
1246
1247
  it 'should support `max_top.equals(:another_view).times(2).plus(10)`' do
1247
- @view = @layout.context(UIView.new) do
1248
+ @layout.context(@view) do
1248
1249
  @layout.constraints do
1249
1250
  @constraint = @layout.max_top.equals(:another_view).times(2).plus(10)
1250
1251
  end
@@ -1272,7 +1273,7 @@ describe 'Constraints - Simple helpers' do
1272
1273
 
1273
1274
  describe '`center_y` support' do
1274
1275
  it 'should support `center_y 10`' do
1275
- @view = @layout.context(UIView.new) do
1276
+ @layout.context(@view) do
1276
1277
  @layout.constraints do
1277
1278
  @constraint = @layout.center_y(10)
1278
1279
  end
@@ -1290,13 +1291,13 @@ describe 'Constraints - Simple helpers' do
1290
1291
  resolved[0].firstItem.should.be.kind_of(UIView)
1291
1292
  resolved[0].firstAttribute.should == NSLayoutAttributeCenterY
1292
1293
  resolved[0].relation.should == NSLayoutRelationEqual
1293
- resolved[0].secondItem.should == nil
1294
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
1294
+ resolved[0].secondItem.should == @parent_view
1295
+ resolved[0].secondAttribute.should == NSLayoutAttributeCenterY
1295
1296
  resolved[0].multiplier.should == 1
1296
1297
  resolved[0].constant.should == 10
1297
1298
  end
1298
1299
  it 'should support `min_center_y 10`' do
1299
- @view = @layout.context(UIView.new) do
1300
+ @layout.context(@view) do
1300
1301
  @layout.constraints do
1301
1302
  @constraint = @layout.min_center_y(10)
1302
1303
  end
@@ -1310,7 +1311,7 @@ describe 'Constraints - Simple helpers' do
1310
1311
  @constraint.attribute2.should == :center_y
1311
1312
  end
1312
1313
  it 'should support `max_center_y 10`' do
1313
- @view = @layout.context(UIView.new) do
1314
+ @layout.context(@view) do
1314
1315
  @layout.constraints do
1315
1316
  @constraint = @layout.max_center_y(10)
1316
1317
  end
@@ -1324,7 +1325,7 @@ describe 'Constraints - Simple helpers' do
1324
1325
  @constraint.attribute2.should == :center_y
1325
1326
  end
1326
1327
  it 'should support `center_y.equals(:another_view[, :center_y])`' do
1327
- @view = @layout.context(UIView.new) do
1328
+ @layout.context(@view) do
1328
1329
  @layout.constraints do
1329
1330
  @constraint = @layout.center_y.equals(:another_view)
1330
1331
  end
@@ -1339,7 +1340,7 @@ describe 'Constraints - Simple helpers' do
1339
1340
  @constraint.attribute2.should == :center_y
1340
1341
  end
1341
1342
  it 'should support `min_center_y.equals(:another_view[, :center_y])`' do
1342
- @view = @layout.context(UIView.new) do
1343
+ @layout.context(@view) do
1343
1344
  @layout.constraints do
1344
1345
  @constraint = @layout.min_center_y.equals(:another_view)
1345
1346
  end
@@ -1354,7 +1355,7 @@ describe 'Constraints - Simple helpers' do
1354
1355
  @constraint.attribute2.should == :center_y
1355
1356
  end
1356
1357
  it 'should support `max_center_y.equals(:another_view[, :center_y])`' do
1357
- @view = @layout.context(UIView.new) do
1358
+ @layout.context(@view) do
1358
1359
  @layout.constraints do
1359
1360
  @constraint = @layout.max_center_y.equals(:another_view)
1360
1361
  end
@@ -1369,7 +1370,7 @@ describe 'Constraints - Simple helpers' do
1369
1370
  @constraint.attribute2.should == :center_y
1370
1371
  end
1371
1372
  it 'should support `center_y.equals(:another_view, :top)`' do
1372
- @view = @layout.context(UIView.new) do
1373
+ @layout.context(@view) do
1373
1374
  @layout.constraints do
1374
1375
  @constraint = @layout.center_y.equals(:another_view, :top)
1375
1376
  end
@@ -1384,7 +1385,7 @@ describe 'Constraints - Simple helpers' do
1384
1385
  @constraint.attribute2.should == :top
1385
1386
  end
1386
1387
  it 'should support `min_center_y.equals(:another_view, :top)`' do
1387
- @view = @layout.context(UIView.new) do
1388
+ @layout.context(@view) do
1388
1389
  @layout.constraints do
1389
1390
  @constraint = @layout.min_center_y.equals(:another_view, :top)
1390
1391
  end
@@ -1399,7 +1400,7 @@ describe 'Constraints - Simple helpers' do
1399
1400
  @constraint.attribute2.should == :top
1400
1401
  end
1401
1402
  it 'should support `max_center_y.equals(:another_view, :top)`' do
1402
- @view = @layout.context(UIView.new) do
1403
+ @layout.context(@view) do
1403
1404
  @layout.constraints do
1404
1405
  @constraint = @layout.max_center_y.equals(:another_view, :top)
1405
1406
  end
@@ -1414,7 +1415,7 @@ describe 'Constraints - Simple helpers' do
1414
1415
  @constraint.attribute2.should == :top
1415
1416
  end
1416
1417
  it 'should support `center_y.equals(:another_view, :top).plus(10)`' do
1417
- @view = @layout.context(UIView.new) do
1418
+ @layout.context(@view) do
1418
1419
  @layout.constraints do
1419
1420
  @constraint = @layout.center_y.equals(:another_view, :top).plus(10)
1420
1421
  end
@@ -1429,7 +1430,7 @@ describe 'Constraints - Simple helpers' do
1429
1430
  @constraint.attribute2.should == :top
1430
1431
  end
1431
1432
  it 'should support `min_center_y.equals(:another_view, :top).plus(10)`' do
1432
- @view = @layout.context(UIView.new) do
1433
+ @layout.context(@view) do
1433
1434
  @layout.constraints do
1434
1435
  @constraint = @layout.min_center_y.equals(:another_view, :top).plus(10)
1435
1436
  end
@@ -1444,7 +1445,7 @@ describe 'Constraints - Simple helpers' do
1444
1445
  @constraint.attribute2.should == :top
1445
1446
  end
1446
1447
  it 'should support `max_center_y.equals(:another_view, :top).plus(10)`' do
1447
- @view = @layout.context(UIView.new) do
1448
+ @layout.context(@view) do
1448
1449
  @layout.constraints do
1449
1450
  @constraint = @layout.max_center_y.equals(:another_view, :top).plus(10)
1450
1451
  end
@@ -1459,7 +1460,7 @@ describe 'Constraints - Simple helpers' do
1459
1460
  @constraint.attribute2.should == :top
1460
1461
  end
1461
1462
  it 'should support `center_y.equals(:another_view).times(2).plus(10)`' do
1462
- @view = @layout.context(UIView.new) do
1463
+ @layout.context(@view) do
1463
1464
  @layout.constraints do
1464
1465
  @constraint = @layout.center_y.equals(:another_view).times(2).plus(10)
1465
1466
  end
@@ -1474,7 +1475,7 @@ describe 'Constraints - Simple helpers' do
1474
1475
  @constraint.attribute2.should == :center_y
1475
1476
  end
1476
1477
  it 'should support `min_center_y.equals(:another_view).times(2).plus(10)`' do
1477
- @view = @layout.context(UIView.new) do
1478
+ @layout.context(@view) do
1478
1479
  @layout.constraints do
1479
1480
  @constraint = @layout.min_center_y.equals(:another_view).times(2).plus(10)
1480
1481
  end
@@ -1489,7 +1490,7 @@ describe 'Constraints - Simple helpers' do
1489
1490
  @constraint.attribute2.should == :center_y
1490
1491
  end
1491
1492
  it 'should support `max_center_y.equals(:another_view).times(2).plus(10)`' do
1492
- @view = @layout.context(UIView.new) do
1493
+ @layout.context(@view) do
1493
1494
  @layout.constraints do
1494
1495
  @constraint = @layout.max_center_y.equals(:another_view).times(2).plus(10)
1495
1496
  end
@@ -1517,7 +1518,7 @@ describe 'Constraints - Simple helpers' do
1517
1518
 
1518
1519
  describe '`bottom` support' do
1519
1520
  it 'should support `bottom 10`' do
1520
- @view = @layout.context(UIView.new) do
1521
+ @layout.context(@view) do
1521
1522
  @layout.constraints do
1522
1523
  @constraint = @layout.bottom(10)
1523
1524
  end
@@ -1535,13 +1536,13 @@ describe 'Constraints - Simple helpers' do
1535
1536
  resolved[0].firstItem.should.be.kind_of(UIView)
1536
1537
  resolved[0].firstAttribute.should == NSLayoutAttributeBottom
1537
1538
  resolved[0].relation.should == NSLayoutRelationEqual
1538
- resolved[0].secondItem.should == nil
1539
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
1539
+ resolved[0].secondItem.should == @parent_view
1540
+ resolved[0].secondAttribute.should == NSLayoutAttributeBottom
1540
1541
  resolved[0].multiplier.should == 1
1541
1542
  resolved[0].constant.should == 10
1542
1543
  end
1543
1544
  it 'should support `min_bottom 10`' do
1544
- @view = @layout.context(UIView.new) do
1545
+ @layout.context(@view) do
1545
1546
  @layout.constraints do
1546
1547
  @constraint = @layout.min_bottom(10)
1547
1548
  end
@@ -1555,7 +1556,7 @@ describe 'Constraints - Simple helpers' do
1555
1556
  @constraint.attribute2.should == :bottom
1556
1557
  end
1557
1558
  it 'should support `max_bottom 10`' do
1558
- @view = @layout.context(UIView.new) do
1559
+ @layout.context(@view) do
1559
1560
  @layout.constraints do
1560
1561
  @constraint = @layout.max_bottom(10)
1561
1562
  end
@@ -1569,7 +1570,7 @@ describe 'Constraints - Simple helpers' do
1569
1570
  @constraint.attribute2.should == :bottom
1570
1571
  end
1571
1572
  it 'should support `bottom.equals(:another_view[, :bottom])`' do
1572
- @view = @layout.context(UIView.new) do
1573
+ @layout.context(@view) do
1573
1574
  @layout.constraints do
1574
1575
  @constraint = @layout.bottom.equals(:another_view)
1575
1576
  end
@@ -1584,7 +1585,7 @@ describe 'Constraints - Simple helpers' do
1584
1585
  @constraint.attribute2.should == :bottom
1585
1586
  end
1586
1587
  it 'should support `min_bottom.equals(:another_view[, :bottom])`' do
1587
- @view = @layout.context(UIView.new) do
1588
+ @layout.context(@view) do
1588
1589
  @layout.constraints do
1589
1590
  @constraint = @layout.min_bottom.equals(:another_view)
1590
1591
  end
@@ -1599,7 +1600,7 @@ describe 'Constraints - Simple helpers' do
1599
1600
  @constraint.attribute2.should == :bottom
1600
1601
  end
1601
1602
  it 'should support `max_bottom.equals(:another_view[, :bottom])`' do
1602
- @view = @layout.context(UIView.new) do
1603
+ @layout.context(@view) do
1603
1604
  @layout.constraints do
1604
1605
  @constraint = @layout.max_bottom.equals(:another_view)
1605
1606
  end
@@ -1614,7 +1615,7 @@ describe 'Constraints - Simple helpers' do
1614
1615
  @constraint.attribute2.should == :bottom
1615
1616
  end
1616
1617
  it 'should support `bottom.equals(:another_view, :top)`' do
1617
- @view = @layout.context(UIView.new) do
1618
+ @layout.context(@view) do
1618
1619
  @layout.constraints do
1619
1620
  @constraint = @layout.bottom.equals(:another_view, :top)
1620
1621
  end
@@ -1629,7 +1630,7 @@ describe 'Constraints - Simple helpers' do
1629
1630
  @constraint.attribute2.should == :top
1630
1631
  end
1631
1632
  it 'should support `min_bottom.equals(:another_view, :top)`' do
1632
- @view = @layout.context(UIView.new) do
1633
+ @layout.context(@view) do
1633
1634
  @layout.constraints do
1634
1635
  @constraint = @layout.min_bottom.equals(:another_view, :top)
1635
1636
  end
@@ -1644,7 +1645,7 @@ describe 'Constraints - Simple helpers' do
1644
1645
  @constraint.attribute2.should == :top
1645
1646
  end
1646
1647
  it 'should support `max_bottom.equals(:another_view, :top)`' do
1647
- @view = @layout.context(UIView.new) do
1648
+ @layout.context(@view) do
1648
1649
  @layout.constraints do
1649
1650
  @constraint = @layout.max_bottom.equals(:another_view, :top)
1650
1651
  end
@@ -1659,7 +1660,7 @@ describe 'Constraints - Simple helpers' do
1659
1660
  @constraint.attribute2.should == :top
1660
1661
  end
1661
1662
  it 'should support `bottom.equals(:another_view, :top).plus(10)`' do
1662
- @view = @layout.context(UIView.new) do
1663
+ @layout.context(@view) do
1663
1664
  @layout.constraints do
1664
1665
  @constraint = @layout.bottom.equals(:another_view, :top).plus(10)
1665
1666
  end
@@ -1674,7 +1675,7 @@ describe 'Constraints - Simple helpers' do
1674
1675
  @constraint.attribute2.should == :top
1675
1676
  end
1676
1677
  it 'should support `min_bottom.equals(:another_view, :top).plus(10)`' do
1677
- @view = @layout.context(UIView.new) do
1678
+ @layout.context(@view) do
1678
1679
  @layout.constraints do
1679
1680
  @constraint = @layout.min_bottom.equals(:another_view, :top).plus(10)
1680
1681
  end
@@ -1689,7 +1690,7 @@ describe 'Constraints - Simple helpers' do
1689
1690
  @constraint.attribute2.should == :top
1690
1691
  end
1691
1692
  it 'should support `max_bottom.equals(:another_view, :top).plus(10)`' do
1692
- @view = @layout.context(UIView.new) do
1693
+ @layout.context(@view) do
1693
1694
  @layout.constraints do
1694
1695
  @constraint = @layout.max_bottom.equals(:another_view, :top).plus(10)
1695
1696
  end
@@ -1704,7 +1705,7 @@ describe 'Constraints - Simple helpers' do
1704
1705
  @constraint.attribute2.should == :top
1705
1706
  end
1706
1707
  it 'should support `bottom.equals(:another_view).times(2).plus(10)`' do
1707
- @view = @layout.context(UIView.new) do
1708
+ @layout.context(@view) do
1708
1709
  @layout.constraints do
1709
1710
  @constraint = @layout.bottom.equals(:another_view).times(2).plus(10)
1710
1711
  end
@@ -1719,7 +1720,7 @@ describe 'Constraints - Simple helpers' do
1719
1720
  @constraint.attribute2.should == :bottom
1720
1721
  end
1721
1722
  it 'should support `min_bottom.equals(:another_view).times(2).plus(10)`' do
1722
- @view = @layout.context(UIView.new) do
1723
+ @layout.context(@view) do
1723
1724
  @layout.constraints do
1724
1725
  @constraint = @layout.min_bottom.equals(:another_view).times(2).plus(10)
1725
1726
  end
@@ -1734,7 +1735,7 @@ describe 'Constraints - Simple helpers' do
1734
1735
  @constraint.attribute2.should == :bottom
1735
1736
  end
1736
1737
  it 'should support `max_bottom.equals(:another_view).times(2).plus(10)`' do
1737
- @view = @layout.context(UIView.new) do
1738
+ @layout.context(@view) do
1738
1739
  @layout.constraints do
1739
1740
  @constraint = @layout.max_bottom.equals(:another_view).times(2).plus(10)
1740
1741
  end
@@ -1762,7 +1763,7 @@ describe 'Constraints - Simple helpers' do
1762
1763
 
1763
1764
  describe '`width` support' do
1764
1765
  it 'should support `width 10`' do
1765
- @view = @layout.context(UIView.new) do
1766
+ @layout.context(@view) do
1766
1767
  @layout.constraints do
1767
1768
  @constraint = @layout.width(10)
1768
1769
  end
@@ -1786,7 +1787,7 @@ describe 'Constraints - Simple helpers' do
1786
1787
  resolved[0].constant.should == 10
1787
1788
  end
1788
1789
  it 'should support `min_width 10`' do
1789
- @view = @layout.context(UIView.new) do
1790
+ @layout.context(@view) do
1790
1791
  @layout.constraints do
1791
1792
  @constraint = @layout.min_width(10)
1792
1793
  end
@@ -1800,7 +1801,7 @@ describe 'Constraints - Simple helpers' do
1800
1801
  @constraint.attribute2.should == :width
1801
1802
  end
1802
1803
  it 'should support `max_width 10`' do
1803
- @view = @layout.context(UIView.new) do
1804
+ @layout.context(@view) do
1804
1805
  @layout.constraints do
1805
1806
  @constraint = @layout.max_width(10)
1806
1807
  end
@@ -1814,7 +1815,7 @@ describe 'Constraints - Simple helpers' do
1814
1815
  @constraint.attribute2.should == :width
1815
1816
  end
1816
1817
  it 'should support `width.equals(:another_view[, :width])`' do
1817
- @view = @layout.context(UIView.new) do
1818
+ @layout.context(@view) do
1818
1819
  @layout.constraints do
1819
1820
  @constraint = @layout.width.equals(:another_view)
1820
1821
  end
@@ -1829,7 +1830,7 @@ describe 'Constraints - Simple helpers' do
1829
1830
  @constraint.attribute2.should == :width
1830
1831
  end
1831
1832
  it 'should support `min_width.equals(:another_view[, :width])`' do
1832
- @view = @layout.context(UIView.new) do
1833
+ @layout.context(@view) do
1833
1834
  @layout.constraints do
1834
1835
  @constraint = @layout.min_width.equals(:another_view)
1835
1836
  end
@@ -1844,7 +1845,7 @@ describe 'Constraints - Simple helpers' do
1844
1845
  @constraint.attribute2.should == :width
1845
1846
  end
1846
1847
  it 'should support `max_width.equals(:another_view[, :width])`' do
1847
- @view = @layout.context(UIView.new) do
1848
+ @layout.context(@view) do
1848
1849
  @layout.constraints do
1849
1850
  @constraint = @layout.max_width.equals(:another_view)
1850
1851
  end
@@ -1859,7 +1860,7 @@ describe 'Constraints - Simple helpers' do
1859
1860
  @constraint.attribute2.should == :width
1860
1861
  end
1861
1862
  it 'should support `width.equals(:another_view, :height).plus(10)`' do
1862
- @view = @layout.context(UIView.new) do
1863
+ @layout.context(@view) do
1863
1864
  @layout.constraints do
1864
1865
  @constraint = @layout.width.equals(:another_view, :height).plus(10)
1865
1866
  end
@@ -1874,7 +1875,7 @@ describe 'Constraints - Simple helpers' do
1874
1875
  @constraint.attribute2.should == :height
1875
1876
  end
1876
1877
  it 'should support `min_width.equals(:another_view, :height).plus(10)`' do
1877
- @view = @layout.context(UIView.new) do
1878
+ @layout.context(@view) do
1878
1879
  @layout.constraints do
1879
1880
  @constraint = @layout.min_width.equals(:another_view, :height).plus(10)
1880
1881
  end
@@ -1889,7 +1890,7 @@ describe 'Constraints - Simple helpers' do
1889
1890
  @constraint.attribute2.should == :height
1890
1891
  end
1891
1892
  it 'should support `max_width.equals(:another_view, :height).plus(10)`' do
1892
- @view = @layout.context(UIView.new) do
1893
+ @layout.context(@view) do
1893
1894
  @layout.constraints do
1894
1895
  @constraint = @layout.max_width.equals(:another_view, :height).plus(10)
1895
1896
  end
@@ -1904,7 +1905,7 @@ describe 'Constraints - Simple helpers' do
1904
1905
  @constraint.attribute2.should == :height
1905
1906
  end
1906
1907
  it 'should support `width.equals(:another_view).times(2).plus(10)`' do
1907
- @view = @layout.context(UIView.new) do
1908
+ @layout.context(@view) do
1908
1909
  @layout.constraints do
1909
1910
  @constraint = @layout.width.equals(:another_view).times(2).plus(10)
1910
1911
  end
@@ -1919,7 +1920,7 @@ describe 'Constraints - Simple helpers' do
1919
1920
  @constraint.attribute2.should == :width
1920
1921
  end
1921
1922
  it 'should support `min_width.equals(:another_view).times(2).plus(10)`' do
1922
- @view = @layout.context(UIView.new) do
1923
+ @layout.context(@view) do
1923
1924
  @layout.constraints do
1924
1925
  @constraint = @layout.min_width.equals(:another_view).times(2).plus(10)
1925
1926
  end
@@ -1934,7 +1935,7 @@ describe 'Constraints - Simple helpers' do
1934
1935
  @constraint.attribute2.should == :width
1935
1936
  end
1936
1937
  it 'should support `max_width.equals(:another_view).times(2).plus(10)`' do
1937
- @view = @layout.context(UIView.new) do
1938
+ @layout.context(@view) do
1938
1939
  @layout.constraints do
1939
1940
  @constraint = @layout.max_width.equals(:another_view).times(2).plus(10)
1940
1941
  end
@@ -1962,7 +1963,7 @@ describe 'Constraints - Simple helpers' do
1962
1963
 
1963
1964
  describe '`height` support' do
1964
1965
  it 'should support `height 10`' do
1965
- @view = @layout.context(UIView.new) do
1966
+ @layout.context(@view) do
1966
1967
  @layout.constraints do
1967
1968
  @constraint = @layout.height(10)
1968
1969
  end
@@ -1986,7 +1987,7 @@ describe 'Constraints - Simple helpers' do
1986
1987
  resolved[0].constant.should == 10
1987
1988
  end
1988
1989
  it 'should support `min_height 10`' do
1989
- @view = @layout.context(UIView.new) do
1990
+ @layout.context(@view) do
1990
1991
  @layout.constraints do
1991
1992
  @constraint = @layout.min_height(10)
1992
1993
  end
@@ -2000,7 +2001,7 @@ describe 'Constraints - Simple helpers' do
2000
2001
  @constraint.attribute2.should == :height
2001
2002
  end
2002
2003
  it 'should support `max_height 10`' do
2003
- @view = @layout.context(UIView.new) do
2004
+ @layout.context(@view) do
2004
2005
  @layout.constraints do
2005
2006
  @constraint = @layout.max_height(10)
2006
2007
  end
@@ -2014,7 +2015,7 @@ describe 'Constraints - Simple helpers' do
2014
2015
  @constraint.attribute2.should == :height
2015
2016
  end
2016
2017
  it 'should support `height.equals(:another_view[, :height])`' do
2017
- @view = @layout.context(UIView.new) do
2018
+ @layout.context(@view) do
2018
2019
  @layout.constraints do
2019
2020
  @constraint = @layout.height.equals(:another_view)
2020
2021
  end
@@ -2029,7 +2030,7 @@ describe 'Constraints - Simple helpers' do
2029
2030
  @constraint.attribute2.should == :height
2030
2031
  end
2031
2032
  it 'should support `min_height.equals(:another_view[, :height])`' do
2032
- @view = @layout.context(UIView.new) do
2033
+ @layout.context(@view) do
2033
2034
  @layout.constraints do
2034
2035
  @constraint = @layout.min_height.equals(:another_view)
2035
2036
  end
@@ -2044,7 +2045,7 @@ describe 'Constraints - Simple helpers' do
2044
2045
  @constraint.attribute2.should == :height
2045
2046
  end
2046
2047
  it 'should support `max_height.equals(:another_view[, :height])`' do
2047
- @view = @layout.context(UIView.new) do
2048
+ @layout.context(@view) do
2048
2049
  @layout.constraints do
2049
2050
  @constraint = @layout.max_height.equals(:another_view)
2050
2051
  end
@@ -2059,7 +2060,7 @@ describe 'Constraints - Simple helpers' do
2059
2060
  @constraint.attribute2.should == :height
2060
2061
  end
2061
2062
  it 'should support `height.equals(:another_view).plus(10)`' do
2062
- @view = @layout.context(UIView.new) do
2063
+ @layout.context(@view) do
2063
2064
  @layout.constraints do
2064
2065
  @constraint = @layout.height.equals(:another_view).plus(10)
2065
2066
  end
@@ -2074,7 +2075,7 @@ describe 'Constraints - Simple helpers' do
2074
2075
  @constraint.attribute2.should == :height
2075
2076
  end
2076
2077
  it 'should support `min_height.equals(:another_view).plus(10)`' do
2077
- @view = @layout.context(UIView.new) do
2078
+ @layout.context(@view) do
2078
2079
  @layout.constraints do
2079
2080
  @constraint = @layout.min_height.equals(:another_view).plus(10)
2080
2081
  end
@@ -2089,7 +2090,7 @@ describe 'Constraints - Simple helpers' do
2089
2090
  @constraint.attribute2.should == :height
2090
2091
  end
2091
2092
  it 'should support `max_height.equals(:another_view).plus(10)`' do
2092
- @view = @layout.context(UIView.new) do
2093
+ @layout.context(@view) do
2093
2094
  @layout.constraints do
2094
2095
  @constraint = @layout.max_height.equals(:another_view).plus(10)
2095
2096
  end
@@ -2104,7 +2105,7 @@ describe 'Constraints - Simple helpers' do
2104
2105
  @constraint.attribute2.should == :height
2105
2106
  end
2106
2107
  it 'should support `height.equals(:another_view).times(2).plus(10)`' do
2107
- @view = @layout.context(UIView.new) do
2108
+ @layout.context(@view) do
2108
2109
  @layout.constraints do
2109
2110
  @constraint = @layout.height.equals(:another_view).times(2).plus(10)
2110
2111
  end
@@ -2119,7 +2120,7 @@ describe 'Constraints - Simple helpers' do
2119
2120
  @constraint.attribute2.should == :height
2120
2121
  end
2121
2122
  it 'should support `min_height.equals(:another_view).times(2).plus(10)`' do
2122
- @view = @layout.context(UIView.new) do
2123
+ @layout.context(@view) do
2123
2124
  @layout.constraints do
2124
2125
  @constraint = @layout.min_height.equals(:another_view).times(2).plus(10)
2125
2126
  end
@@ -2134,7 +2135,7 @@ describe 'Constraints - Simple helpers' do
2134
2135
  @constraint.attribute2.should == :height
2135
2136
  end
2136
2137
  it 'should support `max_height.equals(:another_view).times(2).plus(10)`' do
2137
- @view = @layout.context(UIView.new) do
2138
+ @layout.context(@view) do
2138
2139
  @layout.constraints do
2139
2140
  @constraint = @layout.max_height.equals(:another_view).times(2).plus(10)
2140
2141
  end
@@ -2162,7 +2163,7 @@ describe 'Constraints - Simple helpers' do
2162
2163
 
2163
2164
  describe '`leading` support' do
2164
2165
  it 'should support `leading 10`' do
2165
- @view = @layout.context(UIView.new) do
2166
+ @layout.context(@view) do
2166
2167
  @layout.constraints do
2167
2168
  @constraint = @layout.leading(10)
2168
2169
  end
@@ -2180,13 +2181,13 @@ describe 'Constraints - Simple helpers' do
2180
2181
  resolved[0].firstItem.should.be.kind_of(UIView)
2181
2182
  resolved[0].firstAttribute.should == NSLayoutAttributeLeading
2182
2183
  resolved[0].relation.should == NSLayoutRelationEqual
2183
- resolved[0].secondItem.should == nil
2184
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
2184
+ resolved[0].secondItem.should == @parent_view
2185
+ resolved[0].secondAttribute.should == NSLayoutAttributeLeading
2185
2186
  resolved[0].multiplier.should == 1
2186
2187
  resolved[0].constant.should == 10
2187
2188
  end
2188
2189
  it 'should support `min_leading 10`' do
2189
- @view = @layout.context(UIView.new) do
2190
+ @layout.context(@view) do
2190
2191
  @layout.constraints do
2191
2192
  @constraint = @layout.min_leading(10)
2192
2193
  end
@@ -2200,7 +2201,7 @@ describe 'Constraints - Simple helpers' do
2200
2201
  @constraint.attribute2.should == :leading
2201
2202
  end
2202
2203
  it 'should support `max_leading 10`' do
2203
- @view = @layout.context(UIView.new) do
2204
+ @layout.context(@view) do
2204
2205
  @layout.constraints do
2205
2206
  @constraint = @layout.max_leading(10)
2206
2207
  end
@@ -2214,7 +2215,7 @@ describe 'Constraints - Simple helpers' do
2214
2215
  @constraint.attribute2.should == :leading
2215
2216
  end
2216
2217
  it 'should support `leading.equals(:another_view[, :leading])`' do
2217
- @view = @layout.context(UIView.new) do
2218
+ @layout.context(@view) do
2218
2219
  @layout.constraints do
2219
2220
  @constraint = @layout.leading.equals(:another_view)
2220
2221
  end
@@ -2229,7 +2230,7 @@ describe 'Constraints - Simple helpers' do
2229
2230
  @constraint.attribute2.should == :leading
2230
2231
  end
2231
2232
  it 'should support `min_leading.equals(:another_view[, :leading])`' do
2232
- @view = @layout.context(UIView.new) do
2233
+ @layout.context(@view) do
2233
2234
  @layout.constraints do
2234
2235
  @constraint = @layout.min_leading.equals(:another_view)
2235
2236
  end
@@ -2244,7 +2245,7 @@ describe 'Constraints - Simple helpers' do
2244
2245
  @constraint.attribute2.should == :leading
2245
2246
  end
2246
2247
  it 'should support `max_leading.equals(:another_view[, :leading])`' do
2247
- @view = @layout.context(UIView.new) do
2248
+ @layout.context(@view) do
2248
2249
  @layout.constraints do
2249
2250
  @constraint = @layout.max_leading.equals(:another_view)
2250
2251
  end
@@ -2259,7 +2260,7 @@ describe 'Constraints - Simple helpers' do
2259
2260
  @constraint.attribute2.should == :leading
2260
2261
  end
2261
2262
  it 'should support `leading.equals(:another_view).plus(10)`' do
2262
- @view = @layout.context(UIView.new) do
2263
+ @layout.context(@view) do
2263
2264
  @layout.constraints do
2264
2265
  @constraint = @layout.leading.equals(:another_view).plus(10)
2265
2266
  end
@@ -2274,7 +2275,7 @@ describe 'Constraints - Simple helpers' do
2274
2275
  @constraint.attribute2.should == :leading
2275
2276
  end
2276
2277
  it 'should support `min_leading.equals(:another_view).plus(10)`' do
2277
- @view = @layout.context(UIView.new) do
2278
+ @layout.context(@view) do
2278
2279
  @layout.constraints do
2279
2280
  @constraint = @layout.min_leading.equals(:another_view).plus(10)
2280
2281
  end
@@ -2289,7 +2290,7 @@ describe 'Constraints - Simple helpers' do
2289
2290
  @constraint.attribute2.should == :leading
2290
2291
  end
2291
2292
  it 'should support `max_leading.equals(:another_view).plus(10)`' do
2292
- @view = @layout.context(UIView.new) do
2293
+ @layout.context(@view) do
2293
2294
  @layout.constraints do
2294
2295
  @constraint = @layout.max_leading.equals(:another_view).plus(10)
2295
2296
  end
@@ -2304,7 +2305,7 @@ describe 'Constraints - Simple helpers' do
2304
2305
  @constraint.attribute2.should == :leading
2305
2306
  end
2306
2307
  it 'should support `leading.equals(:another_view).times(2).plus(10)`' do
2307
- @view = @layout.context(UIView.new) do
2308
+ @layout.context(@view) do
2308
2309
  @layout.constraints do
2309
2310
  @constraint = @layout.leading.equals(:another_view).times(2).plus(10)
2310
2311
  end
@@ -2319,7 +2320,7 @@ describe 'Constraints - Simple helpers' do
2319
2320
  @constraint.attribute2.should == :leading
2320
2321
  end
2321
2322
  it 'should support `min_leading.equals(:another_view).times(2).plus(10)`' do
2322
- @view = @layout.context(UIView.new) do
2323
+ @layout.context(@view) do
2323
2324
  @layout.constraints do
2324
2325
  @constraint = @layout.min_leading.equals(:another_view).times(2).plus(10)
2325
2326
  end
@@ -2334,7 +2335,7 @@ describe 'Constraints - Simple helpers' do
2334
2335
  @constraint.attribute2.should == :leading
2335
2336
  end
2336
2337
  it 'should support `max_leading.equals(:another_view).times(2).plus(10)`' do
2337
- @view = @layout.context(UIView.new) do
2338
+ @layout.context(@view) do
2338
2339
  @layout.constraints do
2339
2340
  @constraint = @layout.max_leading.equals(:another_view).times(2).plus(10)
2340
2341
  end
@@ -2362,7 +2363,7 @@ describe 'Constraints - Simple helpers' do
2362
2363
 
2363
2364
  describe '`trailing` support' do
2364
2365
  it 'should support `trailing 10`' do
2365
- @view = @layout.context(UIView.new) do
2366
+ @layout.context(@view) do
2366
2367
  @layout.constraints do
2367
2368
  @constraint = @layout.trailing(10)
2368
2369
  end
@@ -2380,13 +2381,13 @@ describe 'Constraints - Simple helpers' do
2380
2381
  resolved[0].firstItem.should.be.kind_of(UIView)
2381
2382
  resolved[0].firstAttribute.should == NSLayoutAttributeTrailing
2382
2383
  resolved[0].relation.should == NSLayoutRelationEqual
2383
- resolved[0].secondItem.should == nil
2384
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
2384
+ resolved[0].secondItem.should == @parent_view
2385
+ resolved[0].secondAttribute.should == NSLayoutAttributeTrailing
2385
2386
  resolved[0].multiplier.should == 1
2386
2387
  resolved[0].constant.should == 10
2387
2388
  end
2388
2389
  it 'should support `min_trailing 10`' do
2389
- @view = @layout.context(UIView.new) do
2390
+ @layout.context(@view) do
2390
2391
  @layout.constraints do
2391
2392
  @constraint = @layout.min_trailing(10)
2392
2393
  end
@@ -2400,7 +2401,7 @@ describe 'Constraints - Simple helpers' do
2400
2401
  @constraint.attribute2.should == :trailing
2401
2402
  end
2402
2403
  it 'should support `max_trailing 10`' do
2403
- @view = @layout.context(UIView.new) do
2404
+ @layout.context(@view) do
2404
2405
  @layout.constraints do
2405
2406
  @constraint = @layout.max_trailing(10)
2406
2407
  end
@@ -2414,7 +2415,7 @@ describe 'Constraints - Simple helpers' do
2414
2415
  @constraint.attribute2.should == :trailing
2415
2416
  end
2416
2417
  it 'should support `trailing.equals(:another_view[, :trailing])`' do
2417
- @view = @layout.context(UIView.new) do
2418
+ @layout.context(@view) do
2418
2419
  @layout.constraints do
2419
2420
  @constraint = @layout.trailing.equals(:another_view)
2420
2421
  end
@@ -2429,7 +2430,7 @@ describe 'Constraints - Simple helpers' do
2429
2430
  @constraint.attribute2.should == :trailing
2430
2431
  end
2431
2432
  it 'should support `min_trailing.equals(:another_view[, :trailing])`' do
2432
- @view = @layout.context(UIView.new) do
2433
+ @layout.context(@view) do
2433
2434
  @layout.constraints do
2434
2435
  @constraint = @layout.min_trailing.equals(:another_view)
2435
2436
  end
@@ -2444,7 +2445,7 @@ describe 'Constraints - Simple helpers' do
2444
2445
  @constraint.attribute2.should == :trailing
2445
2446
  end
2446
2447
  it 'should support `max_trailing.equals(:another_view[, :trailing])`' do
2447
- @view = @layout.context(UIView.new) do
2448
+ @layout.context(@view) do
2448
2449
  @layout.constraints do
2449
2450
  @constraint = @layout.max_trailing.equals(:another_view)
2450
2451
  end
@@ -2459,7 +2460,7 @@ describe 'Constraints - Simple helpers' do
2459
2460
  @constraint.attribute2.should == :trailing
2460
2461
  end
2461
2462
  it 'should support `trailing.equals(:another_view).plus(10)`' do
2462
- @view = @layout.context(UIView.new) do
2463
+ @layout.context(@view) do
2463
2464
  @layout.constraints do
2464
2465
  @constraint = @layout.trailing.equals(:another_view).plus(10)
2465
2466
  end
@@ -2474,7 +2475,7 @@ describe 'Constraints - Simple helpers' do
2474
2475
  @constraint.attribute2.should == :trailing
2475
2476
  end
2476
2477
  it 'should support `min_trailing.equals(:another_view).plus(10)`' do
2477
- @view = @layout.context(UIView.new) do
2478
+ @layout.context(@view) do
2478
2479
  @layout.constraints do
2479
2480
  @constraint = @layout.min_trailing.equals(:another_view).plus(10)
2480
2481
  end
@@ -2489,7 +2490,7 @@ describe 'Constraints - Simple helpers' do
2489
2490
  @constraint.attribute2.should == :trailing
2490
2491
  end
2491
2492
  it 'should support `max_trailing.equals(:another_view).plus(10)`' do
2492
- @view = @layout.context(UIView.new) do
2493
+ @layout.context(@view) do
2493
2494
  @layout.constraints do
2494
2495
  @constraint = @layout.max_trailing.equals(:another_view).plus(10)
2495
2496
  end
@@ -2504,7 +2505,7 @@ describe 'Constraints - Simple helpers' do
2504
2505
  @constraint.attribute2.should == :trailing
2505
2506
  end
2506
2507
  it 'should support `trailing.equals(:another_view).times(2).plus(10)`' do
2507
- @view = @layout.context(UIView.new) do
2508
+ @layout.context(@view) do
2508
2509
  @layout.constraints do
2509
2510
  @constraint = @layout.trailing.equals(:another_view).times(2).plus(10)
2510
2511
  end
@@ -2519,7 +2520,7 @@ describe 'Constraints - Simple helpers' do
2519
2520
  @constraint.attribute2.should == :trailing
2520
2521
  end
2521
2522
  it 'should support `min_trailing.equals(:another_view).times(2).plus(10)`' do
2522
- @view = @layout.context(UIView.new) do
2523
+ @layout.context(@view) do
2523
2524
  @layout.constraints do
2524
2525
  @constraint = @layout.min_trailing.equals(:another_view).times(2).plus(10)
2525
2526
  end
@@ -2534,7 +2535,7 @@ describe 'Constraints - Simple helpers' do
2534
2535
  @constraint.attribute2.should == :trailing
2535
2536
  end
2536
2537
  it 'should support `max_trailing.equals(:another_view).times(2).plus(10)`' do
2537
- @view = @layout.context(UIView.new) do
2538
+ @layout.context(@view) do
2538
2539
  @layout.constraints do
2539
2540
  @constraint = @layout.max_trailing.equals(:another_view).times(2).plus(10)
2540
2541
  end
@@ -2562,7 +2563,7 @@ describe 'Constraints - Simple helpers' do
2562
2563
 
2563
2564
  describe '`baseline` support' do
2564
2565
  it 'should support `baseline 10`' do
2565
- @view = @layout.context(UIView.new) do
2566
+ @layout.context(@view) do
2566
2567
  @layout.constraints do
2567
2568
  @constraint = @layout.baseline(10)
2568
2569
  end
@@ -2580,13 +2581,13 @@ describe 'Constraints - Simple helpers' do
2580
2581
  resolved[0].firstItem.should.be.kind_of(UIView)
2581
2582
  resolved[0].firstAttribute.should == NSLayoutAttributeBaseline
2582
2583
  resolved[0].relation.should == NSLayoutRelationEqual
2583
- resolved[0].secondItem.should == nil
2584
- resolved[0].secondAttribute.should == NSLayoutAttributeNotAnAttribute
2584
+ resolved[0].secondItem.should == @parent_view
2585
+ resolved[0].secondAttribute.should == NSLayoutAttributeBaseline
2585
2586
  resolved[0].multiplier.should == 1
2586
2587
  resolved[0].constant.should == 10
2587
2588
  end
2588
2589
  it 'should support `min_baseline 10`' do
2589
- @view = @layout.context(UIView.new) do
2590
+ @layout.context(@view) do
2590
2591
  @layout.constraints do
2591
2592
  @constraint = @layout.min_baseline(10)
2592
2593
  end
@@ -2600,7 +2601,7 @@ describe 'Constraints - Simple helpers' do
2600
2601
  @constraint.attribute2.should == :baseline
2601
2602
  end
2602
2603
  it 'should support `max_baseline 10`' do
2603
- @view = @layout.context(UIView.new) do
2604
+ @layout.context(@view) do
2604
2605
  @layout.constraints do
2605
2606
  @constraint = @layout.max_baseline(10)
2606
2607
  end
@@ -2614,7 +2615,7 @@ describe 'Constraints - Simple helpers' do
2614
2615
  @constraint.attribute2.should == :baseline
2615
2616
  end
2616
2617
  it 'should support `baseline.equals(:another_view[, :baseline])`' do
2617
- @view = @layout.context(UIView.new) do
2618
+ @layout.context(@view) do
2618
2619
  @layout.constraints do
2619
2620
  @constraint = @layout.baseline.equals(:another_view)
2620
2621
  end
@@ -2629,7 +2630,7 @@ describe 'Constraints - Simple helpers' do
2629
2630
  @constraint.attribute2.should == :baseline
2630
2631
  end
2631
2632
  it 'should support `min_baseline.equals(:another_view[, :baseline])`' do
2632
- @view = @layout.context(UIView.new) do
2633
+ @layout.context(@view) do
2633
2634
  @layout.constraints do
2634
2635
  @constraint = @layout.min_baseline.equals(:another_view)
2635
2636
  end
@@ -2644,7 +2645,7 @@ describe 'Constraints - Simple helpers' do
2644
2645
  @constraint.attribute2.should == :baseline
2645
2646
  end
2646
2647
  it 'should support `max_baseline.equals(:another_view[, :baseline])`' do
2647
- @view = @layout.context(UIView.new) do
2648
+ @layout.context(@view) do
2648
2649
  @layout.constraints do
2649
2650
  @constraint = @layout.max_baseline.equals(:another_view)
2650
2651
  end
@@ -2659,7 +2660,7 @@ describe 'Constraints - Simple helpers' do
2659
2660
  @constraint.attribute2.should == :baseline
2660
2661
  end
2661
2662
  it 'should support `baseline.equals(:another_view).plus(10)`' do
2662
- @view = @layout.context(UIView.new) do
2663
+ @layout.context(@view) do
2663
2664
  @layout.constraints do
2664
2665
  @constraint = @layout.baseline.equals(:another_view).plus(10)
2665
2666
  end
@@ -2674,7 +2675,7 @@ describe 'Constraints - Simple helpers' do
2674
2675
  @constraint.attribute2.should == :baseline
2675
2676
  end
2676
2677
  it 'should support `min_baseline.equals(:another_view).plus(10)`' do
2677
- @view = @layout.context(UIView.new) do
2678
+ @layout.context(@view) do
2678
2679
  @layout.constraints do
2679
2680
  @constraint = @layout.min_baseline.equals(:another_view).plus(10)
2680
2681
  end
@@ -2689,7 +2690,7 @@ describe 'Constraints - Simple helpers' do
2689
2690
  @constraint.attribute2.should == :baseline
2690
2691
  end
2691
2692
  it 'should support `max_baseline.equals(:another_view).plus(10)`' do
2692
- @view = @layout.context(UIView.new) do
2693
+ @layout.context(@view) do
2693
2694
  @layout.constraints do
2694
2695
  @constraint = @layout.max_baseline.equals(:another_view).plus(10)
2695
2696
  end
@@ -2704,7 +2705,7 @@ describe 'Constraints - Simple helpers' do
2704
2705
  @constraint.attribute2.should == :baseline
2705
2706
  end
2706
2707
  it 'should support `baseline.equals(:another_view).times(2).plus(10)`' do
2707
- @view = @layout.context(UIView.new) do
2708
+ @layout.context(@view) do
2708
2709
  @layout.constraints do
2709
2710
  @constraint = @layout.baseline.equals(:another_view).times(2).plus(10)
2710
2711
  end
@@ -2719,7 +2720,7 @@ describe 'Constraints - Simple helpers' do
2719
2720
  @constraint.attribute2.should == :baseline
2720
2721
  end
2721
2722
  it 'should support `min_baseline.equals(:another_view).times(2).plus(10)`' do
2722
- @view = @layout.context(UIView.new) do
2723
+ @layout.context(@view) do
2723
2724
  @layout.constraints do
2724
2725
  @constraint = @layout.min_baseline.equals(:another_view).times(2).plus(10)
2725
2726
  end
@@ -2734,7 +2735,7 @@ describe 'Constraints - Simple helpers' do
2734
2735
  @constraint.attribute2.should == :baseline
2735
2736
  end
2736
2737
  it 'should support `max_baseline.equals(:another_view).times(2).plus(10)`' do
2737
- @view = @layout.context(UIView.new) do
2738
+ @layout.context(@view) do
2738
2739
  @layout.constraints do
2739
2740
  @constraint = @layout.max_baseline.equals(:another_view).times(2).plus(10)
2740
2741
  end