Skip to content

Commit 141e173

Browse files
committed
Basic Testing setup with Specta & Expecta
1 parent f6d93a5 commit 141e173

File tree

8 files changed

+393
-4
lines changed

8 files changed

+393
-4
lines changed

OAuth2Client.xcodeproj/project.pbxproj

Lines changed: 208 additions & 4 deletions
Large diffs are not rendered by default.

OAuth2Client.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OAuth2Client.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Podfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
target "OAuth2Client.framework" do
2+
3+
end
4+
5+
target "OAuth2Client" do
6+
platform :ios, "4.3" #that shit cray!
7+
8+
end
9+
10+
target "OAuth2ClientTests" do
11+
platform :ios, "5.0"
12+
13+
pod 'Specta', '~> 0.2'
14+
pod 'Expecta', '~> 0.3'
15+
pod 'OCMock', '~> 3.1'
16+
pod 'OHHTTPStubs', '~> 3.1'
17+
18+
19+
post_install do |installer|
20+
21+
# fixing Specta for Xcode 6
22+
# http://stackoverflow.com/a/25078857/25724
23+
puts "Fixing Specta pod for Xcode 6"
24+
target = installer.project.targets.find { |t| t.to_s == "Pods-OAuth2ClientTests-Specta" }
25+
if (target)
26+
target.build_configurations.each do |config|
27+
s = config.build_settings['FRAMEWORK_SEARCH_PATHS']
28+
s = [ '$(inherited)' ] if s == nil;
29+
s.push('$(PLATFORM_DIR)/Developer/Library/Frameworks')
30+
config.build_settings['FRAMEWORK_SEARCH_PATHS'] = s
31+
end
32+
else
33+
puts "WARNING: Pods-OAuth2ClientTests-Specta target not found"
34+
end
35+
end
36+
end
37+

Podfile.lock

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
PODS:
2+
- Expecta (0.3.1)
3+
- OCMock (3.1.1)
4+
- OHHTTPStubs (3.1.5):
5+
- OHHTTPStubs/Core
6+
- OHHTTPStubs/Core (3.1.5)
7+
- Specta (0.2.1)
8+
9+
DEPENDENCIES:
10+
- Expecta (~> 0.3)
11+
- OCMock (~> 3.1)
12+
- OHHTTPStubs (~> 3.1)
13+
- Specta (~> 0.2)
14+
15+
SPEC CHECKSUMS:
16+
Expecta: 03aabd0a89d8dea843baecb19a7fd7466a69a31d
17+
OCMock: f6cb8c162ab9d5620dddf411282c7b2c0ee78854
18+
OHHTTPStubs: c1e362552b71b81e1deb7a80f44c51585b946c43
19+
Specta: 9141310f46b1f68b676650ff2854e1ed0b74163a
20+
21+
COCOAPODS: 0.33.1

Tests/Info.plist

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>com.nxtbgthng.$(PRODUCT_NAME:rfc1034identifier)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
</dict>
24+
</plist>

Tests/NXOAuth2PostBodyStreamSpec.m

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#import "NXOAuth2PostBodyStream.h"
2+
3+
4+
SpecBegin(NXOAuth2PostBodyStream)
5+
6+
describe(@"NXOAuth2PostBodyStream", ^{
7+
8+
describe(@"-initWithParameters:", ^{
9+
it(@"returns an new instance", ^{
10+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:@{}];
11+
expect(stream).toNot.beNil();
12+
});
13+
14+
it(@"does not crash on nil parameter", ^{
15+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:nil];
16+
expect(stream).toNot.beNil();
17+
});
18+
19+
20+
it(@"generates a boundary", ^{
21+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:@{}];
22+
expect(stream.boundary).toNot.beNil();
23+
});
24+
});
25+
26+
27+
describe(@".boundary", ^{
28+
it(@"is generated ", ^{
29+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:@{}];
30+
expect(stream).toNot.beNil();
31+
});
32+
});
33+
34+
35+
describe(@".length", ^{
36+
it(@"zero length with nil parameters", ^{
37+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:nil];
38+
expect(stream.length).to.equal(0);
39+
});
40+
41+
xit(@"zero length with empty parameters", ^{
42+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:@{}];
43+
expect(stream.length).to.equal(0);
44+
});
45+
46+
47+
it(@"correct length for parameters", ^{
48+
NSDictionary *parameter = @{@"foo": @"bar",
49+
@"rab": @(0.0f)};
50+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:parameter];
51+
52+
expect(stream.length).to.equal(204);
53+
});
54+
});
55+
56+
57+
xdescribe(@"NSInputStream", ^{
58+
describe(@"-scheduleInRunLoop:forMode:", ^{
59+
it(@"triggers no assert when called", ^{
60+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:@{}];
61+
62+
expect(^{
63+
[stream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
64+
}).toNot.raiseAny();
65+
});
66+
});
67+
68+
describe(@"-removeFromRunLoop:forMode:", ^{
69+
it(@"triggers no assert when called", ^{
70+
NXOAuth2PostBodyStream *stream = [[NXOAuth2PostBodyStream alloc] initWithParameters:@{}];
71+
72+
expect(^{
73+
[stream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
74+
}).toNot.raiseAny();
75+
});
76+
});
77+
});
78+
});
79+
80+
SpecEnd

Tests/OAuth2ClientTests.pch

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Prefix header
3+
//
4+
// The contents of this file are implicitly included at the beginning of every source file.
5+
//
6+
7+
#ifdef __OBJC__
8+
#import <XCTest/XCTest.h>
9+
#import <Specta/Specta.h>
10+
#define EXP_SHORTHAND
11+
#import <Expecta/Expecta.h>
12+
#import <OCMock/OCMock.h>
13+
#import <OHHTTPStubs/OHHTTPStubs.h>
14+
#import <OHHTTPStubs/OHHTTPStubsResponse+HTTPMessage.h>
15+
#endif

0 commit comments

Comments
 (0)