Skip to content

Commit e04b3b3

Browse files
committed
Convert Tests to Kiwi Specs. Integrate travis-ci
1 parent 2e6cd2e commit e04b3b3

File tree

8 files changed

+410
-551
lines changed

8 files changed

+410
-551
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ profile
1616
*.moved-aside
1717
DerivedData
1818
.idea/
19+
20+
# CocoaPods
21+
Tests/Pods/**/*

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: objective-c
2+
before_install: rake travis:before_install
3+
install: rake travis:install
4+
script: rake travis:script

Rakefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
desc "Run tests"
2+
task :test do
3+
system 'xctool -workspace Tests/ECSlidingViewController.xcworkspace -scheme ECSlidingViewController -sdk iphonesimulator test'
4+
end
5+
6+
namespace :travis do
7+
task :before_install do
8+
system 'brew update'
9+
end
10+
11+
task :install do
12+
system 'brew uninstall xctool'
13+
system 'brew install xctool --HEAD'
14+
end
15+
16+
task :script => 'test'
17+
end

Tests/ECSlidingViewController.xcodeproj/project.pbxproj

Lines changed: 53 additions & 194 deletions
Large diffs are not rendered by default.
Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
// ECSlidingViewControllerSpec.m
2+
// ECSlidingViewController
3+
//
4+
// Copyright (c) 2013, Michael Enriquez (http://enriquez.me)
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
24+
#import "Kiwi.h"
25+
#import "ECSlidingViewController.h"
26+
27+
SPEC_BEGIN(ECSlidingViewControllerSpec)
28+
29+
describe(@"ECSlidingViewController", ^{
30+
__block UIViewController *topViewController;
31+
__block UIViewController *underLeftViewController;
32+
__block UIViewController *underRightViewController;
33+
__block ECSlidingViewController *slidingViewController;
34+
35+
beforeEach(^{
36+
topViewController = [[UIViewController alloc] init];
37+
underLeftViewController = [[UIViewController alloc] init];
38+
underRightViewController = [[UIViewController alloc] init];
39+
slidingViewController = [ECSlidingViewController slidingWithTopViewController:topViewController];
40+
slidingViewController.underLeftViewController = underLeftViewController;
41+
slidingViewController.underRightViewController = underRightViewController;
42+
43+
slidingViewController.view.frame = CGRectMake(0, 0, 320, 480);
44+
});
45+
46+
it(@"gets topViewController", ^{
47+
[[slidingViewController.topViewController should] equal:topViewController];
48+
});
49+
50+
it(@"gets underLeftViewController", ^{
51+
[[slidingViewController.underLeftViewController should] equal:underLeftViewController];
52+
});
53+
54+
it(@"gets underRightViewController", ^{
55+
[[slidingViewController.underRightViewController should] equal:underRightViewController];
56+
});
57+
58+
it(@"gets default anchor amounts", ^{
59+
[[theValue(slidingViewController.anchorLeftPeekAmount) should] equal:@44.0];
60+
[[theValue(slidingViewController.anchorLeftRevealAmount) should] equal:@276.0];
61+
[[theValue(slidingViewController.anchorRightPeekAmount) should] equal:@44.0];
62+
[[theValue(slidingViewController.anchorRightRevealAmount) should] equal:@276.0];
63+
});
64+
65+
it(@"sets anchorLeftPeekAmount", ^{
66+
slidingViewController.anchorLeftPeekAmount = 50.0;
67+
[[theValue(slidingViewController.anchorLeftPeekAmount) should] equal:@50.0];
68+
[[theValue(slidingViewController.anchorLeftRevealAmount) should] equal:@270.0];
69+
});
70+
71+
it(@"sets anchorLeftRevealAmount", ^{
72+
slidingViewController.anchorLeftRevealAmount = 250.0;
73+
[[theValue(slidingViewController.anchorLeftRevealAmount) should] equal:@250.0];
74+
[[theValue(slidingViewController.anchorLeftPeekAmount) should] equal:@70.0];
75+
});
76+
77+
it(@"sets anchorRightPeekAmount", ^{
78+
slidingViewController.anchorRightPeekAmount = 60.0;
79+
[[theValue(slidingViewController.anchorRightPeekAmount) should] equal:@60.0];
80+
[[theValue(slidingViewController.anchorRightRevealAmount) should] equal:@260.0];
81+
});
82+
83+
it(@"sets anchorRightRevealAmount", ^{
84+
slidingViewController.anchorRightRevealAmount = 260.0;
85+
[[theValue(slidingViewController.anchorRightRevealAmount) should] equal:@260.0];
86+
[[theValue(slidingViewController.anchorRightPeekAmount) should] equal:@60.0];
87+
});
88+
89+
it(@"loads the container view", ^{
90+
UIView *view = slidingViewController.view;
91+
[[view shouldNot] beNil];
92+
});
93+
94+
it(@"throws an exception when attempting to load the container view without a topViewController", ^{
95+
slidingViewController = [[ECSlidingViewController alloc] init];
96+
[[theBlock(^{
97+
UIView *view = slidingViewController.view;
98+
[[view shouldNot] beNil];
99+
}) should] raise];
100+
});
101+
102+
describe(@"viewControllerForKey:", ^{
103+
it(@"returns the topViewController", ^{
104+
[[[slidingViewController viewControllerForKey:ECTransitionContextTopViewControllerKey]
105+
should] equal:topViewController];
106+
});
107+
108+
it(@"returns the underLeftViewController", ^{
109+
[[[slidingViewController viewControllerForKey:ECTransitionContextUnderLeftControllerKey]
110+
should] equal:underLeftViewController];
111+
});
112+
113+
it(@"returns the underRightViewController", ^{
114+
[[[slidingViewController viewControllerForKey:ECTransitionContextUnderRightControllerKey]
115+
should] equal:underRightViewController];
116+
});
117+
});
118+
119+
describe(@"initialFrameForViewController:", ^{
120+
beforeEach(^{
121+
slidingViewController.anchorLeftPeekAmount = 50.0;
122+
slidingViewController.anchorRightRevealAmount = 200.0;
123+
});
124+
125+
context(@"reset from left operation", ^{
126+
beforeEach(^{
127+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationResetFromLeft]
128+
forKey:@"currentOperation"];
129+
});
130+
131+
it(@"starts the top view anchored left", ^{
132+
[[theValue([slidingViewController initialFrameForViewController:topViewController])
133+
should] equal:theValue(CGRectMake(-270.0, 0, 320, 480))];
134+
});
135+
136+
it(@"starts the under left view hidden", ^{
137+
[[theValue([slidingViewController initialFrameForViewController:underLeftViewController])
138+
should] equal:theValue(CGRectZero)];
139+
});
140+
141+
it(@"starts the under right view visible", ^{
142+
[[theValue([slidingViewController initialFrameForViewController:underRightViewController])
143+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
144+
});
145+
});
146+
147+
context(@"reset from right operation", ^{
148+
beforeEach(^{
149+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationResetFromRight]
150+
forKey:@"currentOperation"];
151+
});
152+
153+
it(@"starts the top view anchored right", ^{
154+
[[theValue([slidingViewController initialFrameForViewController:topViewController])
155+
should] equal:theValue(CGRectMake(200, 0, 320, 480))];
156+
});
157+
158+
it(@"starts the under left view visible", ^{
159+
[[theValue([slidingViewController initialFrameForViewController:underLeftViewController])
160+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
161+
});
162+
163+
it(@"starts the under right view hidden", ^{
164+
[[theValue([slidingViewController initialFrameForViewController:underRightViewController])
165+
should] equal:theValue(CGRectZero)];
166+
});
167+
});
168+
169+
context(@"anchor right operation", ^{
170+
beforeEach(^{
171+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationAnchorRight]
172+
forKey:@"currentOperation"];
173+
});
174+
175+
it(@"starts the top view centered", ^{
176+
[[theValue([slidingViewController initialFrameForViewController:topViewController])
177+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
178+
});
179+
180+
it(@"starts the under left view visible", ^{
181+
[[theValue([slidingViewController initialFrameForViewController:underLeftViewController])
182+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
183+
});
184+
185+
it(@"starts the under right view hidden", ^{
186+
[[theValue([slidingViewController initialFrameForViewController:underRightViewController])
187+
should] equal:theValue(CGRectZero)];
188+
});
189+
});
190+
191+
context(@"anchor left operation", ^{
192+
beforeEach(^{
193+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationAnchorLeft]
194+
forKey:@"currentOperation"];
195+
});
196+
197+
it(@"starts the top view centered", ^{
198+
[[theValue([slidingViewController initialFrameForViewController:topViewController])
199+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
200+
});
201+
202+
it(@"starts the under left view hidden", ^{
203+
[[theValue([slidingViewController initialFrameForViewController:underLeftViewController])
204+
should] equal:theValue(CGRectZero)];
205+
});
206+
207+
it(@"starts the under right view visible", ^{
208+
[[theValue([slidingViewController initialFrameForViewController:underRightViewController])
209+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
210+
});
211+
});
212+
});
213+
214+
describe(@"finalFrameForViewController:", ^{
215+
beforeEach(^{
216+
slidingViewController.anchorLeftPeekAmount = 50.0;
217+
slidingViewController.anchorRightRevealAmount = 200.0;
218+
});
219+
220+
context(@"reset from left operation", ^{
221+
beforeEach(^{
222+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationResetFromLeft]
223+
forKey:@"currentOperation"];
224+
});
225+
226+
it(@"ends the top view centered", ^{
227+
[[theValue([slidingViewController finalFrameForViewController:topViewController])
228+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
229+
});
230+
231+
it(@"ends the under left view hidden", ^{
232+
[[theValue([slidingViewController finalFrameForViewController:underLeftViewController])
233+
should] equal:theValue(CGRectZero)];
234+
});
235+
236+
it(@"ends the under right view hidden", ^{
237+
[[theValue([slidingViewController finalFrameForViewController:underRightViewController])
238+
should] equal:theValue(CGRectZero)];
239+
});
240+
});
241+
242+
context(@"reset from right operation", ^{
243+
beforeEach(^{
244+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationResetFromRight]
245+
forKey:@"currentOperation"];
246+
});
247+
248+
it(@"ends the top view centered", ^{
249+
[[theValue([slidingViewController finalFrameForViewController:topViewController])
250+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
251+
});
252+
253+
it(@"ends the under left view hidden", ^{
254+
[[theValue([slidingViewController finalFrameForViewController:underLeftViewController])
255+
should] equal:theValue(CGRectZero)];
256+
});
257+
258+
it(@"ends the under right view hidden", ^{
259+
[[theValue([slidingViewController finalFrameForViewController:underRightViewController])
260+
should] equal:theValue(CGRectZero)];
261+
});
262+
});
263+
264+
context(@"anchor right operation", ^{
265+
beforeEach(^{
266+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationAnchorRight]
267+
forKey:@"currentOperation"];
268+
});
269+
270+
it(@"ends the top view anchored right", ^{
271+
[[theValue([slidingViewController finalFrameForViewController:topViewController])
272+
should] equal:theValue(CGRectMake(200, 0, 320, 480))];
273+
});
274+
275+
it(@"ends the under left view visible", ^{
276+
[[theValue([slidingViewController finalFrameForViewController:underLeftViewController])
277+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
278+
});
279+
280+
it(@"ends the under right view hidden", ^{
281+
[[theValue([slidingViewController finalFrameForViewController:underRightViewController])
282+
should] equal:theValue(CGRectZero)];
283+
});
284+
});
285+
286+
context(@"anchor left operation", ^{
287+
beforeEach(^{
288+
[slidingViewController setValue:[NSNumber numberWithInteger:ECSlidingViewControllerOperationAnchorLeft]
289+
forKey:@"currentOperation"];
290+
});
291+
292+
it(@"ends the top view anchored left", ^{
293+
[[theValue([slidingViewController finalFrameForViewController:topViewController])
294+
should] equal:theValue(CGRectMake(-270, 0, 320, 480))];
295+
});
296+
297+
it(@"ends the under left view hidden", ^{
298+
[[theValue([slidingViewController finalFrameForViewController:underLeftViewController])
299+
should] equal:theValue(CGRectZero)];
300+
});
301+
302+
it(@"ends the under right view visible", ^{
303+
[[theValue([slidingViewController finalFrameForViewController:underRightViewController])
304+
should] equal:theValue(CGRectMake(0, 0, 320, 480))];
305+
});
306+
});
307+
});
308+
});
309+
310+
SPEC_END

0 commit comments

Comments
 (0)