Comments (3)
I'm running into this as well using Xcode 6.0.1 targetting 8.0, trying to verify that a header with a UUID is matched. Could be I'm missing something?
#define EXP_SHORTHAND
#import "Expecta.h"
#import "Specta.h"
#import "Nocilla.h"
SpecBegin(Requests)
describe(@"Nocilla", ^{
__block NSString *fakeURL;
beforeAll(^{
fakeURL = @"http://somefakeplace.com";
[[LSNocilla sharedInstance] start];
});
afterAll(^{
[[LSNocilla sharedInstance] stop];
});
afterEach(^{
[[LSNocilla sharedInstance] clearStubs];
});
it(@"control to verify regex is valid", ^{
NSRegularExpression *headerRegex = [NSRegularExpression regularExpressionWithPattern:@"[\\w]{8}(-[\\w]{4}){3}-[\\w]{12}" options:0 error:nil];
NSString *uuid = [[NSUUID UUID] UUIDString];
NSArray *matches = [headerRegex matchesInString:uuid options:0 range:NSMakeRange(0, [uuid length])];
expect([matches count]).to.beGreaterThan(0);
});
it(@"should match a stub that has a UUID in a header", ^AsyncBlock {
NSRegularExpression *headerRegex = [NSRegularExpression regularExpressionWithPattern:@"[\\w]{8}(-[\\w]{4}){3}-[\\w]{12}" options:0 error:nil];
stubRequest(@"GET", fakeURL)
.withHeaders(@{@"Accept": @"application/json", @"TraceContext":headerRegex})
.andReturn(200).withBody(@"{\"ok\":true}");
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:fakeURL]];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:[[NSUUID UUID] UUIDString] forHTTPHeaderField:@"TraceContext"];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
expect(data).to.equal(@"{\"ok\":true}".data);
done();
}];
});
});
SpecEnd
from nocilla.
@jjohnson4014 This is because you can't put regular expressions in the header matching - you can only use regular expressions to match the URL.
from nocilla.
OK further update on this it seems to happen with the iOS7 introduced NSURLSession dataTaskWithURL but not with the old school NSURLConnection requests.
from nocilla.
Related Issues (20)
- Not able to stub cookies for normal (non-directed requests) HOT 1
- Body matcher fails to match arbitrary NSData
- Support for RestKit HOT 1
- Add 0.10.0 to CocoaPods.org HOT 1
- Synchronous Request Support
- Wait for async request to complete before stop() HOT 1
- Crash in LSHTTPStubURLProtocol - EXC_BAD_ACCESS - Specific way to stub redirects? HOT 1
- Ability to Delay a Response HOT 1
- Redirect Implementation is Inconsistent With OS Behavior
- Carthage Binaries HOT 1
- ASIHTTPRequest synchronous request with stub never ends HOT 1
- LSNocilla.sharedInstance().stop() Not working HOT 5
- Project no longer maintained? HOT 3
- Nocilla never returns the stub HOT 2
- App store rejection due to private api references HOT 3
- Use this snippet to stub the request HOT 1
- Push v0.11.0 podspec to Cocoapods HOT 2
- Swift 3 Support HOT 2
- How do I Nocilla in Swift 3? HOT 2
- SPM Support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nocilla.