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

[RACStream(Operations) reduceEach:]_block_invoke #86

Closed
wujunyang opened this issue Apr 1, 2017 · 1 comment
Closed

[RACStream(Operations) reduceEach:]_block_invoke #86

wujunyang opened this issue Apr 1, 2017 · 1 comment

Comments

@wujunyang
Copy link

1:testLoginViewModel.m

(RACSignal *)isValidUsernameAndPasswordSignal
{
return [RACSignal combineLatest:@[RACObserve(self, username), RACObserve(self, password)] reduce:^(NSString *username, NSString *password) {
return @([self isValidEmail:username] && [self isValidPassword:password]);
}];
}
//验证

(BOOL)isValidEmail:(NSString )data
{
NSString emailPattern =
@"(?:[a-z0-9!#$%&'+/=?^{|}~-]+(?:\.[a-z0-9!#$%\&'*+/=?\^{|}"
@"~-]+)|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-"
@"x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])")@(?:(?:[a-z0-9](?:[a-"
@"z0-9-][a-z0-9])?.)+a-z0-9?|[(?:(?:25[0-5"
@"]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"
@"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21"
@"-\x5a\x53-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])+)])";
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:emailPattern options:NSRegularExpressionCaseInsensitive error:&error];
NSTextCheckingResult *match = [regex firstMatchInString:data options:0 range:NSMakeRange(0, [data length])];
return match != nil;
}

(BOOL)isValidPassword:(NSString *)password
{
return password.length >= 6;
}

2:I do unit testing on the above file,But it has been reporting the problem above;[RACStream(Operations) reduceEach:]_block_invoke

#import <Kiwi/Kiwi.h>

#import <ReactiveCocoa/ReactiveCocoa.h>
#import "testLoginViewModel.h"

SPEC_BEGIN(testLoginViewModelSpec)

describe(@"testLoginViewModel", ^{
__block testLoginViewModel* viewModel = nil;

beforeEach(^{
viewModel = [testLoginViewModel new];
});

afterEach(^{
viewModel = nil;
});

context(@"when username is wujunyang and password is freedom", ^{
__block BOOL result = NO;

it(@"should return signal that value is YES", ^{
    viewModel.username = @"wuyang@126.com";
    viewModel.password = @"123456";
    
    [[viewModel isValidUsernameAndPasswordSignal] subscribeNext:^(id x) {
        result = [x boolValue];
    }];
    
     [[theValue(result) should] beYes];
});

});
});

SPEC_END

Where is the problem?

@wujunyang
Copy link
Author

I solved

platform :ios, '7.0'

abstract_target 'MobileProjectDefault' do
pod 'AFNetworking', '>2.6.0'
pod 'SDWebImage', '
>3.7'
pod 'JSONModel', '> 1.0.1'
pod 'Masonry','
>0.6.1'
pod 'FMDB/common' , '>2.5'
pod 'FMDB/SQLCipher', '
>2.5'
pod 'CocoaLumberjack', '~> 2.0.0-rc'
pod 'ReactiveCocoa', '2.5'
pod 'CYLTabBarController'
pod 'MLeaksFinder' #可以把它放在MobileProject_Local的target中 这样就不会影响到产品环境
pod 'RealReachability'

target 'MobileProject_Local' do
    
end

target 'MobileProject' do
    
    target 'MobileProjectTests' do
        inherit! :search_paths
        pod 'Kiwi', '~> 2.3.1'
    end
end

end

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