//// //// ApiTests.swift //// Api //// //// Created by Mauro Bender on 13/8/16. //// Copyright © 2016 CocoaPods. All rights reserved. //// import Quick import Nimble import Mockingjay import Api class ApiTests: QuickSpec { override func setUp() { super.setUp() // Register stubs stub( matchApiPath( "tests/get", method: .GET ), builder: http( 200 ) ) stub( matchApiPath( "tests/delete", method: .DELETE ), builder: http( 200 ) ) } override func spec() { describe( "Api" ) { let api = Api( baseURL: baseURL, apiPath: apiPath ) describe( "resource" ) { let resource : Resource = api.resource( "items" ) it( "should have the correct api" ) { expect( resource.api ) == api } it( "should have the correct path" ) { expect( resource.path ) == "items" } } describe( "request" ) { it( "should call the correct endpoint with the correct method" ) { waitUntil { done in api.request( .DELETE, path: "tests/delete" ) { result in done() } } } } describe( "get" ) { it( "should call the correct endpoint" ) { waitUntil { done in api.get( "tests/get" ) { result in done() } } } } } } }