Skip to content

Commit

Permalink
Merge pull request #78 from Hsilgos/fix_unit_test_localisation
Browse files Browse the repository at this point in the history
Fixes unit tests on non-en localised machine
  • Loading branch information
Tyler-Keith-Thompson authored Feb 12, 2023
2 parents 1939b21 + 6fcf3b3 commit f44796a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/CucumberSwift/StubGeneration/Method.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ class Method {
var methodString = "\(keywordString.capitalizingFirstLetter())(\"^\(regex.trimmingCharacters(in: .whitespacesAndNewlines))$\") { \(matchesParameter), \(stepParameter) in\n"
for variable in variables {
for i in 0..<variable.count {
let spelledNumber = (i > 0) ? NumberFormatter.localizedString(from: .init(value: i + 1),
number: .spellOut) : ""
let formatter = NumberFormatter()
formatter.numberStyle = .spellOut
formatter.locale = Locale(identifier: "en-US")
let spelledNumber = (i > 0) ? formatter.string(from: .init(value: i + 1)) ?? "" : ""
let varName = "\(variable.type) \(spelledNumber)".camelCasingString()
if variable.type != "dataTable" && variable.type != "docString" {
methodString += " let \(varName) = \(matchesParameter)[\(i + 1)]\n"
Expand Down

0 comments on commit f44796a

Please sign in to comment.