Last active
March 17, 2021 19:17
-
-
Save okaminu/b29062bf7d15a4ea566d3b9ac1619cd9 to your computer and use it in GitHub Desktop.
This file contains 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
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