Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 37 lines (29 sloc) 1.363 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#import "SpecHelper.h"
#import "InjectionErrorFixtures.h"
#import "Fixtures.h"

SPEC_BEGIN(InjectionErrorsSpecs)

beforeEach(^{
      JSObjectionInjector *injector = [JSObjection createInjector];
      [JSObjection setDefaultInjector:injector];
});

it(@"throws an exception if property type is not an object", ^{
      [[theBlock(^{
          [[JSObjection defaultInjector] getObject:[UnsupportedPropertyObject class]];
      }) should] raiseWithReason:@"Unable to determine class type for property declaration: 'myInteger'"];
});

it(@"throws an exception if property cannot be found", ^{
      [[theBlock(^{
          [[JSObjection defaultInjector] getObject:[BadPropertyObject class]];
      }) should] raiseWithReason:@"Unable to find property declaration: 'badProperty' for class 'BadPropertyObject'"];
});

it(@"throws if an object requires a protocol that does not exist in the context", ^{
      [[theBlock(^{
          [[JSObjection defaultInjector] getObject:[FiveSpeedCar class]];
      }) should] raiseWithReason:@"Cannot find an instance that is bound to the protocol 'GearBox' to assign to the property 'gearBox'"];
});

it(@"throws if instantiation rule is not valid", ^{
      [[theBlock(^{
          [JSObjection registerClass:[CarFactory class] scope:3];
      }) should] raiseWithReason:@"Invalid Instantiation Rule"];
});


SPEC_END
Something went wrong with that request. Please try again.