From edcf68ca48b9490f97c7e49da0ff1a03afec46a9 Mon Sep 17 00:00:00 2001 From: Tyler Thompson Date: Thu, 22 Apr 2021 08:51:19 -0600 Subject: [PATCH] [master] - rows on data tables are now public...how on earth was that not already true? - TT --- Sources/CucumberSwift/Gherkin/Parser/DataTable.swift | 2 +- .../CucumberSwiftConsumerTests.swift | 11 +++++++++++ .../Features/CucumberSwift.feature | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Sources/CucumberSwift/Gherkin/Parser/DataTable.swift b/Sources/CucumberSwift/Gherkin/Parser/DataTable.swift index 4a1ee427..a7178e70 100644 --- a/Sources/CucumberSwift/Gherkin/Parser/DataTable.swift +++ b/Sources/CucumberSwift/Gherkin/Parser/DataTable.swift @@ -9,7 +9,7 @@ import Foundation public class DataTable { public typealias Row = [String] - var rows = [Row]() + public var rows = [Row]() init(_ lines:[Row]) { rows = lines } diff --git a/Tests/CucumberSwiftConsumerTests/CucumberSwiftConsumerTests.swift b/Tests/CucumberSwiftConsumerTests/CucumberSwiftConsumerTests.swift index c02ad80f..e12fb692 100644 --- a/Tests/CucumberSwiftConsumerTests/CucumberSwiftConsumerTests.swift +++ b/Tests/CucumberSwiftConsumerTests/CucumberSwiftConsumerTests.swift @@ -119,6 +119,17 @@ extension Cucumber: StepImplementation { XCTAssert(true) } Given("^I point my step to a unit test$", class:Me.self, selector: #selector(Me.unitTestIsExecuted)) + Given("^a step with a data table$") { _, step in + guard let dataTable = step.dataTable else { + XCTFail("no data table found!") + return + } + XCTAssertEqual(dataTable.rows.count, 2) + XCTAssertEqual(dataTable.rows[0][0], "foo") + XCTAssertEqual(dataTable.rows[0][1], "bar") + XCTAssertEqual(dataTable.rows[1][0], "boz") + XCTAssertEqual(dataTable.rows[1][1], "boo") + } When("^I run the tests$") { _, step in XCTAssert(true) diff --git a/Tests/CucumberSwiftConsumerTests/Features/CucumberSwift.feature b/Tests/CucumberSwiftConsumerTests/Features/CucumberSwift.feature index e207960c..0a3daf1e 100644 --- a/Tests/CucumberSwiftConsumerTests/Features/CucumberSwift.feature +++ b/Tests/CucumberSwiftConsumerTests/Features/CucumberSwift.feature @@ -61,6 +61,13 @@ as expected When I run the tests Then The unit test runs + Scenario: Something with a data table + Given a step with a data table + | foo | bar | + | boz | boo | + When I run the tests + Then I can access the data table + Scenario: Unimplemented scenario with DocString Given a DocString of some kind that is not implemented """xml