This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_cancellAllTasks_givenExistsActiveTasks_shouldCancellAllOfThem() { | |
let sut = Network( parameters ... ) | |
sut.session.dataTask(with: URL(fileURLWithPath: "lorem/ipsum")).resume() | |
sut.session.dataTask(with: URL(fileURLWithPath: "foo/bar")).resume() | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func cancelAllTasks() { | |
session.getAllTasks { tasks in | |
tasks.forEach { $0.cancel() } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.log | |
func given<A>(_ description: String, block: () throws -> A) rethrows -> A { | |
os_log("1º Given %{public}@", description) | |
return try XCTContext.runActivity(named: "Given " + description, block: { _ in try block() }) | |
} | |
func when<A>(_ description: String, block: () throws -> A) rethrows -> A { | |
os_log("2º When %{public}@", description) | |
return try XCTContext.runActivity(named: "When " + description, block: { _ in try block() }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_Validation_Case_1() { | |
given("valueA is false, valueB is true and valueC is false") { | |
let a = false | |
let b = true | |
let c = false | |
when("validation is called") { | |
sut.validation(valueA: a, valueB: b, valueC: c) | |
then("should call setup method passing a, b and c."){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func given<A>(_ description: String, block: () throws -> A) rethrows -> A { | |
return try XCTContext.runActivity(named: "Given " + description, block: { _ in try block() }) | |
} | |
func when<A>(_ description: String, block: () throws -> A) rethrows -> A { | |
return try XCTContext.runActivity(named: "When " + description, block: { _ in try block() }) | |
} | |
func then<A>(_ description: String, block: () throws -> A) rethrows -> A { | |
return try XCTContext.runActivity(named: "Then " + description, block: { _ in try block() }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_Validation_Case_1() { | |
given("valueA is false, valueB is true and valueC is false") { _ in | |
let a = false | |
let b = true | |
let c = false | |
when("validation is called") { _ in | |
sut.validation(valueA: a, valueB: b, valueC: c) | |
then("should call setup method passing a, b and c."){ _ in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func given<A>(_ description: String, block: (XCTActivity) throws -> A) rethrows -> A { | |
return try XCTContext.runActivity(named: "Given " + description, block: block) | |
} | |
func when<A>(_ description: String, block: (XCTActivity) throws -> A) rethrows -> A { | |
return try XCTContext.runActivity(named: "When " + description, block: block) | |
} | |
func then<A>(_ description: String, block: (XCTActivity) throws -> A) rethrows -> A { | |
return try XCTContext.runActivity(named: "Then " + description, block: block) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_Validation_Case_1() { | |
XCTContext.runActivity(named: "Given valueA is false, valueB is true and valueC is false") { _ in | |
let a = false | |
let b = true | |
let c = false | |
XCTContext.runActivity(named:"When validation is called") { _ in | |
sut.validation(valueA: a, valueB: b, valueC: c) | |
XCTContext.runActivity(named:"Then should call setup method passing a, b and c."){ _ in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension XCTContext { | |
/// Create and run a new activity with provided name and block. | |
public class func runActivity<Result>(named name: String, block: (XCTActivity) throws -> Result) rethrows -> Result | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TableOfContentsSpec: QuickSpec { | |
override func spec() { | |
describe("the 'Documentation' directory") { | |
it("has everything you need to get started") { | |
let sections = Directory("Documentation").sections | |
expect(sections).to(contain("Organized Tests with Quick Examples and Example Groups")) | |
expect(sections).to(contain("Installing Quick")) | |
} | |
context("if it doesn't have what you're looking for") { |