diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Nocilla.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Nocilla.xcscheme new file mode 100644 index 00000000..1237baad --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/Nocilla.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Nocilla.podspec b/Nocilla.podspec deleted file mode 100644 index eaeb4010..00000000 --- a/Nocilla.podspec +++ /dev/null @@ -1,35 +0,0 @@ -Pod::Spec.new do |s| - s.name = "Nocilla" - s.version = "0.11.0" - s.summary = "Stunning HTTP stubbing for iOS. Testing HTTP requests has never been easier." - s.homepage = "https://github.com/luisobo/Nocilla" - - s.license = { :type => 'MIT', :file => 'LICENSE' } - s.author = { "Luis Solano" => "contact@luissolano.com" } - - s.source = { :git => "https://github.com/luisobo/Nocilla.git", :tag => "0.11.0" } - - s.ios.deployment_target = '5.0' - s.osx.deployment_target = '10.7' - s.tvos.deployment_target = '9.0' - - s.source_files = 'Nocilla/**/*.{h,m}' - - s.public_header_files = [ - 'Nocilla/Categories/NSData+Nocilla.h', - 'Nocilla/Categories/NSString+Nocilla.h', - 'Nocilla/DSL/LSStubRequestDSL.h', - 'Nocilla/DSL/LSStubResponseDSL.h', - 'Nocilla/LSNocilla.h', - 'Nocilla/Matchers/LSMatcheable.h', - 'Nocilla/Matchers/LSMatcher.h', - 'Nocilla/Matchers/NSData+Matcheable.h', - 'Nocilla/Matchers/NSRegularExpression+Matcheable.h', - 'Nocilla/Matchers/NSString+Matcheable.h', - 'Nocilla/Model/LSHTTPBody.h', - 'Nocilla/Nocilla.h' - ] - - s.requires_arc = true - s.frameworks = 'CFNetwork' -end diff --git a/Nocilla/Hooks/NSURLSession/LSNSURLSessionHook.h b/Nocilla/Hooks/NSURLSession/LSNSURLSessionHook.h index aa6ec8c4..476c824d 100644 --- a/Nocilla/Hooks/NSURLSession/LSNSURLSessionHook.h +++ b/Nocilla/Hooks/NSURLSession/LSNSURLSessionHook.h @@ -6,8 +6,6 @@ // Copyright (c) 2014 Luis Solano Bonet. All rights reserved. // -#import - #import "LSHTTPClientHook.h" @interface LSNSURLSessionHook : LSHTTPClientHook diff --git a/Nocilla/Nocilla.h b/Nocilla/Nocilla.h index d9cb1abd..7c67d53b 100644 --- a/Nocilla/Nocilla.h +++ b/Nocilla/Nocilla.h @@ -14,14 +14,14 @@ FOUNDATION_EXPORT double NocillaVersionNumber; //! Project version string for Nocilla. FOUNDATION_EXPORT const unsigned char NocillaVersionString[]; -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import +#import "LSHTTPBody.h" +#import "LSNocilla.h" +#import "LSMatcheable.h" +#import "LSMatcher.h" +#import "NSString+Matcheable.h" +#import "NSData+Matcheable.h" +#import "NSRegularExpression+Matcheable.h" +#import "LSStubRequestDSL.h" +#import "LSStubResponseDSL.h" +#import "NSData+Nocilla.h" +#import "NSString+Nocilla.h" diff --git a/Nocilla/public/LSASIHTTPRequestHook.h b/Nocilla/public/LSASIHTTPRequestHook.h new file mode 120000 index 00000000..92a094c0 --- /dev/null +++ b/Nocilla/public/LSASIHTTPRequestHook.h @@ -0,0 +1 @@ +../Hooks/ASIHTTPRequest/LSASIHTTPRequestHook.h \ No newline at end of file diff --git a/Nocilla/public/LSHTTPBody.h b/Nocilla/public/LSHTTPBody.h new file mode 120000 index 00000000..8b799ecd --- /dev/null +++ b/Nocilla/public/LSHTTPBody.h @@ -0,0 +1 @@ +../Model/LSHTTPBody.h \ No newline at end of file diff --git a/Nocilla/public/LSHTTPClientHook.h b/Nocilla/public/LSHTTPClientHook.h new file mode 120000 index 00000000..c563684b --- /dev/null +++ b/Nocilla/public/LSHTTPClientHook.h @@ -0,0 +1 @@ +../Hooks/LSHTTPClientHook.h \ No newline at end of file diff --git a/Nocilla/public/LSHTTPRequest.h b/Nocilla/public/LSHTTPRequest.h new file mode 120000 index 00000000..818bb6f5 --- /dev/null +++ b/Nocilla/public/LSHTTPRequest.h @@ -0,0 +1 @@ +../Model/LSHTTPRequest.h \ No newline at end of file diff --git a/Nocilla/public/LSHTTPRequestDSLRepresentation.h b/Nocilla/public/LSHTTPRequestDSLRepresentation.h new file mode 120000 index 00000000..fa777b6f --- /dev/null +++ b/Nocilla/public/LSHTTPRequestDSLRepresentation.h @@ -0,0 +1 @@ +../DSL/LSHTTPRequestDSLRepresentation.h \ No newline at end of file diff --git a/Nocilla/public/LSHTTPResponse.h b/Nocilla/public/LSHTTPResponse.h new file mode 120000 index 00000000..f389b2d1 --- /dev/null +++ b/Nocilla/public/LSHTTPResponse.h @@ -0,0 +1 @@ +../Model/LSHTTPResponse.h \ No newline at end of file diff --git a/Nocilla/public/LSHTTPStubURLProtocol.h b/Nocilla/public/LSHTTPStubURLProtocol.h new file mode 120000 index 00000000..99923a00 --- /dev/null +++ b/Nocilla/public/LSHTTPStubURLProtocol.h @@ -0,0 +1 @@ +../Hooks/NSURLRequest/LSHTTPStubURLProtocol.h \ No newline at end of file diff --git a/Nocilla/public/LSMatcheable.h b/Nocilla/public/LSMatcheable.h new file mode 120000 index 00000000..7f28a049 --- /dev/null +++ b/Nocilla/public/LSMatcheable.h @@ -0,0 +1 @@ +../Matchers/LSMatcheable.h \ No newline at end of file diff --git a/Nocilla/public/LSMatcher.h b/Nocilla/public/LSMatcher.h new file mode 120000 index 00000000..67af1761 --- /dev/null +++ b/Nocilla/public/LSMatcher.h @@ -0,0 +1 @@ +../Matchers/LSMatcher.h \ No newline at end of file diff --git a/Nocilla/public/LSNSURLHook.h b/Nocilla/public/LSNSURLHook.h new file mode 120000 index 00000000..b5b4c223 --- /dev/null +++ b/Nocilla/public/LSNSURLHook.h @@ -0,0 +1 @@ +../Hooks/NSURLRequest/LSNSURLHook.h \ No newline at end of file diff --git a/Nocilla/public/LSNSURLSessionHook.h b/Nocilla/public/LSNSURLSessionHook.h new file mode 120000 index 00000000..d4a80409 --- /dev/null +++ b/Nocilla/public/LSNSURLSessionHook.h @@ -0,0 +1 @@ +../Hooks/NSURLSession/LSNSURLSessionHook.h \ No newline at end of file diff --git a/Nocilla/public/LSNocilla.h b/Nocilla/public/LSNocilla.h new file mode 120000 index 00000000..5a8261dd --- /dev/null +++ b/Nocilla/public/LSNocilla.h @@ -0,0 +1 @@ +../LSNocilla.h \ No newline at end of file diff --git a/Nocilla/public/LSStubRequest.h b/Nocilla/public/LSStubRequest.h new file mode 120000 index 00000000..286e0537 --- /dev/null +++ b/Nocilla/public/LSStubRequest.h @@ -0,0 +1 @@ +../Stubs/LSStubRequest.h \ No newline at end of file diff --git a/Nocilla/public/LSStubRequestDSL.h b/Nocilla/public/LSStubRequestDSL.h new file mode 120000 index 00000000..5038851e --- /dev/null +++ b/Nocilla/public/LSStubRequestDSL.h @@ -0,0 +1 @@ +../DSL/LSStubRequestDSL.h \ No newline at end of file diff --git a/Nocilla/public/LSStubResponse.h b/Nocilla/public/LSStubResponse.h new file mode 120000 index 00000000..e7ab1f36 --- /dev/null +++ b/Nocilla/public/LSStubResponse.h @@ -0,0 +1 @@ +../Stubs/LSStubResponse.h \ No newline at end of file diff --git a/Nocilla/public/LSStubResponseDSL.h b/Nocilla/public/LSStubResponseDSL.h new file mode 120000 index 00000000..69fe92c3 --- /dev/null +++ b/Nocilla/public/LSStubResponseDSL.h @@ -0,0 +1 @@ +../DSL/LSStubResponseDSL.h \ No newline at end of file diff --git a/Nocilla/public/NSData+Matcheable.h b/Nocilla/public/NSData+Matcheable.h new file mode 120000 index 00000000..8dba4821 --- /dev/null +++ b/Nocilla/public/NSData+Matcheable.h @@ -0,0 +1 @@ +../Matchers/NSData+Matcheable.h \ No newline at end of file diff --git a/Nocilla/public/NSData+Nocilla.h b/Nocilla/public/NSData+Nocilla.h new file mode 120000 index 00000000..9cd7be03 --- /dev/null +++ b/Nocilla/public/NSData+Nocilla.h @@ -0,0 +1 @@ +../Categories/NSData+Nocilla.h \ No newline at end of file diff --git a/Nocilla/public/NSRegularExpression+Matcheable.h b/Nocilla/public/NSRegularExpression+Matcheable.h new file mode 120000 index 00000000..2513f242 --- /dev/null +++ b/Nocilla/public/NSRegularExpression+Matcheable.h @@ -0,0 +1 @@ +../Matchers/NSRegularExpression+Matcheable.h \ No newline at end of file diff --git a/Nocilla/public/NSString+Matcheable.h b/Nocilla/public/NSString+Matcheable.h new file mode 120000 index 00000000..16e5178b --- /dev/null +++ b/Nocilla/public/NSString+Matcheable.h @@ -0,0 +1 @@ +../Matchers/NSString+Matcheable.h \ No newline at end of file diff --git a/Nocilla/public/NSString+Nocilla.h b/Nocilla/public/NSString+Nocilla.h new file mode 120000 index 00000000..953ace19 --- /dev/null +++ b/Nocilla/public/NSString+Nocilla.h @@ -0,0 +1 @@ +../Categories/NSString+Nocilla.h \ No newline at end of file diff --git a/Nocilla/public/Nocilla.h b/Nocilla/public/Nocilla.h new file mode 120000 index 00000000..240cf850 --- /dev/null +++ b/Nocilla/public/Nocilla.h @@ -0,0 +1 @@ +../Nocilla.h \ No newline at end of file diff --git a/NocillaTests/DSL/LSHTTPRequestDSLRepresentationSpec.m b/NocillaTests/DSL/LSHTTPRequestDSLRepresentationSpec.m deleted file mode 100644 index 87914528..00000000 --- a/NocillaTests/DSL/LSHTTPRequestDSLRepresentationSpec.m +++ /dev/null @@ -1,88 +0,0 @@ -#import "Kiwi.h" -#import "LSTestRequest.h" -#import "LSHTTPRequestDSLRepresentation.h" - -SPEC_BEGIN(LSHTTPRequestDSLRepresentationSpec) -describe(@"description", ^{ - __block LSHTTPRequestDSLRepresentation *dsl = nil; - describe(@"a request with a GET method and url", ^{ - beforeEach(^{ - LSTestRequest *request = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - dsl = [[LSHTTPRequestDSLRepresentation alloc] initWithRequest:request]; - }); - it(@"should return the DSL representation", ^{ - [[[dsl description] should] equal:@"stubRequest(@\"GET\", @\"http://www.google.com\");"]; - }); - }); - describe(@"a request with a POST method and a url", ^{ - beforeEach(^{ - LSTestRequest *request = [[LSTestRequest alloc] initWithMethod:@"POST" url:@"http://luissolano.com"]; - dsl = [[LSHTTPRequestDSLRepresentation alloc] initWithRequest:request]; - - }); - it(@"should return the DSL representation", ^{ - [[[dsl description] should] equal:@"stubRequest(@\"POST\", @\"http://luissolano.com\");"]; - }); - }); - describe(@"a request with one header", ^{ - beforeEach(^{ - LSTestRequest *request = [[LSTestRequest alloc] initWithMethod:@"POST" url:@"http://luissolano.com"]; - [request setHeader:@"Accept" value:@"text/plain"]; - dsl = [[LSHTTPRequestDSLRepresentation alloc] initWithRequest:request]; - }); - it(@"should return the DSL representation", ^{ - [[[dsl description] should] equal:@"stubRequest(@\"POST\", @\"http://luissolano.com\").\nwithHeaders(@{ @\"Accept\": @\"text/plain\" });"]; - }); - }); - describe(@"a request with 3 headers", ^{ - beforeEach(^{ - LSTestRequest *request = [[LSTestRequest alloc] initWithMethod:@"POST" url:@"http://luissolano.com"]; - [request setHeader:@"Accept" value:@"text/plain"]; - [request setHeader:@"Content-Length" value:@"18"]; - [request setHeader:@"If-Match" value:@"a8fhw0dhasd03qn02"]; - dsl = [[LSHTTPRequestDSLRepresentation alloc] initWithRequest:request]; - - }); - it(@"should return the DSL representation", ^{ - NSString *expected = @"stubRequest(@\"POST\", @\"http://luissolano.com\").\nwithHeaders(@{ @\"Accept\": @\"text/plain\", @\"Content-Length\": @\"18\", @\"If-Match\": @\"a8fhw0dhasd03qn02\" });"; - [[[dsl description] should] equal:expected]; - }); - }); - describe(@"when a header contains a double quoute", ^{ - beforeEach(^{ - LSTestRequest *request = [[LSTestRequest alloc] initWithMethod:@"POST" url:@"http://luissolano.com"]; - [request setHeader:@"X-MY-HEADER" value:@"quote\"quoute"]; - dsl = [[LSHTTPRequestDSLRepresentation alloc] initWithRequest:request]; - }); - it(@"should escape the result", ^{ - [[[dsl description] should] equal:@"stubRequest(@\"POST\", @\"http://luissolano.com\").\nwithHeaders(@{ @\"X-MY-HEADER\": @\"quote\"quoute\" });"]; - }); - }); - describe(@"a request with headers and body", ^{ - beforeEach(^{ - LSTestRequest *request = [[LSTestRequest alloc] initWithMethod:@"POST" url:@"http://luissolano.com"]; - [request setHeader:@"Accept" value:@"text/plain"]; - [request setHeader:@"Content-Length" value:@"18"]; - [request setHeader:@"If-Match" value:@"a8fhw0dhasd03qn02"]; - [request setBody:[@"The body of a request, yeah!" dataUsingEncoding:NSUTF8StringEncoding]]; - dsl = [[LSHTTPRequestDSLRepresentation alloc] initWithRequest:request]; - - }); - it(@"should return the DSL representation", ^{ - NSString *expected = @"stubRequest(@\"POST\", @\"http://luissolano.com\").\nwithHeaders(@{ @\"Accept\": @\"text/plain\", @\"Content-Length\": @\"18\", @\"If-Match\": @\"a8fhw0dhasd03qn02\" }).\nwithBody(@\"The body of a request, yeah!\");"; - [[[dsl description] should] equal:expected]; - }); - }); - context(@"when the body contain double quotes", ^{ - beforeEach(^{ - LSTestRequest *request = [[LSTestRequest alloc] initWithMethod:@"POST" url:@"http://luissolano.com"]; - [request setBody:[@"{\"text\":\"adios\"}" dataUsingEncoding:NSUTF8StringEncoding]]; - dsl = [[LSHTTPRequestDSLRepresentation alloc] initWithRequest:request]; - }); - it(@"should return the DSL representation", ^{ - NSString *expected = @"stubRequest(@\"POST\", @\"http://luissolano.com\").\nwithBody(@\"{\\\"text\\\":\\\"adios\\\"}\");"; - [[[dsl description] should] equal:expected]; - }); - }); -}); -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Diff/LSHTTPRequestDiffSpec.m b/NocillaTests/Diff/LSHTTPRequestDiffSpec.m deleted file mode 100644 index 58a06823..00000000 --- a/NocillaTests/Diff/LSHTTPRequestDiffSpec.m +++ /dev/null @@ -1,268 +0,0 @@ -#import "Kiwi.h" -#import "LSHTTPRequest.h" -#import "LSHTTPRequestDiff.h" -#import "LSTestRequest.h" - -SPEC_BEGIN(LSHTTPRequestDiffSpec) -describe(@"diffing two LSHTTPRequests", ^{ - __block LSTestRequest *oneRequest = nil; - __block LSTestRequest *anotherRequest = nil; - __block LSHTTPRequestDiff *diff = nil; - context(@"when both represent the same request", ^{ - beforeEach(^{ - NSString *urlString = @"http://www.google.com"; - oneRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:urlString]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:urlString]; - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - - it(@"should result in an empty diff", ^{ - [[theValue(diff.isEmpty) should] beYes]; - }); - it(@"should an empty description", ^{ - [[[diff description] should] equal:@""]; - }); - }); - context(@"when the request differ in the method", ^{ - beforeEach(^{ - NSString *urlString = @"http://www.google.com"; - oneRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:urlString]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"POST" url:urlString]; - }); - it(@"should not be empty", ^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - [[theValue(diff.isEmpty) should] beNo]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: GET\n+ Method: POST\n"; - [[[diff description] should] equal:expected]; - }); - - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: POST\n+ Method: GET\n"; - [[[diff description] should] equal:expected]; - }); - - }); - }); - - context(@"when the requests differ in the URL", ^{ - beforeEach(^{ - oneRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.luissolano.com"]; - }); - it(@"should not be empty", ^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - [[theValue(diff.isEmpty) should] beNo]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- URL: http://www.google.com\n+ URL: http://www.luissolano.com\n"; - [[[diff description] should] equal:expected]; - }); - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- URL: http://www.luissolano.com\n+ URL: http://www.google.com\n"; - [[[diff description] should] equal:expected]; - }); - }); - }); - context(@"when the request differ in one header", ^{ - beforeEach(^{ - oneRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - [oneRequest setHeader:@"Content-Type" value:@"application/json"]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - }); - it(@"should not be empty", ^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - [[theValue(diff.isEmpty) should] beNo]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @" Headers:\n-\t\"Content-Type\": \"application/json\"\n"; - [[[diff description] should] equal:expected]; - }); - - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @" Headers:\n+\t\"Content-Type\": \"application/json\"\n"; - [[[diff description] should] equal:expected]; - }); - - }); - - }); - - context(@"when the request differ in one header each", ^{ - beforeEach(^{ - oneRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - [oneRequest setHeader:@"Content-Type" value:@"application/json"]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - [anotherRequest setHeader:@"Accept" value:@"text/plain"]; - }); - it(@"should not be empty", ^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - [[theValue(diff.isEmpty) should] beNo]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @" Headers:\n-\t\"Content-Type\": \"application/json\"\n+\t\"Accept\": \"text/plain\"\n"; - [[[diff description] should] equal:expected]; - }); - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @" Headers:\n-\t\"Accept\": \"text/plain\"\n+\t\"Content-Type\": \"application/json\"\n"; - [[[diff description] should] equal:expected]; - }); - - }); - }); - context(@"when the requests differ in the body", ^{ - beforeEach(^{ - oneRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - oneRequest.body = [@"this is a body" dataUsingEncoding:NSUTF8StringEncoding]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - }); - it(@"should not be empty", ^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - [[theValue(diff.isEmpty) should] beNo]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Body: \"this is a body\"\n"; - [[[diff description] should] equal:expected]; - }); - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"+ Body: \"this is a body\"\n"; - - [[[diff description] should] equal:expected]; - }); - - }); - }); - context(@"when the requests differ in the Method and the URL", ^{ - beforeEach(^{ - oneRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"http://www.luissolano.com"]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: GET\n+ Method: PUT\n- URL: http://www.google.com\n+ URL: http://www.luissolano.com\n"; - [[[diff description] should] equal:expected]; - }); - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: PUT\n+ Method: GET\n- URL: http://www.luissolano.com\n+ URL: http://www.google.com\n"; - [[[diff description] should] equal:expected]; - }); - - }); - }); - context(@"when the request differ in the Method, URL and headers", ^{ - beforeEach(^{ - oneRequest = [[LSTestRequest alloc] initWithMethod:@"POST" url:@"http://www.google.es"]; - [oneRequest setHeader:@"X-API-TOKEN" value:@"123456789"]; - [oneRequest setHeader:@"Accept" value:@"application/json"]; - [oneRequest setHeader:@"X-Custom-Header" value:@"Really??"]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"DELETE" url:@"http://www.luissolano.com/ispellchecker/"]; - [anotherRequest setHeader:@"Accept" value:@"application/json"]; - [anotherRequest setHeader:@"X-API-TOKEN" value:@"abcedfghi"]; - [anotherRequest setHeader:@"X-APP-ID" value:@"Nocilla"]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: POST\n+ Method: DELETE\n- URL: http://www.google.es\n+ URL: http://www.luissolano.com/ispellchecker/\n Headers:\n-\t\"X-API-TOKEN\": \"123456789\"\n-\t\"X-Custom-Header\": \"Really??\"\n+\t\"X-API-TOKEN\": \"abcedfghi\"\n+\t\"X-APP-ID\": \"Nocilla\"\n"; - [[[diff description] should] equal:expected]; - }); - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: DELETE\n+ Method: POST\n- URL: http://www.luissolano.com/ispellchecker/\n+ URL: http://www.google.es\n Headers:\n-\t\"X-API-TOKEN\": \"abcedfghi\"\n-\t\"X-APP-ID\": \"Nocilla\"\n+\t\"X-API-TOKEN\": \"123456789\"\n+\t\"X-Custom-Header\": \"Really??\"\n"; - [[[diff description] should] equal:expected]; - }); - }); - }); - context(@"when the requests differ in everything", ^{ - beforeEach(^{ - oneRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://www.google.it"]; - [oneRequest setHeader:@"X-API-TOKEN" value:@"123456789"]; - [oneRequest setHeader:@"Accept" value:@"application/json"]; - [oneRequest setHeader:@"X-Custom-Header" value:@"Really??"]; - [oneRequest setBody:[@"This is a body" dataUsingEncoding:NSUTF8StringEncoding]]; - anotherRequest = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"http://www.luissolano.com"]; - [anotherRequest setHeader:@"X-API-TOKEN" value:@"123456789"]; - [anotherRequest setHeader:@"X-APP-ID" value:@"Nocilla"]; - [anotherRequest setBody:[@"This is THE body" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - context(@"in one direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:oneRequest andRequest:anotherRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: PUT\n+ Method: GET\n- URL: https://www.google.it\n+ URL: http://www.luissolano.com\n Headers:\n-\t\"Accept\": \"application/json\"\n-\t\"X-Custom-Header\": \"Really??\"\n+\t\"X-APP-ID\": \"Nocilla\"\n- Body: \"This is a body\"\n+ Body: \"This is THE body\"\n"; - [[[diff description] should] equal:expected]; - }); - }); - context(@"in the other direction", ^{ - beforeEach(^{ - diff = [[LSHTTPRequestDiff alloc] initWithRequest:anotherRequest andRequest:oneRequest]; - }); - it(@"should have a description representing the diff", ^{ - NSString *expected = @"- Method: GET\n+ Method: PUT\n- URL: http://www.luissolano.com\n+ URL: https://www.google.it\n Headers:\n-\t\"X-APP-ID\": \"Nocilla\"\n+\t\"Accept\": \"application/json\"\n+\t\"X-Custom-Header\": \"Really??\"\n- Body: \"This is THE body\"\n+ Body: \"This is a body\"\n"; - [[[diff description] should] equal:expected]; - }); - }); - }); -}); -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Hooks/ASIHTTPRequest/ASIHTTPRequestStubbingSpec.m b/NocillaTests/Hooks/ASIHTTPRequest/ASIHTTPRequestStubbingSpec.m deleted file mode 100644 index 04b275bf..00000000 --- a/NocillaTests/Hooks/ASIHTTPRequest/ASIHTTPRequestStubbingSpec.m +++ /dev/null @@ -1,128 +0,0 @@ -#import "Kiwi.h" -#import "Nocilla.h" -#import "ASIHTTPRequest.h" -#import "ASIFormDataRequest.h" -#import "LSASIHTTPRequestHook.h" - -SPEC_BEGIN(ASIHTTPRequestStubbingSpec) - -beforeEach(^{ - [[LSNocilla sharedInstance] start]; -}); - -afterEach(^{ - [[LSNocilla sharedInstance] stop]; - [[LSNocilla sharedInstance] clearStubs]; -}); - -it(@"stubs a GET request", ^{ - stubRequest(@"GET", @"http://httpstat.us/400"). - andReturn(201). - withHeaders(@{@"Header 1":@"Foo", @"Header 2":@"Bar"}). - withBody(@"Holaa!"); - - ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://httpstat.us/400"]]; - - [request startAsynchronous]; - - [request waitUntilFinished]; - - [[expectFutureValue(theValue(request.responseStatusCode)) shouldEventually] equal:theValue(201)]; - [[request.responseString should] equal:@"Holaa!"]; - [[request.responseData should] equal:[@"Holaa!" dataUsingEncoding:NSUTF8StringEncoding]]; - [[request.responseHeaders should] equal:@{@"Header 1":@"Foo", @"Header 2":@"Bar"}]; - [[theValue(request.isFinished) should] beYes]; - -}); - -it(@"stubs a POST request", ^{ - stubRequest(@"POST", @"http://api.example.com/v1/dogs.json"). - withHeaders(@{@"Authorization":@"Bearer 123123123"}). - withBody(@"{\"dog\":\"pepu\"}"). - andReturn(201). - withHeaders(@{@"Header 1":@"Foo", @"Header 2":@"Bar"}). - withBody(@"Holaa!"); - - ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://api.example.com/v1/dogs.json"]]; - request.requestMethod = @"POST"; - [request addRequestHeader:@"Authorization" value:@"Bearer 123123123"]; - [request appendPostData:[@"{\"dog\":\"pepu\"}" dataUsingEncoding:NSUTF8StringEncoding]]; - - [request startAsynchronous]; - - [request waitUntilFinished]; - - [[expectFutureValue(theValue(request.responseStatusCode)) shouldEventually] equal:theValue(201)]; - [[request.responseString should] equal:@"Holaa!"]; - [[request.responseData should] equal:[@"Holaa!" dataUsingEncoding:NSUTF8StringEncoding]]; - [[request.responseHeaders should] equal:@{@"Header 1":@"Foo", @"Header 2":@"Bar"}]; - [[theValue(request.isFinished) should] beYes]; -}); - -it(@"fails a request", ^{ - NSError *error = [NSError nullMock]; - stubRequest(@"POST", @"http://api.example.com/v1/cats"). - withHeaders(@{@"Authorization":@"Basic 667788"}). - withBody(@"name=calcetines&color=black"). - andFailWithError(error); - - ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://api.example.com/v1/cats"]]; - [request setRequestMethod:@"POST"]; - [request addRequestHeader:@"Authorization" value:@"Basic 667788"]; - [request addPostValue:@"calcetines" forKey:@"name"]; - [request addPostValue:@"black" forKey:@"color"]; - - [request startAsynchronous]; - - [request waitUntilFinished]; - - [[expectFutureValue(request.error) shouldEventually] beIdenticalTo:error]; - [[theValue(request.isFinished) should] beYes]; -}); - -it(@"stubs an HTTPS request", ^{ - stubRequest(@"GET", @"https://example.com/things"). - andReturn(201). - withHeaders(@{@"Header 1":@"Foo", @"Header 2":@"Bar"}). - withBody(@"Holaa!"); - - ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"https://example.com/things"]]; - - [request startAsynchronous]; - - [request waitUntilFinished]; - - [[expectFutureValue(theValue(request.responseStatusCode)) shouldEventually] equal:theValue(201)]; - [[request.responseString should] equal:@"Holaa!"]; - [[request.responseData should] equal:[@"Holaa!" dataUsingEncoding:NSUTF8StringEncoding]]; - [[request.responseHeaders should] equal:@{@"Header 1":@"Foo", @"Header 2":@"Bar"}]; - [[theValue(request.isFinished) should] beYes]; -}); - -it(@"stubs a ASIFormDataRequest", ^{ - stubRequest(@"POST", @"http://api.example.com/v1/cats"). - withHeaders(@{@"Authorization":@"Basic 667788"}). - withBody(@"name=calcetines&color=black"). - andReturn(201). - withHeaders(@{@"Header 1":@"Foo", @"Header 2":@"Bar"}). - withBody(@"Holaa!"); - - ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://api.example.com/v1/cats"]]; - [request setRequestMethod:@"POST"]; - [request addRequestHeader:@"Authorization" value:@"Basic 667788"]; - [request addPostValue:@"calcetines" forKey:@"name"]; - [request addPostValue:@"black" forKey:@"color"]; - - - [request startAsynchronous]; - - [request waitUntilFinished]; - - [[expectFutureValue(theValue(request.responseStatusCode)) shouldEventually] equal:theValue(201)]; - [[request.responseString should] equal:@"Holaa!"]; - [[request.responseData should] equal:[@"Holaa!" dataUsingEncoding:NSUTF8StringEncoding]]; - [[request.responseHeaders should] equal:@{@"Header 1":@"Foo", @"Header 2":@"Bar"}]; - [[theValue(request.isFinished) should] beYes]; -}); - -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Hooks/ASIHTTPRequest/LSASIHTTPRequestHookSpec.m b/NocillaTests/Hooks/ASIHTTPRequest/LSASIHTTPRequestHookSpec.m deleted file mode 100644 index e69de29b..00000000 diff --git a/NocillaTests/Hooks/NSURLRequest/AFNetworkingStubbingSpec.m b/NocillaTests/Hooks/NSURLRequest/AFNetworkingStubbingSpec.m deleted file mode 100644 index 681d3110..00000000 --- a/NocillaTests/Hooks/NSURLRequest/AFNetworkingStubbingSpec.m +++ /dev/null @@ -1,335 +0,0 @@ -#import "Kiwi.h" -#import "AFNetworking.h" -#import "Nocilla.h" -#import "HTTPServer.h" -#import "LSTestingConnection.h" - -SPEC_BEGIN(AFNetworkingStubbingSpec) - -beforeEach(^{ - [[LSNocilla sharedInstance] start]; -}); -afterEach(^{ - [[LSNocilla sharedInstance] stop]; - [[LSNocilla sharedInstance] clearStubs]; -}); - -context(@"AFNetworking", ^{ - it(@"should stub the request", ^{ - stubRequest(@"POST", @"https://example.com/say-hello"). - withHeader(@"Content-Type", @"text/plain"). - withHeader(@"X-MY-AWESOME-HEADER", @"sisisi"). - withBody(@"Adios!"). - andReturn(200). - withHeader(@"Content-Type", @"text/plain"). - withBody(@"hola"); - - NSURL *url = [NSURL URLWithString:@"https://example.com/say-hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request setHTTPMethod:@"POST"]; - [request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"]; - [request setHTTPBody:[@"Adios!" dataUsingEncoding:NSASCIIStringEncoding]]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation start]; - - [operation waitUntilFinished]; - - [operation.error shouldBeNil]; - [[operation.responseString should] equal:@"hola"]; - [[theValue(operation.response.statusCode) should] equal:theValue(200)]; - [[[operation.response.allHeaderFields objectForKey:@"Content-Type"] should] equal:@"text/plain"]; - }); - - it(@"should stub the request with a raw reponse", ^{ - stubRequest(@"POST", @"https://example.com/say-hello"). - withHeader(@"Content-Type", @"text/plain"). - withHeader(@"X-MY-AWESOME-HEADER", @"sisisi"). - withBody(@"Adios!"). - andReturnRawResponse([@"HTTP/1.1 200 OK\nContent-Type: text/plain\n\nhola" dataUsingEncoding:NSUTF8StringEncoding]); - - NSURL *url = [NSURL URLWithString:@"https://example.com/say-hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request setHTTPMethod:@"POST"]; - [request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"]; - [request setHTTPBody:[@"Adios!" dataUsingEncoding:NSASCIIStringEncoding]]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation start]; - - [operation waitUntilFinished]; - - [operation.error shouldBeNil]; - [[operation.responseString should] equal:@"hola"]; - [[theValue(operation.response.statusCode) should] equal:theValue(200)]; - [[[operation.response.allHeaderFields objectForKey:@"Content-Type"] should] equal:@"text/plain"]; - }); - - it(@"should have the same result as a real HTTP request", ^{ - NSURL *url = [NSURL URLWithString:@"http://localhost:12345/say-hello"]; - - [[LSNocilla sharedInstance] stop]; - - HTTPServer *server = [[HTTPServer alloc] init]; - [server setPort:12345]; - NSError *error; - [server setConnectionClass:[LSTestingConnection class]]; - [server start:&error]; - [error shouldBeNil]; - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request setHTTPMethod:@"POST"]; - [request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"]; - [request setHTTPBody:[@"Adios!" dataUsingEncoding:NSASCIIStringEncoding]]; - AFHTTPRequestOperation *realOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [realOperation start]; - - [realOperation waitUntilFinished]; - - [realOperation.error shouldBeNil]; - [[realOperation.responseString should] equal:@"hola"]; - [[theValue(realOperation.response.statusCode) should] equal:theValue(200)]; - - NSHTTPURLResponse *realResponse = realOperation.response; - NSString *realBody = realOperation.responseString; - - [server stop]; - - [[LSNocilla sharedInstance] start]; - - stubRequest(@"POST", @"http://localhost:12345/say-hello"). - withHeaders(@{@"Content-Type" : @"text/plain", @"X-MY-AWESOME-HEADER" : @"sisisi"}). - withBody(@"Adios!"). - andReturn(200). - withHeaders([realResponse allHeaderFields]). - withBody(@"hola"); - - - - NSMutableURLRequest *stubbedRequest = [NSMutableURLRequest requestWithURL:url]; - [stubbedRequest setHTTPMethod:@"POST"]; - [stubbedRequest setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; - [stubbedRequest setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"]; - [stubbedRequest setHTTPBody:[@"Adios!" dataUsingEncoding:NSASCIIStringEncoding]]; - AFHTTPRequestOperation *stubbedOperation = [[AFHTTPRequestOperation alloc] initWithRequest:stubbedRequest]; - [stubbedOperation start]; - - [stubbedOperation waitUntilFinished]; - - [stubbedOperation.error shouldBeNil]; - [[stubbedOperation.responseString should] equal:@"hola"]; - [[theValue(stubbedOperation.response.statusCode) should] equal:theValue(200)]; - - NSHTTPURLResponse *stubbedResponse = stubbedOperation.response; - NSString *stubbedBody = stubbedOperation.responseString; - - - NSDictionary *realHeaders = [realResponse allHeaderFields]; - NSDictionary *stubbedHeaders = [stubbedResponse allHeaderFields]; - [[theValue(realResponse.statusCode) should] equal:theValue(stubbedResponse.statusCode)]; - [[realHeaders should] equal:stubbedHeaders]; - [[realBody should] equal:stubbedBody]; - }); - - it(@"should stub an asynchronous request", ^{ - stubRequest(@"POST", @"https://example.com/say-hello"). - withHeaders(@{ @"X-MY-AWESOME-HEADER": @"sisisi", @"Content-Type": @"text/plain" }). - withBody(@"Adios!"). - andReturn(200). - withHeader(@"Content-Type", @"text/plain"). - withBody(@"hola"); - - NSURL *url = [NSURL URLWithString:@"https://example.com/say-hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request setHTTPMethod:@"POST"]; - [request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"]; - [request setHTTPBody:[@"Adios!" dataUsingEncoding:NSASCIIStringEncoding]]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation start]; - - [[expectFutureValue(theValue(operation.response.statusCode)) shouldEventually] equal:theValue(200)]; - [[operation.responseString should] equal:@"hola"]; - - [[[operation.response.allHeaderFields objectForKey:@"Content-Type"] shouldEventually] equal:@"text/plain"]; - [operation.error shouldBeNil]; - }); - - it(@"stubs a request with an error", ^{ - NSError *error = [NSError errorWithDomain:@"com.luisobo.nocilla" code:123 userInfo:@{NSLocalizedDescriptionKey:@"Failing, failing... 1, 2, 3..."}]; - - stubRequest(@"POST", @"https://example.com/say-hello"). - withHeaders(@{ @"X-MY-AWESOME-HEADER": @"sisisi", @"Content-Type": @"text/plain" }). - withBody(@"Adios!"). - andFailWithError(error); - - NSURL *url = [NSURL URLWithString:@"https://example.com/say-hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request setHTTPMethod:@"POST"]; - [request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"]; - [request setHTTPBody:[@"Adios!" dataUsingEncoding:NSASCIIStringEncoding]]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - - - __block BOOL succeed = NO; - __block BOOL failed = NO; - __block NSError *capturedError = nil; - [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { - succeed = YES; - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - capturedError = error; - failed = YES; - }]; - - [operation start]; - - [[expectFutureValue(theValue(failed)) shouldEventually] beYes]; - [[capturedError should] equal:[NSError errorWithDomain:@"com.luisobo.nocilla" code:123 userInfo:@{NSLocalizedDescriptionKey:@"Failing, failing... 1, 2, 3...", - @"NSErrorFailingURLKey":[NSURL URLWithString:@"https://example.com/say-hello"], - @"NSErrorFailingURLStringKey":@"https://example.com/say-hello" - }]]; - - [[operation.error should] equal:[NSError errorWithDomain:@"com.luisobo.nocilla" code:123 userInfo:@{NSLocalizedDescriptionKey:@"Failing, failing... 1, 2, 3...", - @"NSErrorFailingURLKey":[NSURL URLWithString:@"https://example.com/say-hello"], - @"NSErrorFailingURLStringKey":@"https://example.com/say-hello" - }]]; - }); - - it(@"stubs the request with data", ^{ - NSData *requestData = [@"data123" dataUsingEncoding:NSUTF8StringEncoding]; - stubRequest(@"POST", @"https://example.com/say-hello"). - withHeader(@"Content-Type", @"text/plain"). - withHeader(@"X-MY-AWESOME-HEADER", @"sisisi"). - withBody(requestData). - andReturn(200). - withHeader(@"Content-Type", @"text/plain"). - withBody([@"eeeeooo" dataUsingEncoding:NSUTF8StringEncoding]); - - NSURL *url = [NSURL URLWithString:@"https://example.com/say-hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request setHTTPMethod:@"POST"]; - [request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"]; - [request setHTTPBody:requestData]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation start]; - - [operation waitUntilFinished]; - - [operation.error shouldBeNil]; - [[operation.responseString should] equal:@"eeeeooo"]; - [[theValue(operation.response.statusCode) should] equal:theValue(200)]; - [[[operation.response.allHeaderFields objectForKey:@"Content-Type"] should] equal:@"text/plain"]; - - }); - - it(@"stubs the request with multipart request", ^{ - __block BOOL done = NO; - __block AFHTTPRequestOperation *capturedOperation; - __block id capturedResponseObject; - - NSData *requestData = [@"data123" dataUsingEncoding:NSUTF8StringEncoding]; - stubRequest(@"POST", @"https://example.com/say-hello"). - andReturn(200). - withHeader(@"Content-Type", @"application/json"). - withBody(@"{\"foo\":\"bar\"}"); - - NSURL *url = [NSURL URLWithString:@"https://example.com"]; - AFHTTPRequestOperationManager * client = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:url]; - NSInputStream * stream = [[NSInputStream alloc] initWithData:requestData]; - - [client POST:@"say-hello" parameters:nil constructingBodyWithBlock:^(id formData) { - [formData appendPartWithInputStream:stream name:@"name" fileName:@"filename" length:10 mimeType:@"application/octet-stream"]; - } success:^(AFHTTPRequestOperation *operation, id responseObject) { - capturedOperation = operation; - capturedResponseObject = responseObject; - done = YES; - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - done = YES; - }]; - - [[expectFutureValue(theValue(done)) shouldEventually] beYes]; - - [capturedOperation.error shouldBeNil]; - [[capturedOperation.responseString should] equal:@"{\"foo\":\"bar\"}"]; - [[theValue(capturedOperation.response.statusCode) should] equal:theValue(200)]; - [[[capturedOperation.response.allHeaderFields objectForKey:@"Content-Type"] should] equal:@"application/json"]; - [[capturedResponseObject should] equal:@{@"foo": @"bar"}]; - }); - - it(@"should properly handle redirects", ^{ - stubRequest(@"GET", @"https://example.com/hello"). - andReturn(301). - withHeader(@"Location", @"https://example.com/hola"); - - stubRequest(@"GET", @"https://example.com/hola"). - andReturn(200). - withHeader(@"Content-Type", @"text/plain"). - withBody(@"hola"); - - NSURL *url = [NSURL URLWithString:@"https://example.com/hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation start]; - - [operation waitUntilFinished]; - - [operation.error shouldBeNil]; - [[operation.responseString should] equal:@"hola"]; - [[theValue(operation.response.statusCode) should] equal:theValue(200)]; - [[[operation.response.allHeaderFields objectForKey:@"Content-Type"] should] equal:@"text/plain"]; - }); - - it(@"should properly sets cookies on a non-redirected request", ^{ - stubRequest(@"GET", @"https://example.com/hello"). - andReturn(200). - withBody(@"hola"). - withHeader(@"Content-Type", @"text/plain"). - withHeader(@"Set-Cookie", @"giveme=cookies;Path=/;"); - - NSURL *url = [NSURL URLWithString:@"https://example.com/hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation start]; - - [operation waitUntilFinished]; - - NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; - NSArray *cookies = [cookieStorage cookiesForURL:[NSURL URLWithString:@"https://example.com/"]]; - [[cookies should] haveCountOf:1]; - NSHTTPCookie *cookie = cookies[0]; - [[[cookie name] should] equal:@"giveme"]; - [[[cookie value] should] equal:@"cookies"]; - }); - - it(@"should properly sets cookies on redirect", ^{ - stubRequest(@"GET", @"https://example.com/hello"). - andReturn(301). - withHeaders(@{@"Location": @"https://example.com/hola", - @"Set-Cookie": @"giveme=cookies;Path=/;"}); - - stubRequest(@"GET", @"https://example.com/hola"). - withHeader(@"Cookie", @"giveme=cookies"). - andReturn(200). - withHeader(@"Content-Type", @"text/plain"). - withBody(@"hola"); - - NSURL *url = [NSURL URLWithString:@"https://example.com/hello"]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation start]; - - [operation waitUntilFinished]; - - NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; - NSArray *cookies = [cookieStorage cookiesForURL:[NSURL URLWithString:@"https://example.com/"]]; - [[cookies should] haveCountOf:1]; - NSHTTPCookie *cookie = cookies[0]; - [[[cookie name] should] equal:@"giveme"]; - [[[cookie value] should] equal:@"cookies"]; - - }); -}); -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Hooks/NSURLRequest/LSHTTPStubURLProtocolSpec.m b/NocillaTests/Hooks/NSURLRequest/LSHTTPStubURLProtocolSpec.m deleted file mode 100644 index 9afda7f9..00000000 --- a/NocillaTests/Hooks/NSURLRequest/LSHTTPStubURLProtocolSpec.m +++ /dev/null @@ -1,158 +0,0 @@ -#import "Kiwi.h" -#import "LSHTTPStubURLProtocol.h" -#import "LSStubRequest.h" -#import "LSStubResponse.h" -#import "LSNocilla.h" - -@interface NSHTTPURLResponse(UndocumentedInitializer) -- (id)initWithURL:(NSURL*)URL statusCode:(NSInteger)statusCode headerFields:(NSDictionary*)headerFields requestTime:(double)requestTime; -@end - -@interface LSTestingNSURLProtocolClient : NSObject -@property (nonatomic, strong) NSURLResponse *response; -@property (nonatomic, strong) NSData *body; -@end - -@implementation LSTestingNSURLProtocolClient -- (void)URLProtocol:(NSURLProtocol *)protocol wasRedirectedToRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse { - -} -- (void)URLProtocol:(NSURLProtocol *)protocol cachedResponseIsValid:(NSCachedURLResponse *)cachedResponse { - -} -- (void)URLProtocol:(NSURLProtocol *)protocol didReceiveResponse:(NSURLResponse *)response cacheStoragePolicy:(NSURLCacheStoragePolicy)policy { - self.response = response; -} -- (void)URLProtocol:(NSURLProtocol *)protocol didLoadData:(NSData *)data { - self.body = data; - -} -- (void)URLProtocolDidFinishLoading:(NSURLProtocol *)protocol { - -} -- (void)URLProtocol:(NSURLProtocol *)protocol didFailWithError:(NSError *)error { - -} -- (void)URLProtocol:(NSURLProtocol *)protocol didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - -} -- (void)URLProtocol:(NSURLProtocol *)protocol didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - -} - - -@end -SPEC_BEGIN(LSHTTPStubURLProtocolSpec) - -describe(@"+canInitWithRequest", ^{ - context(@"when it is a HTTP request", ^{ - it(@"should return YES", ^{ - NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.example.com/dogs.json"]]; - - BOOL result = [LSHTTPStubURLProtocol canInitWithRequest:request]; - - [[theValue(result) should] beYes]; - }); - }); - context(@"when it is a HTTP request", ^{ - it(@"should return YES", ^{ - NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://api.example.com/cats.xml"]]; - - BOOL result = [LSHTTPStubURLProtocol canInitWithRequest:request]; - - [[theValue(result) should] beYes]; - }); - }); - - context(@"when it is an FTP request", ^{ - it(@"should return NO", ^{ - NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"ftp://ftp.example.com/"]]; - - BOOL result = [LSHTTPStubURLProtocol canInitWithRequest:request]; - - [[theValue(result) should] beNo]; - }); - }); -}); - -describe(@"#startLoading", ^{ - context(@"when the protocol receives a request", ^{ - __block NSString *stringUrl = nil; - __block NSString *bodyString = nil; - __block LSHTTPStubURLProtocol *protocol = nil; - __block LSTestingNSURLProtocolClient *client = nil; - beforeEach(^{ - stringUrl = @"http://api.example.com/dogs.xml"; - NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:stringUrl]]; - - client = [[LSTestingNSURLProtocolClient alloc] init]; - - protocol = [[LSHTTPStubURLProtocol alloc] initWithRequest:request cachedResponse:nil client:client]; - }); - context(@"that matches an stubbed request", ^{ - context(@"and the response should succeed", ^{ - beforeEach(^{ - LSStubRequest *stubRequest = [[LSStubRequest alloc] initWithMethod:@"GET" url:stringUrl]; - LSStubResponse *stubResponse = [[LSStubResponse alloc] initWithStatusCode:403]; - [stubResponse setHeader:@"Content-Type" value:@"application/xml"]; - bodyString = @"Error" ; - stubResponse.body = [bodyString dataUsingEncoding:NSUTF8StringEncoding]; - stubRequest.response = stubResponse; - - [[LSNocilla sharedInstance] stub:@selector(stubbedRequests) andReturn:@[stubRequest]]; - }); - - it(@"should pass to the client the correct response", ^{ - [protocol startLoading]; - - [[client.response should] beKindOfClass:[NSHTTPURLResponse class]]; - NSHTTPURLResponse *response = (NSHTTPURLResponse *)client.response; - [[response.URL should] equal:[NSURL URLWithString:stringUrl]]; - [[theValue(response.statusCode) should] equal:theValue(403)]; - [[response.allHeaderFields should] equal:@{ @"Content-Type": @"application/xml"}]; - }); - it(@"should pass the body to the client", ^{ - - [[client should] receive:@selector(URLProtocol:didLoadData:) withArguments:protocol, [bodyString dataUsingEncoding:NSUTF8StringEncoding]]; - - [protocol startLoading]; - - }); - - it(@"should notify the client that it finished loading", ^{ - [[client should] receive:@selector(URLProtocolDidFinishLoading:)]; - - [protocol startLoading]; - }); - }); - - context(@"and the response should fail", ^{ - __block NSError *error; - beforeEach(^{ - LSStubRequest *stubRequest = [[LSStubRequest alloc] initWithMethod:@"GET" url:stringUrl]; - error = [NSError mock]; - LSStubResponse *stubResponse = [[LSStubResponse alloc] initWithError:error]; - stubRequest.response = stubResponse; - - [[LSNocilla sharedInstance] stub:@selector(stubbedRequests) andReturn:@[stubRequest]]; - }); - - it(@"should notify the client that it failed", ^{ - [[client should] receive:@selector(URLProtocol:didFailWithError:) withArguments:protocol, error]; - - [protocol startLoading]; - }); - }); - }); - context(@"that doesn't match any stubbed request", ^{ - it(@"should raise an exception with a meaningful message", ^{ - NSString *expectedMessage = @"An unexpected HTTP request was fired.\n\nUse this snippet to stub the request:\nstubRequest(@\"GET\", @\"http://api.example.com/dogs.xml\");\n"; - [[theBlock(^{ - [protocol startLoading]; - }) should] raiseWithName:@"NocillaUnexpectedRequest" reason:expectedMessage]; - }); - }); - }); -}); - -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Hooks/NSURLRequest/MKNetworkKitStubbingSpec.m b/NocillaTests/Hooks/NSURLRequest/MKNetworkKitStubbingSpec.m deleted file mode 100644 index 8d61437f..00000000 --- a/NocillaTests/Hooks/NSURLRequest/MKNetworkKitStubbingSpec.m +++ /dev/null @@ -1,125 +0,0 @@ -#import "Kiwi.h" -#import "MKNetworkKit.h" -#import "Nocilla.h" -#import "HTTPServer.h" -#import "LSTestingConnection.h" - -SPEC_BEGIN(MKNetworkKitStubbingSpec) - -beforeAll(^{ - [[LSNocilla sharedInstance] start]; -}); -afterAll(^{ - [[LSNocilla sharedInstance] stop]; -}); -afterEach(^{ - [[LSNocilla sharedInstance] clearStubs]; -}); - -context(@"MKNetworkKit", ^{ - it(@"should stub an asynchronous request", ^{ - stubRequest(@"POST", @"http://example.com/say-hello"). - withHeaders(@{ @"X-MY-AWESOME-HEADER": @"sisisi", @"Content-Type": @"application/json; charset=utf-8" }). - withBody(@"{\"text\":\"hola\"}"). - andReturn(200). - withHeader(@"Content-Type", @"text/plain"). - withBody(@"{\"text\":\"adios\"}"); - - MKNetworkOperation *operation = [[MKNetworkOperation alloc] - initWithURLString:@"http://example.com/say-hello" - params:[@{ @"text" : @"hola" } mutableCopy] - httpMethod:@"POST"]; - [operation addHeaders: @{ - @"Content-Type" : @"text/plain", - @"X-MY-AWESOME-HEADER" : @"sisisi" }]; - - [operation setPostDataEncoding:MKNKPostDataEncodingTypeJSON]; - [operation start]; - - - - - [[expectFutureValue(operation.responseString) shouldEventually] equal:@"{\"text\":\"adios\"}"]; - - [operation.error shouldBeNil]; - [[theValue(operation.readonlyResponse.statusCode) should] equal:theValue(200)]; - [[[operation.readonlyResponse.allHeaderFields objectForKey:@"Content-Type"] should] equal:@"text/plain"]; - }); - - it(@"should have the same result as a real HTTP request", ^{ - NSURL *url = [NSURL URLWithString:@"http://localhost:12345/say-hello"]; - - [[LSNocilla sharedInstance] stop]; - - HTTPServer *server = [[HTTPServer alloc] init]; - [server setPort:12345]; - NSError *error; - [server setConnectionClass:[LSTestingConnection class]]; - [server start:&error]; - [error shouldBeNil]; - - - MKNetworkOperation *realOperation = [[MKNetworkOperation alloc] - initWithURLString:url.absoluteString - params:[@{ @"this is" : @"the body" } mutableCopy] - httpMethod:@"POST"]; - [realOperation addHeaders: @{ - @"Content-Type" : @"application/json", - @"X-MY-AWESOME-HEADER" : @"sisisi" }]; - - [realOperation setPostDataEncoding:MKNKPostDataEncodingTypeJSON]; - [realOperation start]; - - - [[expectFutureValue(theValue(realOperation.readonlyResponse.statusCode)) shouldEventually] equal:theValue(200)]; - [realOperation.error shouldBeNil]; - [[realOperation.responseString should] equal:@"hola"]; - - - NSHTTPURLResponse *realResponse = realOperation.readonlyResponse; - NSString *realBody = realOperation.responseString; - - [server stop]; - - [[LSNocilla sharedInstance] start]; - - stubRequest(@"POST", @"http://localhost:12345/say-hello"). - withHeaders(@{ @"Content-Type": @"application/json; charset=utf-8", @"X-MY-AWESOME-HEADER": @"sisisi" }). - withBody(@"{\"this is\":\"the body\"}"). - andReturn(200). - withHeaders([realResponse allHeaderFields]). - withBody(@"hola"); - - - - MKNetworkOperation *stubbedOperation = [[MKNetworkOperation alloc] - initWithURLString:url.absoluteString - params:[@{ @"this is" : @"the body" } mutableCopy] - httpMethod:@"POST"]; - [stubbedOperation addHeaders: @{ - @"Content-Type" : @"application/json", - @"X-MY-AWESOME-HEADER" : @"sisisi" }]; - - [stubbedOperation setPostDataEncoding:MKNKPostDataEncodingTypeJSON]; - [stubbedOperation start]; - - [[expectFutureValue(theValue(stubbedOperation.readonlyResponse.statusCode)) shouldEventually] equal:theValue(200)]; - - [[stubbedOperation.responseString should] equal:@"hola"]; - [stubbedOperation.error shouldBeNil]; - - - - NSHTTPURLResponse *stubbedResponse = stubbedOperation.readonlyResponse; - NSString *stubbedBody = stubbedOperation.responseString; - - - NSDictionary *realHeaders = [realResponse allHeaderFields]; - NSDictionary *stubbedHeaders = [stubbedResponse allHeaderFields]; - [[theValue(realResponse.statusCode) should] equal:theValue(stubbedResponse.statusCode)]; - [[realHeaders should] equal:stubbedHeaders]; - [[realBody should] equal:stubbedBody]; - }); - -}); -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Hooks/NSURLRequest/NSURLRequest+LSHTTPRequestSpec.m b/NocillaTests/Hooks/NSURLRequest/NSURLRequest+LSHTTPRequestSpec.m deleted file mode 100644 index b9e86b50..00000000 --- a/NocillaTests/Hooks/NSURLRequest/NSURLRequest+LSHTTPRequestSpec.m +++ /dev/null @@ -1,25 +0,0 @@ -#import "Kiwi.h" -#import "NSURLRequest+LSHTTPRequest.h" - -SPEC_BEGIN(NSURLRequest_LSHTTPRequestSpec) - -describe(@"-body", ^{ - __block NSURLRequest *request; - - context(@"when the request provides a body stream", ^{ - __block NSString *stringUrl = @"http://api.example.com/dogs.xml"; - __block NSData *requestBody = [@"arg1=foo&arg2=bar" dataUsingEncoding:NSUTF8StringEncoding]; - - beforeEach(^{ - NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:stringUrl]]; - mutableRequest.HTTPBodyStream = [NSInputStream inputStreamWithData:requestBody]; - request = mutableRequest; - }); - - it(@"uses the entire stream as the body", ^{ - [[[request body] should] equal:requestBody]; - }); - }); -}); - -SPEC_END diff --git a/NocillaTests/Hooks/NSURLRequest/NSURLRequestHookSpec.m b/NocillaTests/Hooks/NSURLRequest/NSURLRequestHookSpec.m deleted file mode 100644 index 4b666604..00000000 --- a/NocillaTests/Hooks/NSURLRequest/NSURLRequestHookSpec.m +++ /dev/null @@ -1,24 +0,0 @@ -#import "Kiwi.h" -#import "LSNSURLHook.h" -#import "LSHTTPStubURLProtocol.h" - -SPEC_BEGIN(LSNSURLHookSpec) -describe(@"#load", ^{ - it(@"should register LSHTTPStubURLProtocol as a NSURLProtocol", ^{ - LSNSURLHook *hook = [[LSNSURLHook alloc] init]; - [[NSURLProtocol should] receive:@selector(registerClass:) withArguments:[LSHTTPStubURLProtocol class]]; - - [hook load]; - }); -}); - -describe(@"#unload", ^{ - it(@"should unregister LSHTTPStubURLProtocol as a NSURLProtocol", ^{ - LSNSURLHook *hook = [[LSNSURLHook alloc] init]; - - [[NSURLProtocol should] receive:@selector(unregisterClass:) withArguments:[LSHTTPStubURLProtocol class]]; - - [hook unload]; - }); -}); -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Hooks/NSURLSession/NSURLSessionStubbingSpec.m b/NocillaTests/Hooks/NSURLSession/NSURLSessionStubbingSpec.m deleted file mode 100644 index 7fe3d259..00000000 --- a/NocillaTests/Hooks/NSURLSession/NSURLSessionStubbingSpec.m +++ /dev/null @@ -1,45 +0,0 @@ -// -// NSURLSessionStubbingSpec.m -// Nocilla -// -// Created by Luis Solano Bonet on 08/01/14. -// Copyright 2014 Luis Solano Bonet. All rights reserved. -// - -#import "Kiwi.h" -#import "Nocilla.h" -#import "LSHTTPStubURLProtocol.h" - -SPEC_BEGIN(NSURLSessionStubbingSpec) -if (NSClassFromString(@"NSURLSession") == nil) return; - -beforeEach(^{ - [[LSNocilla sharedInstance] start]; -}); -afterEach(^{ - [[LSNocilla sharedInstance] stop]; - [[LSNocilla sharedInstance] clearStubs]; -}); - -it(@"stubs NSURLSessionDataTask", ^{ - stubRequest(@"GET", @"http://example.com") - .andReturn(200) - .withBody(@"this is a counter example."); - __block BOOL done = NO; - __block NSData *capturedData; - NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; - - NSURL *url = [NSURL URLWithString:@"http://example.com"]; - NSURLSession *urlsession = [NSURLSession sessionWithConfiguration:configuration]; - NSURLSessionDataTask *datatask = [urlsession dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - done = YES; - capturedData = data; - }]; - [datatask resume]; - - - [[expectFutureValue(theValue(done)) shouldEventually] beYes]; - [[[[NSString alloc] initWithData:capturedData encoding:NSUTF8StringEncoding] should] equal:@"this is a counter example."]; -}); - -SPEC_END diff --git a/NocillaTests/Info.plist b/NocillaTests/Info.plist deleted file mode 100644 index c443a0d5..00000000 --- a/NocillaTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - com.luissolano.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/NocillaTests/LSNocillaSpec.m b/NocillaTests/LSNocillaSpec.m deleted file mode 100644 index 9dd15224..00000000 --- a/NocillaTests/LSNocillaSpec.m +++ /dev/null @@ -1,70 +0,0 @@ -#import "Kiwi.h" -#import "LSNocilla.h" -#import "LSStubRequest.h" -#import "LSStubResponse.h" - -SPEC_BEGIN(LSNocillaSpec) - -describe(@"-responseForRequest:", ^{ - context(@"when the specified request matches a previously stubbed request", ^{ - it(@"returns the associated response", ^{ - LSStubRequest *stubbedRequest = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - LSStubResponse *stubbedResponse = [[LSStubResponse alloc] initWithStatusCode:403]; - stubbedRequest.response = stubbedResponse; - [[LSNocilla sharedInstance] addStubbedRequest:stubbedRequest]; - - NSObject *actualRequest = [KWMock nullMockForProtocol:@protocol(LSHTTPRequest)]; - [actualRequest stub:@selector(url) andReturn:[NSURL URLWithString:@"http://www.google.com"]]; - [actualRequest stub:@selector(method) andReturn:@"GET"]; - - LSStubResponse *result = [[LSNocilla sharedInstance] responseForRequest:actualRequest]; - - [[result should] equal:stubbedResponse]; - - [[LSNocilla sharedInstance] clearStubs]; - }); - - describe(@"when a stubbed request is replaced with a new stub", ^{ - it(@"returns the response for the newer stub", ^{ - LSStubRequest *firstStub = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - LSStubResponse *firstResponse = [[LSStubResponse alloc] initWithStatusCode:403]; - firstStub.response = firstResponse; - [[LSNocilla sharedInstance] addStubbedRequest:firstStub]; - - LSStubRequest *secondStub = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"http://www.google.com"]; - LSStubResponse *secondResponse = [[LSStubResponse alloc] initWithStatusCode:200]; - secondStub.response = secondResponse; - [[LSNocilla sharedInstance] addStubbedRequest:secondStub]; - - NSObject *actualRequest = [KWMock nullMockForProtocol:@protocol(LSHTTPRequest)]; - [actualRequest stub:@selector(url) andReturn:[NSURL URLWithString:@"http://www.google.com"]]; - [actualRequest stub:@selector(method) andReturn:@"GET"]; - - LSStubResponse *result = [[LSNocilla sharedInstance] responseForRequest:actualRequest]; - - [[result shouldNot] equal:firstResponse]; - [[result should] equal:secondResponse]; - - [[LSNocilla sharedInstance] clearStubs]; - }); - }); - }); - - context(@"when the specified request does not match any stubbed request", ^{ - it(@"raises an exception with a descriptive error message ", ^{ - NSObject *actualRequest = [KWMock nullMockForProtocol:@protocol(LSHTTPRequest)]; - [actualRequest stub:@selector(url) andReturn:[NSURL URLWithString:@"http://www.google.com"]]; - [actualRequest stub:@selector(method) andReturn:@"GET"]; - - - NSString *expectedMessage = @"An unexpected HTTP request was fired.\n\nUse this snippet to stub the request:\nstubRequest(@\"GET\", @\"http://www.google.com\");\n"; - [[theBlock(^{ - [[LSNocilla sharedInstance] responseForRequest:actualRequest]; - }) should] raiseWithName:@"NocillaUnexpectedRequest" reason:expectedMessage]; - - [[LSNocilla sharedInstance] clearStubs]; - }); - }); -}); - -SPEC_END \ No newline at end of file diff --git a/NocillaTests/LSStubResponseSpec.m b/NocillaTests/LSStubResponseSpec.m deleted file mode 100644 index 155bd12b..00000000 --- a/NocillaTests/LSStubResponseSpec.m +++ /dev/null @@ -1,31 +0,0 @@ -#import "Kiwi.h" -#import "LSStubResponse.h" - -SPEC_BEGIN(LSStubResponseSpec) - -describe(@"#initWithRawResponse:", ^{ - context(@"when the input data is a complete raw response", ^{ - it(@"should have the correct statusCode, headers and body", ^{ - NSData *rawData = [@"HTTP/1.1 201 created\nContent-Type: application/json; charset=utf-8\nConnection: keep-alive\n\n{\"success\":true}" dataUsingEncoding:NSUTF8StringEncoding]; - LSStubResponse *stubResponse = [[LSStubResponse alloc] initWithRawResponse:rawData]; - - [[theValue(stubResponse.statusCode) should] equal:theValue(201)]; - [[stubResponse.headers should] equal:[NSDictionary dictionaryWithObjectsAndKeys:@"application/json; charset=utf-8", @"Content-Type", - @"keep-alive", @"Connection", nil]]; - [[stubResponse.body should] equal:[@"{\"success\":true}" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - }); - - context(@"when the input data is a just the raw body", ^{ - it(@"should have the correct body with default status code and headers", ^{ - NSData *rawData = [@"{\"success\":true}" dataUsingEncoding:NSUTF8StringEncoding]; - LSStubResponse *stubResponse = [[LSStubResponse alloc] initWithRawResponse:rawData]; - - [[theValue(stubResponse.statusCode) should] equal:theValue(200)]; - [[stubResponse.headers should] equal:[NSDictionary dictionary]]; - [[stubResponse.body should] equal:[@"{\"success\":true}" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - }); -}); - -SPEC_END \ No newline at end of file diff --git a/NocillaTests/LSTestRequest.h b/NocillaTests/LSTestRequest.h deleted file mode 100644 index a2713f3b..00000000 --- a/NocillaTests/LSTestRequest.h +++ /dev/null @@ -1,14 +0,0 @@ -#import - -#import "LSHTTPRequest.h" - -@interface LSTestRequest : NSObject - -@property (nonatomic, strong) NSURL *url; -@property (nonatomic, strong) NSString *method; -@property (nonatomic, readonly) NSDictionary *headers; -@property (nonatomic, strong) NSData *body; - -- (instancetype)initWithMethod:(NSString *)method url:(NSString *)url; -- (void)setHeader:(NSString *)header value:(NSString *)value; -@end diff --git a/NocillaTests/LSTestRequest.m b/NocillaTests/LSTestRequest.m deleted file mode 100644 index 79ebf108..00000000 --- a/NocillaTests/LSTestRequest.m +++ /dev/null @@ -1,27 +0,0 @@ -#import "LSTestRequest.h" - -@interface LSTestRequest () -@property (nonatomic, strong) NSMutableDictionary *mutableHeaders; -@end - -@implementation LSTestRequest - -- (instancetype)initWithMethod:(NSString *)method url:(NSString *)url { - self = [super init]; - if (self) { - _method = method; - _url = [NSURL URLWithString:url]; - _mutableHeaders = [NSMutableDictionary dictionary]; - } - return self; -} - -- (void)setHeader:(NSString *)header value:(NSString *)value { - self.mutableHeaders[header] = value; -} - -- (NSDictionary *)headers { - return [self.mutableHeaders copy]; -} - -@end diff --git a/NocillaTests/Matchers/LSDataMatcherSpec.m b/NocillaTests/Matchers/LSDataMatcherSpec.m deleted file mode 100644 index 9e2b8ba9..00000000 --- a/NocillaTests/Matchers/LSDataMatcherSpec.m +++ /dev/null @@ -1,46 +0,0 @@ -#import "Kiwi.h" -#import "LSDataMatcher.h" - -SPEC_BEGIN(LSDataMatcherSpec) - -__block LSDataMatcher *matcher = nil; -__block NSData *data = nil; - -beforeEach(^{ - const char bytes[] = { 0xF1, 0x00, 0xFF }; - data = [NSData dataWithBytes:bytes length:sizeof(bytes)]; - matcher = [[LSDataMatcher alloc] initWithData:data]; -}); - -context(@"when both data are equal", ^{ - it(@"matches", ^{ - [[theValue([matcher matchesData:[data copy]]) should] beYes]; - }); -}); - -context(@"when both data are different", ^{ - it(@"does not match", ^{ - const char other_bytes[] = { 0xA1, 0x00, 0xAF }; - NSData *other_data = [NSData dataWithBytes:other_bytes length:sizeof(other_bytes)]; - - [[theValue([matcher matchesData:other_data]) should] beNo]; - }); -}); - -describe(@"isEqual:", ^{ - it(@"is equal to another data matcher with the same data", ^{ - LSDataMatcher *matcherA = [[LSDataMatcher alloc] initWithData:[@"same" dataUsingEncoding:NSUTF8StringEncoding]]; - LSDataMatcher *matcherB = [[LSDataMatcher alloc] initWithData:[@"same" dataUsingEncoding:NSUTF8StringEncoding]]; - - [[matcherA should] equal:matcherB]; - }); - - it(@"is not equal to another data matcher with a different data", ^{ - LSDataMatcher *matcherA = [[LSDataMatcher alloc] initWithData:[@"omg" dataUsingEncoding:NSUTF8StringEncoding]]; - LSDataMatcher *matcherB = [[LSDataMatcher alloc] initWithData:[@"different" dataUsingEncoding:NSUTF8StringEncoding]]; - - [[matcherA shouldNot] equal:matcherB]; - }); -}); - -SPEC_END diff --git a/NocillaTests/Matchers/LSRegexMatcherSpec.m b/NocillaTests/Matchers/LSRegexMatcherSpec.m deleted file mode 100644 index 1007526a..00000000 --- a/NocillaTests/Matchers/LSRegexMatcherSpec.m +++ /dev/null @@ -1,44 +0,0 @@ -#import "Kiwi.h" -#import "LSRegexMatcher.h" -#import "NSString+Nocilla.h" - -SPEC_BEGIN(LSRegexMatcherSpec) - -__block LSRegexMatcher *matcher = nil; -beforeEach(^{ - matcher = [[LSRegexMatcher alloc] initWithRegex:@"Fo+".regex]; -}); - -context(@"when the string matches the regex", ^{ - it(@"matches", ^{ - [[theValue([matcher matches:@"Fo"]) should] beYes]; - [[theValue([matcher matches:@"Foo"]) should] beYes]; - [[theValue([matcher matches:@"Foooooo"]) should] beYes]; - }); -}); - -context(@"when string does not match", ^{ - it(@"does not match", ^{ - [[theValue([matcher matches:@"fo"]) should] beNo]; - [[theValue([matcher matches:@"F"]) should] beNo]; - [[theValue([matcher matches:@"bar"]) should] beNo]; - }); -}); - -describe(@"isEqual:", ^{ - it(@"is equal to another regex matcher with the same regex", ^{ - LSRegexMatcher *matcherA = [[LSRegexMatcher alloc] initWithRegex:@"([same]+)".regex]; - LSRegexMatcher *matcherB = [[LSRegexMatcher alloc] initWithRegex:@"([same]+)".regex]; - - [[matcherA should] equal:matcherB]; - }); - - it(@"is not equal to another regex matcher with a different regex", ^{ - LSRegexMatcher *matcherA = [[LSRegexMatcher alloc] initWithRegex:@"([omg]+)".regex]; - LSRegexMatcher *matcherB = [[LSRegexMatcher alloc] initWithRegex:@"([different]+)".regex]; - - [[matcherA shouldNot] equal:matcherB]; - }); -}); - -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Matchers/LSStringMatcherSpec.m b/NocillaTests/Matchers/LSStringMatcherSpec.m deleted file mode 100644 index c2e24119..00000000 --- a/NocillaTests/Matchers/LSStringMatcherSpec.m +++ /dev/null @@ -1,39 +0,0 @@ -#import "Kiwi.h" -#import "LSStringMatcher.h" - -SPEC_BEGIN(LSStringMatcherSpec) - -__block LSStringMatcher *matcher = nil; -beforeEach(^{ - matcher = [[LSStringMatcher alloc] initWithString:@"foo"]; -}); - -context(@"when both strings are equal", ^{ - it(@"matches", ^{ - [[theValue([matcher matches:@"foo"]) should] beYes]; - }); -}); - -context(@"when both strings are different", ^{ - it(@"does not match", ^{ - [[theValue([matcher matches:@"bar"]) should] beNo]; - }); -}); - -describe(@"isEqual:", ^{ - it(@"is equal to another string matcher with the same string", ^{ - LSStringMatcher *matcherA = [[LSStringMatcher alloc] initWithString:@"same"]; - LSStringMatcher *matcherB = [[LSStringMatcher alloc] initWithString:@"same"]; - - [[matcherA should] equal:matcherB]; - }); - - it(@"is not equal to another string matcher with a different string", ^{ - LSStringMatcher *matcherA = [[LSStringMatcher alloc] initWithString:@"omg"]; - LSStringMatcher *matcherB = [[LSStringMatcher alloc] initWithString:@"different"]; - - [[matcherA shouldNot] equal:matcherB]; - }); -}); - -SPEC_END \ No newline at end of file diff --git a/NocillaTests/NocillaTests-Info.plist b/NocillaTests/NocillaTests-Info.plist deleted file mode 100644 index 169b6f71..00000000 --- a/NocillaTests/NocillaTests-Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/NocillaTests/Stubs/LSStubRequestSpec.m b/NocillaTests/Stubs/LSStubRequestSpec.m deleted file mode 100644 index 0235201d..00000000 --- a/NocillaTests/Stubs/LSStubRequestSpec.m +++ /dev/null @@ -1,312 +0,0 @@ -#import "Kiwi.h" -#import "LSStubRequest.h" -#import "LSTestRequest.h" -#import "NSString+Nocilla.h" -#import "LSRegexMatcher.h" -#import "LSDataMatcher.h" -#import "LSStringMatcher.h" - -SPEC_BEGIN(LSStubRequestSpec) - -describe(@"#matchesRequest:", ^{ - context(@"when the method and the URL are equal", ^{ - it(@"should match", ^{ - LSStubRequest *stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - LSTestRequest *other = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [[theValue([stubRequest matchesRequest:other]) should] beYes]; - }); - }); - context(@"when the method is different", ^{ - it(@"should not match", ^{ - LSStubRequest *stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - LSTestRequest *other = [[LSTestRequest alloc] initWithMethod:@"GET" url:@"https://api.example.com/cats/whiskas.json"]; - - [[theValue([stubRequest matchesRequest:other]) should] beNo]; - }); - }); - context(@"when the URL is different", ^{ - it(@"should not match", ^{ - LSStubRequest *stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - LSTestRequest *other = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/dogs/barky.json"]; - - [[theValue([stubRequest matchesRequest:other]) should] beNo]; - }); - }); - - context(@"when we use a regex matcher for the URL", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *other = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" urlMatcher:[[LSRegexMatcher alloc] initWithRegex:@"^http://foo.com".regex]]; - }); - context(@"the the actual URL matches that regex", ^{ - it(@"matches", ^{ - other = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"http://foo.com/something.json"]; - - [[theValue([stubRequest matchesRequest:other]) should] beYes]; - }); - }); - - context(@"the the actual URL matches that regex", ^{ - it(@"matches", ^{ - other = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"asdhttp://foo.com"]; - - [[theValue([stubRequest matchesRequest:other]) should] beNo]; - }); - }); - }); - - context(@"when the stub request has a subset of header of the actual request", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - [actualRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - }); - describe(@"the stubRequest request", ^{ - it(@"should match the actualRequest request", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beYes]; - }); - }); - - }); - - context(@"when the stub request has a perset of headers of the actual request", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - [stubRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - }); - describe(@"the actualRequest request", ^{ - it(@"should not match the stubRequest request", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beNo]; - }); - }); - }); - - context(@"when the both requests have the same headers", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - [stubRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - [actualRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - }); - it(@"should match", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beYes]; - }); - }); - - context(@"when both requests have the same body", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - [stubRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - [actualRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - LSDataMatcher *bodyMatcher = [[LSDataMatcher alloc] initWithData:[@"Hola, this is a body" dataUsingEncoding:NSUTF8StringEncoding]]; - [stubRequest setBody:bodyMatcher]; - [actualRequest setBody:[@"Hola, this is a body" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - it(@"should match", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beYes]; - }); - }); - - context(@"when using a matching regex to match the body", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - [stubRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - [actualRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - LSRegexMatcher *bodyMatcher = [[LSRegexMatcher alloc] initWithRegex:[NSRegularExpression regularExpressionWithPattern:@"^Hola" options:0 error:nil]]; - [stubRequest setBody:bodyMatcher]; - [actualRequest setBody:[@"Hola, this is a body" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - it(@"should match", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beYes]; - }); - }); - - context(@"when both requests have different bodies", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - [stubRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - [actualRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - LSDataMatcher *bodyMatcher = [[LSDataMatcher alloc] initWithData:[@"Hola, this is a body" dataUsingEncoding:NSUTF8StringEncoding]]; - [stubRequest setBody:bodyMatcher]; - [actualRequest setBody:[@"Adios, this is a body as well" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - it(@"should match", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beNo]; - }); - }); - - context(@"when using a regex that does no match to match the body", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - [stubRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - [actualRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - LSRegexMatcher *bodyMatcher = [[LSRegexMatcher alloc] initWithRegex:[NSRegularExpression regularExpressionWithPattern:@"^Hola" options:0 error:nil]]; - [stubRequest setBody:bodyMatcher]; - [actualRequest setBody:[@"Adios, this is a body as well" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - it(@"should match", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beNo]; - }); - }); - - context(@"when the stubRequest request has a nil body", ^{ - __block LSStubRequest *stubRequest = nil; - __block LSTestRequest *actualRequest = nil; - beforeEach(^{ - stubRequest = [[LSStubRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - actualRequest = [[LSTestRequest alloc] initWithMethod:@"PUT" url:@"https://api.example.com/cats/whiskas.json"]; - - [stubRequest setHeader:@"Content-Type" value:@"application/json"]; - [stubRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setHeader:@"Content-Type" value:@"application/json"]; - [actualRequest setHeader:@"X-API-TOKEN" value:@"123abc"]; - - [actualRequest setBody:[@"Adios, this is a body as well" dataUsingEncoding:NSUTF8StringEncoding]]; - }); - describe(@"the stubRequest request", ^{ - it(@"should match the actualRequest request", ^{ - [[theValue([stubRequest matchesRequest:actualRequest]) should] beYes]; - }); - }); - }); -}); - -describe(@"isEqual:", ^{ - it(@"is equal to a stub with the same method, url, headers and body", ^{ - // It may appear that there is needless duplication of matcher objects in this tests, - // however this is intended as we need to ensure the properties of the stub request - // are truly equal by value, not just equal pointers. - - LSRegexMatcher *urlA = [[LSRegexMatcher alloc] initWithRegex:@"https://(.+)\\.example\\.com/(.+)/data\\.json".regex]; - LSStubRequest *stubA = [[LSStubRequest alloc] initWithMethod:@"GET" urlMatcher:urlA]; - LSRegexMatcher *urlB = [[LSRegexMatcher alloc] initWithRegex:@"https://(.+)\\.example\\.com/(.+)/data\\.json".regex]; - LSStubRequest *stubB = [[LSStubRequest alloc] initWithMethod:@"GET" urlMatcher:urlB]; - - stubA.body = [[LSRegexMatcher alloc] initWithRegex:@"checkout my sexy body ([a-z]+?)".regex]; - stubB.body = [[LSRegexMatcher alloc] initWithRegex:@"checkout my sexy body ([a-z]+?)".regex]; - - [stubA setHeader:@"Content-Type" value:@"application/json"]; - [stubB setHeader:@"Content-Type" value:@"application/json"]; - - [[stubA should] equal:stubB]; - }); - - it(@"is not equal with a different method", ^{ - LSStubRequest *stubA = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"google.com"]; - LSStubRequest *stubB = [[LSStubRequest alloc] initWithMethod:@"POST" url:@"google.com"]; - - [[stubA shouldNot] equal:stubB]; - }); - - it(@"is not equal with a different url matcher", ^{ - LSRegexMatcher *urlA = [[LSRegexMatcher alloc] initWithRegex:@"https://(.+)\\.example\\.com/(.+)/data\\.json".regex]; - LSStubRequest *stubA = [[LSStubRequest alloc] initWithMethod:@"GET" urlMatcher:urlA]; - LSRegexMatcher *urlB = [[LSRegexMatcher alloc] initWithRegex:@"https://github\\.com/(.+)/(.+)/".regex]; - LSStubRequest *stubB = [[LSStubRequest alloc] initWithMethod:@"GET" urlMatcher:urlB]; - - [[stubA shouldNot] equal:stubB]; - }); - - it(@"is not equal with different headers", ^{ - LSStubRequest *stubA = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"google.com"]; - LSStubRequest *stubB = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"google.com"]; - - [stubA setHeader:@"Content-Type" value:@"application/json"]; - [stubB setHeader:@"Content-Type" value:@"application/json"]; - - [stubA setHeader:@"X-OMG" value:@"nothings compares"]; - [stubB setHeader:@"X-DIFFERENT" value:@"to you"]; - - [[stubA shouldNot] equal:stubB]; - }); - - it(@"is not equal with a different body", ^{ - LSStubRequest *stubA = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"google.com"]; - LSStubRequest *stubB = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"google.com"]; - - stubA.body = [[LSStringMatcher alloc] initWithString:@"omg"]; - stubB.body = [[LSStringMatcher alloc] initWithString:@"different"]; - - [[stubA shouldNot] equal:stubB]; - }); - - it(@"is equal with a nil bodies", ^{ - // Body is special in that it's the only propery that may be nil, - // and [nil isEqual:nil] returns NO. - - LSStubRequest *stubA = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"google.com"]; - LSStubRequest *stubB = [[LSStubRequest alloc] initWithMethod:@"GET" url:@"google.com"]; - - stubA.body = nil; - stubB.body = nil; - - [[stubA should] equal:stubB]; - }); -}); - -SPEC_END \ No newline at end of file diff --git a/NocillaTests/Support/LSTestingConnection.h b/NocillaTests/Support/LSTestingConnection.h deleted file mode 100644 index f2e0f135..00000000 --- a/NocillaTests/Support/LSTestingConnection.h +++ /dev/null @@ -1,5 +0,0 @@ -#import "HTTPConnection.h" -#import "LSStubResponse.h" - -@interface LSTestingConnection : HTTPConnection -@end diff --git a/NocillaTests/Support/LSTestingConnection.m b/NocillaTests/Support/LSTestingConnection.m deleted file mode 100644 index 4aae1338..00000000 --- a/NocillaTests/Support/LSTestingConnection.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "LSTestingConnection.h" -#import "HTTPDataResponse.h" -#import "HTTPResponse.h" -@implementation LSTestingConnection -- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path { - return YES; -} - -- (NSObject *)httpResponseForMethod:(NSString *)method URI:(NSString *)path { - NSObject *response = [[HTTPDataResponse alloc] initWithData:[@"hola" dataUsingEncoding:NSUTF8StringEncoding]]; - - return response; -} - -@end diff --git a/NocillaTests/en.lproj/InfoPlist.strings b/NocillaTests/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28ff..00000000 --- a/NocillaTests/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..7b94e5a7 --- /dev/null +++ b/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Nocilla", + defaultLocalization: "en", + platforms: [.iOS(.v11)], + products: [ + .library(name: "Nocilla", targets: ["Nocilla"]), + ], + dependencies: [ + + ], + targets: [ + .target( + name: "Nocilla", + dependencies: [ + + ], + path: "Nocilla", + publicHeadersPath: "public" + ) + ] +) + diff --git a/Podfile b/Podfile deleted file mode 100644 index 97eb52c9..00000000 --- a/Podfile +++ /dev/null @@ -1,15 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' - -platform :ios, '9.0' - -project 'Nocilla' - -target :NocillaTests do - inherit! :search_paths - - pod 'MKNetworkKit', '~> 0.87' - pod 'AFNetworking', '~> 2.4.1' - pod 'CocoaHTTPServer', '~> 2.2.1' - pod 'Kiwi', '~> 2.3.0' - pod 'ASIHTTPRequest', '>= 1.8.1' -end diff --git a/Podfile.lock b/Podfile.lock deleted file mode 100644 index 33db449f..00000000 --- a/Podfile.lock +++ /dev/null @@ -1,65 +0,0 @@ -PODS: - - AFNetworking (2.4.1): - - AFNetworking/NSURLConnection (= 2.4.1) - - AFNetworking/NSURLSession (= 2.4.1) - - AFNetworking/Reachability (= 2.4.1) - - AFNetworking/Security (= 2.4.1) - - AFNetworking/Serialization (= 2.4.1) - - AFNetworking/UIKit (= 2.4.1) - - AFNetworking/NSURLConnection (2.4.1): - - AFNetworking/Reachability - - AFNetworking/Security - - AFNetworking/Serialization - - AFNetworking/NSURLSession (2.4.1): - - AFNetworking/Reachability - - AFNetworking/Security - - AFNetworking/Serialization - - AFNetworking/Reachability (2.4.1) - - AFNetworking/Security (2.4.1) - - AFNetworking/Serialization (2.4.1) - - AFNetworking/UIKit (2.4.1): - - AFNetworking/NSURLConnection - - AFNetworking/NSURLSession - - ASIHTTPRequest (1.8.1): - - ASIHTTPRequest/ASIWebPageRequest (= 1.8.1) - - ASIHTTPRequest/CloudFiles (= 1.8.1) - - ASIHTTPRequest/Core (= 1.8.1) - - ASIHTTPRequest/S3 (= 1.8.1) - - ASIHTTPRequest/ASIWebPageRequest (1.8.1): - - ASIHTTPRequest/Core - - ASIHTTPRequest/CloudFiles (1.8.1): - - ASIHTTPRequest/Core - - ASIHTTPRequest/Core (1.8.1): - - Reachability - - ASIHTTPRequest/S3 (1.8.1): - - ASIHTTPRequest/Core - - CocoaAsyncSocket (0.0.1) - - CocoaHTTPServer (2.2.1): - - CocoaAsyncSocket (~> 0.0.1) - - CocoaLumberjack (~> 1.3.0) - - CocoaLumberjack (1.3.3) - - Kiwi (2.3.1) - - MKNetworkKit (0.87): - - Reachability (~> 3.1.0) - - Reachability (3.1.1) - -DEPENDENCIES: - - AFNetworking (~> 2.4.1) - - ASIHTTPRequest (>= 1.8.1) - - CocoaHTTPServer (~> 2.2.1) - - Kiwi (~> 2.3.0) - - MKNetworkKit (~> 0.87) - -SPEC CHECKSUMS: - AFNetworking: 41d45d2c14219af0fa5addf3cfd433a002c13c9f - ASIHTTPRequest: bf4f9b8be3526d40865d045bb664e0bab246fb81 - CocoaAsyncSocket: e2688ff99f2c2dbbeb95a1d02ba7dd878726ac83 - CocoaHTTPServer: 36f27f3fbc03d25a4fafcc22409a944c5bcf0d2d - CocoaLumberjack: 9c1e36cb5bf886ad691191f59871a11179c7c2aa - Kiwi: f038a6c61f7a9e4d7766bff5717aa3b3fdb75f55 - MKNetworkKit: 60ad3c83b62183e40ba75ce772c9427c25b520de - Reachability: dd9aa4fb6667b9f787690a74f53cb7634ce99893 - -PODFILE CHECKSUM: 6845bdf1d8a193a8186fdae487e0615d7037f7ba - -COCOAPODS: 1.0.1