Skip to content

Commit

Permalink
Fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido Marucci Blas committed Mar 1, 2015
1 parent 1a39de2 commit f263a51
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ end
target 'Tests', :exclusive => true do
pod "WLXBluetoothDevice", :path => "../"

pod 'Specta', '~> 0.2.1'
pod 'Specta', '~> 0.3.2'
pod 'Expecta'
pod 'OCMockito', '~> 1.0'
end
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ PODS:
- OCHamcrest (4.1.1)
- OCMockito (1.4.0):
- OCHamcrest (~> 4.0)
- Specta (0.2.1)
- Specta (0.3.2)
- WLXBluetoothDevice (0.1.0-beta2):
- CocoaLumberjack (~> 2.0.0-rc)

DEPENDENCIES:
- CocoaLumberjack (~> 2.0.0-rc)
- Expecta
- OCMockito (~> 1.0)
- Specta (~> 0.2.1)
- Specta (~> 0.3.2)
- WLXBluetoothDevice (from `../`)

EXTERNAL SOURCES:
Expand All @@ -31,7 +31,7 @@ SPEC CHECKSUMS:
Expecta: 03aabd0a89d8dea843baecb19a7fd7466a69a31d
OCHamcrest: af1c7c5ea345de69ea6c9c2958f65f3044e5c420
OCMockito: 991936bb775cc4c27f063d38f5e17b9161fbd21c
Specta: 9141310f46b1f68b676650ff2854e1ed0b74163a
Specta: 698a58ffa5ec948327d3b92eab50ca58d7f4fbe8
WLXBluetoothDevice: b8715f0e074bcc3e5b88073d06c5f592d8d2ea21

COCOAPODS: 0.35.0
8 changes: 4 additions & 4 deletions Example/Tests/WLXBluetoothConnectionManagerSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@
[MKTVerify(connectionManagerDelegate) connectionManager:connectionManager didFailToConnect:error];
});

it(@"passes the error to the connection block", ^AsyncBlock{
it(@"passes the error to the connection block", ^{ waitUntil(^(DoneCallback done) {
[connectionManager connectWithTimeout:0 usingBlock:^(NSError * anError){
expect(anError).to.equal(error);
done();
}];
[connectionManager didFailToConnect:error];
});
});});

});

Expand Down Expand Up @@ -283,13 +283,13 @@
[MKTVerify(connectionManagerDelegate) connectionManagerDidConnect:connectionManager];
});

it(@"calls the connection block", ^AsyncBlock{
it(@"calls the connection block", ^{ waitUntil(^(DoneCallback done) {
[connectionManager connectWithTimeout:0 usingBlock:^(NSError * error){
expect(error).to.beNil;
done();
}];
[connectionManager didConnect];
});
});});

});

Expand Down
4 changes: 2 additions & 2 deletions Example/Tests/WLXCharacteristicAsyncExecutorSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
[MKTGiven([mockLocator characteristicFromUUID:characteristicUUID]) willReturn:mockCharacteristic];
});

it(@"executes the block immediately", ^AsyncBlock{
it(@"executes the block immediately", ^{ waitUntil(^(DoneCallback done) {
[asyncExecutor executeBlock:^(NSError * error, CBCharacteristic * characteristic){
expect(error).to.beNil;
expect(characteristic).to.equal(mockCharacteristic);
done();
} forCharacteristic:characteristicUUID];
});
});});

});

Expand Down
76 changes: 38 additions & 38 deletions Example/Tests/WLXServiceManagerSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ - (void)updatedValue:(NSData *)data error:(NSError *)error {
[MKTGiven(mockCharacteristic.value) willReturn:data];
});

it(@"calls the block with the read data", ^AsyncBlock{
it(@"calls the block with the read data", ^{ waitUntil(^(DoneCallback done) {
[serviceManager readValueFromCharacteristic:characteristicUUID usingBlock:^(NSError * error, NSData * data) {
[MKTVerify(mockPeripheral) readValueForCharacteristic:mockCharacteristic];
expect(error).to.beNil;
expect(data).to.equal(data);
done();
}];
ASYNC([serviceManager didUpdateValueForCharacteristic:mockCharacteristic error:nil]);
});
});});

it(@"calls the peripheral's readValueForCharacteristic", ^AsyncBlock{
it(@"calls the peripheral's readValueForCharacteristic", ^{ waitUntil(^(DoneCallback done) {
[serviceManager readValueFromCharacteristic:characteristicUUID usingBlock:^(NSError * error, NSData * data) {
[MKTVerify(mockPeripheral) readValueForCharacteristic:mockCharacteristic];
done();
}];
ASYNC([serviceManager didUpdateValueForCharacteristic:mockCharacteristic error:nil]);
});
});});

});

Expand All @@ -138,23 +138,23 @@ - (void)updatedValue:(NSData *)data error:(NSError *)error {
error = [NSError errorWithDomain:@"ar.com.wolox.Test" code:0 userInfo:nil];
});

it(@"call the block with an error", ^AsyncBlock{
it(@"call the block with an error", ^{ waitUntil(^(DoneCallback done) {
[serviceManager readValueFromCharacteristic:characteristicUUID usingBlock:^(NSError * error, NSData * data) {
[MKTVerify(mockPeripheral) readValueForCharacteristic:mockCharacteristic];
expect(error).notTo.beNil;
expect(data).to.beNil;
done();
}];
ASYNC([serviceManager didUpdateValueForCharacteristic:mockCharacteristic error:error]);
});
});});

it(@"calls the peripheral's readValueForCharacteristic", ^AsyncBlock{
it(@"calls the peripheral's readValueForCharacteristic", ^{ waitUntil(^(DoneCallback done) {
[serviceManager readValueFromCharacteristic:characteristicUUID usingBlock:^(NSError * error, NSData * data) {
[MKTVerify(mockPeripheral) readValueForCharacteristic:mockCharacteristic];
done();
}];
ASYNC([serviceManager didUpdateValueForCharacteristic:mockCharacteristic error:error]);
});
});});

});

Expand Down Expand Up @@ -200,41 +200,41 @@ - (void)updatedValue:(NSData *)data error:(NSError *)error {

context(@"when the characteristic's value is successfully writen", ^{

it(@"calls the block with a nil error", ^AsyncBlock{
it(@"calls the block with a nil error", ^{ waitUntil(^(DoneCallback done) {
[serviceManager writeValue:data toCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
expect(error).to.beNil;
done();
}];
ASYNC([serviceManager didWriteValueForCharacteristic:mockCharacteristic error:nil]);
});
});});

it(@"calls the peripheral's writeValue:forCharacteristic:type: method", ^AsyncBlock{
it(@"calls the peripheral's writeValue:forCharacteristic:type: method", ^{ waitUntil(^(DoneCallback done) {
[serviceManager writeValue:data toCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
[MKTVerify(mockPeripheral) writeValue:data forCharacteristic:mockCharacteristic type:CBCharacteristicWriteWithResponse];
done();
}];
ASYNC([serviceManager didWriteValueForCharacteristic:mockCharacteristic error:nil]);
});
});});

});

context(@"when the characteristic's value could not be writen", ^{

it(@"calls the block with an error", ^AsyncBlock{
it(@"calls the block with an error", ^{ waitUntil(^(DoneCallback done) {
[serviceManager writeValue:data toCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
expect(error).notTo.beNil;
done();
}];
ASYNC([serviceManager didWriteValueForCharacteristic:mockCharacteristic error:error]);
});
});});

it(@"calls the peripheral's writeValue:forCharacteristic:type: method", ^AsyncBlock{
it(@"calls the peripheral's writeValue:forCharacteristic:type: method", ^{ waitUntil(^(DoneCallback done) {
[serviceManager writeValue:data toCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
[MKTVerify(mockPeripheral) writeValue:data forCharacteristic:mockCharacteristic type:CBCharacteristicWriteWithResponse];
done();
}];
ASYNC([serviceManager didWriteValueForCharacteristic:mockCharacteristic error:error]);
});
});});

});

Expand Down Expand Up @@ -267,13 +267,13 @@ - (void)updatedValue:(NSData *)data error:(NSError *)error {

});

it(@"calls the peripheral's writeValue:forCharacteristic:type: method", ^AsyncBlock {
it(@"calls the peripheral's writeValue:forCharacteristic:type: method", ^{ waitUntil(^(DoneCallback done) {
[serviceManager writeValue:data toCharacteristic:characteristicUUID];
ASYNC({
[MKTVerify(mockPeripheral) writeValue:data forCharacteristic:mockCharacteristic type:CBCharacteristicWriteWithoutResponse];
done();
});
});
});});

});

Expand Down Expand Up @@ -301,41 +301,41 @@ - (void)updatedValue:(NSData *)data error:(NSError *)error {

context(@"when the notifications are successfully enabled", ^{

it(@"calls the block", ^AsyncBlock{
it(@"calls the block", ^{ waitUntil(^(DoneCallback done) {
[serviceManager enableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
expect(error).to.beNil;
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:nil]);
});
});});

it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^AsyncBlock{
it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^{ waitUntil(^(DoneCallback done) {
[serviceManager enableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
[MKTVerify(mockPeripheral) setNotifyValue:YES forCharacteristic:mockCharacteristic];
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:nil]);
});
});});

});

context(@"when the notifications could not be enabled", ^{

it(@"calls the block witn an error", ^AsyncBlock{
it(@"calls the block witn an error", ^{ waitUntil(^(DoneCallback done) {
[serviceManager enableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
expect(error).notTo.beNil;
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:error]);
});
});});

it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^AsyncBlock{
it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^{ waitUntil(^(DoneCallback done) {
[serviceManager enableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
[MKTVerify(mockPeripheral) setNotifyValue:YES forCharacteristic:mockCharacteristic];
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:error]);
});
});});

});

Expand Down Expand Up @@ -365,41 +365,41 @@ - (void)updatedValue:(NSData *)data error:(NSError *)error {

context(@"when the notifications are successfully enabled", ^{

it(@"calls the block", ^AsyncBlock{
it(@"calls the block", ^{ waitUntil(^(DoneCallback done) {
[serviceManager disableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
expect(error).to.beNil;
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:nil]);
});
});});

it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^AsyncBlock{
it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^{ waitUntil(^(DoneCallback done) {
[serviceManager disableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
[MKTVerify(mockPeripheral) setNotifyValue:NO forCharacteristic:mockCharacteristic];
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:nil]);
});
});});

});

context(@"when the notifications could not be enabled", ^{

it(@"calls the block witn an error", ^AsyncBlock{
it(@"calls the block witn an error", ^{ waitUntil(^(DoneCallback done) {
[serviceManager disableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
expect(error).notTo.beNil;
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:error]);
});
});});

it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^AsyncBlock{
it(@"calls the peripheral's setNotifyValue:forCharacteristic method", ^{ waitUntil(^(DoneCallback done) {
[serviceManager disableNotificationsForCharacteristic:characteristicUUID usingBlock:^(NSError * error) {
[MKTVerify(mockPeripheral) setNotifyValue:YES forCharacteristic:mockCharacteristic];
done();
}];
ASYNC([serviceManager didUpdateNotificationStateForCharacteristic:mockCharacteristic error:error]);
});
});});

});

Expand Down Expand Up @@ -435,27 +435,27 @@ - (void)updatedValue:(NSData *)data error:(NSError *)error {
[MKTGiven(mockCharacteristic.value) willReturn:data];
});

it(@"calls the block with the updated data", ^AsyncBlock{
it(@"calls the block with the updated data", ^{ waitUntil(^(DoneCallback done) {
[serviceManager addObserverForCharacteristic:characteristicUUID usingBlock:^(NSError * error, NSData * aData) {
expect(error).to.beNil;
expect(aData).to.equal(data);
done();
}];
ASYNC([serviceManager didUpdateValueForCharacteristic:mockCharacteristic error:nil]);
});
});});

});

context(@"when a notification error is received for the observed characteristic", ^{

it(@"calls the block with an error", ^AsyncBlock{
it(@"calls the block with an error", ^{ waitUntil(^(DoneCallback done) {
[serviceManager addObserverForCharacteristic:characteristicUUID usingBlock:^(NSError * error, NSData * aData) {
expect(error).notTo.beNil;
expect(aData).to.beNil;
done();
}];
ASYNC([serviceManager didUpdateValueForCharacteristic:mockCharacteristic error:error]);
});
});});

});

Expand Down
Loading

0 comments on commit f263a51

Please sign in to comment.