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

Stubbing a class method with a BOOL return value on a class mock results in error #606

Open
jbelkins opened this issue Apr 8, 2015 · 3 comments

Comments

@jbelkins
Copy link

jbelkins commented Apr 8, 2015

When stubbing a class method that returns boolean on a class mock, an error occurs when trying to set the return value.

ExampleClass has a method with the following signature:

+ (BOOL)booleanClassMethod;

Here is the spec:

context(@"stubbing methods on class mocks", ^{

    let(classMockForSubjectClass, ^Class{
        return [KWMock mockForClass:[ExampleClass class]];
    });

    describe(@"stubbing a class method that returns boolean", ^{

        it(@"should return YES when stubbed", ^{
            [classMockForSubjectClass stub:@selector(booleanClassMethod) andReturn:theValue(YES)];
            BOOL result = [classMockForSubjectClass booleanClassMethod];
            [[theValue(result) should] beYes];
        });
    });
});

From the console:

Assertions:  'mocking a class method that returns boolean, should return YES when stubbed' [FAILED], 
KWStubException "wrapped stub value type (B) could not be converted to the target type (@)" raised

Here is a simple iOS project that demonstrates this error:
https://github.com/jbelkins/KiwiBugExamples

Please let me know if I am not setting up this test properly or if you cannot reproduce. If someone can confirm this is a Kiwi bug and not operator error, I will spend some time trying to fix it.

@silvaric
Copy link

I have the same problem.
How I can make it right? did you know?

@AwayQu
Copy link

AwayQu commented Oct 11, 2017

It seems not support for scale value, i find the source is implements with method signature invoke, but not find the implement of match method signature return value with obj like this @(YES).

@isimple4
Copy link

I changed theValue(YES) to theValue(1) in stub return, which works fine now in ver 3.0.

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

4 participants