Skip to content

Instantly share code, notes, and snippets.

@okaminu
Last active March 17, 2021 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okaminu/b29062bf7d15a4ea566d3b9ac1619cd9 to your computer and use it in GitHub Desktop.
Save okaminu/b29062bf7d15a4ea566d3b9ac1619cd9 to your computer and use it in GitHub Desktop.
package steps
import io.cucumber.scala.{EN, ScalaDsl}
class StepDefinitions extends ScalaDsl with EN {
val chickenCalculator: Option[ChickenCalculator] = None
val actualInsectCount: Option[Int] = None
Given("""a chicken collects {int} insects per minute""") { (insectsPerMinute: Int) =>
chickenCalculator = Some(new ChickenCalculator(insectsPerMinute))
}
When("""chicken has searched insects for {int} minutes""") { (minutes: Int) =>
actualInsectCount = chickenCalculator.map(_.searchInsects(minutes))
}
Then("""the chicken has found {int} insects""") { (expectedInsectCount: Int) =>
assert(actualInsectCount.nonEmpty, "No insects were found")
assert(actualInsectCount.get == expectedInsectCount, "Incorrect found insect count")
}
When("""chicken has searched insects for {int} hours""") { (hours: Int) =>
actualInsectCount = chickenCalculator.map(_.searchInsects(60 * hours))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment