I am not able to reproduce this -- is this what you're doing?
@interface Bar : NSObject <CBPeripheralDelegate>
@property (nonatomic, strong) CBPeripheral *peripheral;
- (void)peripheralTest;
@end
- (void)peripheralTest
{
NSAssert(_peripheral.delegate == self, @"Empty device");
}
// In test class:
- (void)testPeripheral
{
Bar *bar = [Bar new];
id peripheralMock = [OCMockObject mockForClass:CBPeripheral.class];
[[[peripheralMock stub] andReturn:bar] delegate];
bar.peripheral = peripheralMock;
[bar peripheralTest];
}
This test passes for me.