0

I am trying JASidePanels with Kiwi, and got following error:

failed: 'Root side panel controller, wants to show left panel, shows left panel' [FAILED], expected subject to equal 2, got 1

I think I must made some obvious mistake but could not figure out where. Could any one give me some hints? Thanks in advance.

#import "Kiwi.h"
#import "JASidePanelController.h"
#import "UIViewController+JASidePanel.h"

SPEC_BEGIN(MSISidePanelControllerSpec)

describe(@"Root side panel controller", ^{

    __block JASidePanelController *sidePanelController;

    beforeEach(^{
        sidePanelController = [[JASidePanelController alloc] init];
    });

    context(@"wants to show left panel", ^{

        beforeEach(^{
            [sidePanelController showLeftPanelAnimated:YES];
        });

        it(@"shows left panel", ^{
            [[theValue(sidePanelController.state) should] equal:theValue(JASidePanelLeftVisible)];
        });
    });
});

SPEC_END
ThinkChris
  • 1,169
  • 2
  • 15
  • 38

1 Answers1

2

The problem is that your setup code (initializing sidePanelController and sending showLeftPanelAnimated:) are not inside blocks as part of beforeEach or similar functions. See this answer to a similar Kiwi question for details.

Community
  • 1
  • 1
Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75
  • Thanks @esker, could you have a look at the updated code? Getting the same error. – ThinkChris Jul 02 '13 at 01:49
  • Updated code looks good, that's the correct way to use Kiwi now. The problem might have to do with showing the left panel with animated = YES. Perhaps when animated = YES, `sitePanelController.state` is not immediately set to `JASidePanelLeftVisible`, but only does so asynchronously after animation completes? You could try two things: try `showLeftPanelAnimated:NO` but leave the expectation in the `it` block the same. Or, leave animated = YES and change the expectation to `[[expectFutureValue(theValue(sidePanelController.state)) shouldEventually] equal:...]`. – Mike Mertsock Jul 02 '13 at 02:53