Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharedExample with multiple 'it' blocks #712

Closed
iamprabal opened this issue Aug 27, 2018 · 0 comments
Closed

SharedExample with multiple 'it' blocks #712

iamprabal opened this issue Aug 27, 2018 · 0 comments

Comments

@iamprabal
Copy link

iamprabal commented Aug 27, 2018

Hi,
Here's my code:

File 1 : SharedExample code

SHARED_EXAMPLES_BEGIN(GameGeneric)
sharedExamplesFor(@"game", ^(NSDictionary *data) {
__block Game *game;

beforeEach(^{
    game = [data objectForKey:@"gameObj"];
});

it(@"has 0 score", ^{
    [[theValue(game.gameScore.integerValue) should] beZero];
});

it(@"should conform GameUIActionListener", ^{
    [[game should] conformToProtocol:@protocol(GameUIActionListener)];
});

});
SHARED_EXAMPLES_END

File 2 : Spec code

SPEC_BEGIN(QuizGameSpec)
describe(@"QuizGame", ^{
context(@"game init", ^{
__block Game* quizGame;

    beforeEach(^{
        quizGame = [[QuizGame alloc] init];
    });
    
    itBehavesLike(@"game", [NSDictionary dictionaryWithObjectsAndKeys:quizGame, @"gameObj", nil]);
});

});
SPEC_END

My observation: when I have only one 'it' block in the shared example above, it works fine. When I add 2 'it' blocks, the second one is marked failed without executing it (I put breakpoints to conclude this). I want to add a lot of 'it' blocks in my shared example that will validate that the game object (Quiz game or any other game) behaves like a game and then I shall validate the behaviour of specific game types in game-specific spec files. I searched as much as I could but didn't find any "SHARED EXAMPLE" code where there are multiple 'it' blocks inside the same SharedExample. Please forgive me if there is a really trivial and obvious mistake I'm making as I'm really just starting to use Kiwi (and loving it as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant