Skip to content

Commit 969feda

Browse files
committed
Integrated Quick and Nimble for iOS
1 parent 2b2273c commit 969feda

File tree

11 files changed

+241
-184
lines changed

11 files changed

+241
-184
lines changed

Objection.xcodeproj/project.pbxproj

+169-125
Large diffs are not rendered by default.

Objection.xcodeproj/xcshareddata/xcschemes/Specs-iOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<BuildableReference
1818
BuildableIdentifier = "primary"
1919
BlueprintIdentifier = "4B42580713F56CC0006BC001"
20-
BuildableName = "Specs-iOS.octest"
20+
BuildableName = "Specs-iOS.xctest"
2121
BlueprintName = "Specs-iOS"
2222
ReferencedContainer = "container:Objection.xcodeproj">
2323
</BuildableReference>

Specs/BasicUsageSpecs.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#import "InitializerFixtures.h"
44

55
QuickSpecBegin(BasicUsageSpecs)
6+
67
beforeEach(^{
78
JSObjectionInjector *injector = [JSObjection createInjector];
89
[JSObjection setDefaultInjector:injector];
@@ -126,9 +127,7 @@
126127
SingletonItem *item1 = holder1.objectFactory[[SingletonItem class]];
127128
SingletonItem *item2 = [holder2.objectFactory getObject:[SingletonItem class]];
128129

129-
// [[expect(item1)] to: equal(item2)];
130-
// expect(item1).to(equal(item2));
131-
expect(item1).to(equal(item2));
130+
expect(item1).toNot(equal(item2));
132131
});
133132

134133
it(@"can take variadic arguments and pass them along to the injector", ^{
@@ -137,9 +136,9 @@
137136

138137
ConfigurableCar *car = [factory getObjectWithArgs:[ConfigurableCar class], @"Model", @"Power", @"Year", nil];
139138

140-
[[car.model should] equal:@"Model"];
141-
[[car.horsePower should] equal:@"Power"];
142-
[[car.year should] equal:@"Year"];
139+
expect(car.model).to(equal(@"Model"));
140+
expect(car.horsePower).to(equal(@"Power"));
141+
expect(car.year).to(equal(@"Year"));
143142
});
144143
});
145144

Specs/InitializerSpecs.m

+15-17
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,42 @@
1111
it(@"instantiates the object with the default initializer arguments", ^{
1212
ViewController *controller = [injector getObject:[ViewController class]];
1313

14-
[[controller.nibName should] equal:@"MyNib"];
15-
assertThat(controller.bundle, nilValue());
16-
[[controller.car should] beMemberOfClass:[Car class]];
14+
expect(controller.nibName).to(equal(@"MyNib"));
15+
expect(controller.bundle).to(beNil());
16+
expect(controller.car).to(beAKindOf([Car class]));
1717
});
1818

1919
it(@"will override the default arguments if arguments are passed to the injector", ^{
2020
ViewController *controller = [injector getObjectWithArgs:[ViewController class], @"AnotherNib", @"pretendBundle", nil];
21-
22-
[[controller.nibName should] equal:@"AnotherNib"];
23-
[[controller.bundle should] equal:@"pretendBundle"];
24-
[[controller.car should] beMemberOfClass:[Car class]];
21+
22+
expect(controller.nibName).to(equal(@"AnotherNib"));
23+
expect(controller.bundle).to(equal(@"pretendBundle"));
24+
expect(controller.car).to(beAKindOf([Car class]));
2525
});
2626

2727
it(@"is OK to register an object with an initializer without any default arguments", ^{
2828
ConfigurableCar *car = [injector getObjectWithArgs:[ConfigurableCar class], @"Passat", [NSNumber numberWithInt:200], [NSNumber numberWithInt:2002], nil];
2929

30-
[[car.horsePower should] equal:[NSNumber numberWithInt:200]];
31-
[[car.model should] equal:@"Passat"];
32-
[[car.year should] equal:[NSNumber numberWithInt:2002]];
33-
[[car.engine should] beMemberOfClass:[Engine class]];
30+
expect(car.horsePower).to(equal(@200));
31+
expect(car.model).to(equal(@"Passat"));
32+
expect(car.year).to(equal(@2002));
33+
expect(car.engine).to(beAKindOf([Engine class]));
3434
});
3535

3636
it(@"raises an exception if the initializer is not valid", ^{
37-
[[theBlock(^{
38-
[injector getObject:[BadInitializer class]];
39-
}) should] raiseWithReason:@"Could not find initializer 'initWithNonExistentInitializer' on BadInitializer"];
37+
expect([injector getObject:[BadInitializer class]]).to(raiseException().reason(@"Could not find initializer 'initWithNonExistentInitializer' on BadInitializer"));
4038
});
4139

4240
it(@"supports initializing an object with a class method", ^{
4341
Truck *truck = [injector getObjectWithArgs:[Truck class], @"Ford", nil];
4442

45-
[[truck shouldNot] beNil];
46-
[[truck.name should] equal:@"Ford"];
43+
expect(truck).toNot(beNil());
44+
expect(truck.name).to(equal(@"Ford"));
4745
});
4846

4947
it(@"filters the init initializer as a class initializer option", ^{
5048
FilterInitInitializer *obj = [injector getObject:[FilterInitInitializer class]];
51-
[[obj shouldNot] beNil];
49+
expect(obj).toNot(beNil());
5250
});
5351

5452
QuickSpecEnd

Specs/InjectionErrorsSpecs.m

+6-13
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,26 @@
44

55
QuickSpecBegin(InjectionErrorsSpecs)
66

7+
78
beforeEach(^{
89
JSObjectionInjector *injector = [JSObjection createInjector];
910
[JSObjection setDefaultInjector:injector];
1011
});
1112

1213
it(@"throws an exception if property type is not an object", ^{
13-
[[theBlock(^{
14-
[[JSObjection defaultInjector] getObject:[UnsupportedPropertyObject class]];
15-
}) should] raiseWithReason:@"Unable to determine class type for property declaration: 'myInteger'"];
14+
expectAction([[JSObjection defaultInjector] getObject:[UnsupportedPropertyObject class]]).to(raiseException().reason(@"Unable to determine class type for property declaration: 'myInteger'"));
1615
});
1716

1817
it(@"throws an exception if property cannot be found", ^{
19-
[[theBlock(^{
20-
[[JSObjection defaultInjector] getObject:[BadPropertyObject class]];
21-
}) should] raiseWithReason:@"Unable to find property declaration: 'badProperty' for class 'BadPropertyObject'"];
18+
expectAction([[JSObjection defaultInjector] getObject:[BadPropertyObject class]]).to(raiseException().reason(@"Unable to find property declaration: 'badProperty' for class 'BadPropertyObject'"));
2219
});
2320

2421
it(@"throws if an object requires a protocol that does not exist in the context", ^{
25-
[[theBlock(^{
26-
[[JSObjection defaultInjector] getObject:[FiveSpeedCar class]];
27-
}) should] raiseWithReason:@"Cannot find an instance that is bound to the protocol 'GearBox' to assign to the property 'gearBox'"];
22+
expectAction([[JSObjection defaultInjector] getObject:[FiveSpeedCar class]]).to(raiseException().reason(@"Cannot find an instance that is bound to the protocol 'GearBox' to assign to the property 'gearBox'"));
2823
});
2924

30-
it(@"throws if instantiation rule is not valid", ^{
31-
[[theBlock(^{
32-
[JSObjection registerClass:[CarFactory class] scope:3];
33-
}) should] raiseWithReason:@"Invalid Instantiation Rule"];
25+
it(@"throws if instantiation rule is not valid", ^{
26+
expectAction([JSObjection registerClass:[CarFactory class] scope:3]).to(raiseException().reason(@"Invalid Instantiation Rule"));
3427
});
3528

3629

Specs/ModuleUsageSpecs.m

+9-19
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@
3232

3333
it(@"throws an exception if the instance does not conform to the protocol", ^{
3434
Engine *engine = [[Engine alloc] init];
35-
36-
[[theBlock(^{
37-
MyModule *module = [[MyModule alloc] initWithEngine:engine andGearBox:(id)@"no go"];
38-
[module configure];
39-
}) should] raiseWithReason:@"Instance does not conform to the GearBox protocol"];
35+
MyModule *module = [[MyModule alloc] initWithEngine:engine andGearBox:(id)@"no go"];
36+
expectAction([module configure]).to(raiseException().reason(@"Instance does not conform to the GearBox protocol"));
4037
});
4138

4239
it(@"supports eager singletons", ^{
@@ -45,14 +42,10 @@
4542

4643
it(@"throws an exception if an attempt is made to register an eager singleton that was not registered as a singleton", ^{
4744
Engine *engine = [[Engine alloc] init];
48-
49-
[[theBlock(^{
50-
id<GearBox> gearBox = [[AfterMarketGearBox alloc] init];
51-
MyModule *module = [[MyModule alloc] initWithEngine:engine andGearBox:gearBox];
52-
module.instrumentInvalidEagerSingleton = YES;
53-
[JSObjection createInjector:module];
54-
}) should] raiseWithReason:@"Unable to initialize eager singleton for the class 'Car' because it was never registered as a singleton"];
55-
45+
id<GearBox> gearBox = [[AfterMarketGearBox alloc] init];
46+
MyModule *module = [[MyModule alloc] initWithEngine:engine andGearBox:gearBox];
47+
module.instrumentInvalidEagerSingleton = YES;
48+
expectAction([JSObjection createInjector:module]).to(raiseException().reason(@"Unable to initialize eager singleton for the class 'Car' because it was never registered as a singleton"));
5649
});
5750

5851
describe(@"provider bindings", ^{
@@ -132,12 +125,9 @@
132125
it(@"throws an exception if the given object is not a meta class", ^{
133126
id<GearBox> gearBox = [[AfterMarketGearBox alloc] init];
134127
Engine *engine = [[Engine alloc] init];
135-
136-
[[theBlock(^{
137-
MyModule *module = [[MyModule alloc] initWithEngine:engine andGearBox:gearBox];
138-
module.instrumentInvalidMetaClass = YES;
139-
[module configure];
140-
}) should] raiseWithReason:@"\"sneaky\" can not be bound to the protocol \"MetaCar\" because it is not a meta class"];
128+
MyModule *module = [[MyModule alloc] initWithEngine:engine andGearBox:gearBox];
129+
module.instrumentInvalidMetaClass = YES;
130+
expectAction([module configure]).to(raiseException().reason(@"\"sneaky\" can not be bound to the protocol \"MetaCar\" because it is not a meta class"));
141131
});
142132

143133
});

Specs/SpecHelper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#endif
1010

1111
#import "Objection.h"
12-
#define QUICK_DISABLE_SHORT_SYNTAX 1
1312
#import <Quick/Quick.h>
13+
#import <Nimble/Nimble-Swift.h>
1414
#import <Nimble/Nimble.h>
1515
#import <Foundation/Foundation.h>
1616

Stub.swift

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// Stub.swift
3+
// Objection
4+
//
5+
// Created by Justin DeWind on 3/24/15.
6+
//
7+
//
8+
9+
import XCTest
10+
11+
class Stub: XCTestCase {
12+
13+
override func setUp() {
14+
super.setUp()
15+
// Put setup code here. This method is called before the invocation of each test method in the class.
16+
}
17+
18+
override func tearDown() {
19+
// Put teardown code here. This method is called after the invocation of each test method in the class.
20+
super.tearDown()
21+
}
22+
23+
func testExample() {
24+
// This is an example of a functional test case.
25+
XCTAssert(true, "Pass")
26+
}
27+
28+
func testPerformanceExample() {
29+
// This is an example of a performance test case.
30+
self.measureBlock() {
31+
// Put the code you want to measure the time of here.
32+
}
33+
}
34+
35+
}

Vendor/Vendor/Nimble

Submodule Nimble deleted from 0f664fb

Vendor/Vendor/Quick

Submodule Quick deleted from f1cf756

xcodebuild

Whitespace-only changes.

0 commit comments

Comments
 (0)