Skip to content

Instantly share code, notes, and snippets.

View okaminu's full-sized avatar

Aurimas Degutis okaminu

View GitHub Profile
@okaminu
okaminu / GreeterSpec.scala
Last active October 1, 2020 07:48
Pirate Greeter Spec
class GreeterSpec extends org.specs2.mutable.Specification {
"Should greet like a pirate" >> {
Greeter.greet(true) must beEqualTo("Ahoy")
}
}
object Greeter {
def greet(likeAPirate: Boolean): String = if (likeAPirate) "Ahoy" else "Hello"
}
object Greeter {
def greet(likeAPirate: Boolean, age: Some[Int]): String =
if (likeAPirate && age.nonEmpty) {
if (age.get >= 18) "Care to join for a bottle of rum ?" else "Ahoy"
} else "Hello"
}
class Numbers {
def greaterThan(a: Int, b: Int): Boolean = {
a > b
// Mutant 1: a >= b
// Mutant 2: a < b
// Mutant 3: a == b
}
}
class Numbers {
def greaterThan(a: Int, b: Int): Boolean = {
sys.env.get("ACTIVE_MUTATION") match {
case Some("0") =>
a >= b
case Some("1") =>
a < b
case Some("2") =>
a == b
case _ =>
Feature: Answerer that knows everything about chickens
Scenario: Answers why did robot chicken cross the road
Given there is a answerer
And there is a user
When user asks the answerer "Why did the robot chicken cross the road?"
Then the answerer replies "Because it was programmed to"
Feature: Answerer that knows everything about chickens
Scenario: Answers why did the chicken cross the road
Given there is a answerer
And there is a user
When user asks the answerer "Why did the chicken cross the road?"
Then the answerer replies "Because it wanted to fix a bug in the robot chicken"
Feature: Answerer that knows everything about chickens
Background:
Given there is a answerer
And there is a user
Scenario: Answers why did robot chicken cross the road
When user asks the answerer "Why did the robot chicken cross the road?"
Then the answerer replies "Because it was programmed to"
Scenario: Answers why did the chicken cross the road
Feature: Answerer that knows everything about chickens
Scenario Outline:
Given there is a answerer
And there is a user
When user ask the answerer <question>
Then the answerer replies <answer>
Examples:
| question | answer |
| "Why did the robot chicken cross the road?" | "Because it was programmed to"|
Feature: Chicken Finds Insects
Scenario Outline:
Given there is a <type> chicken
When chicken has searched insects for <minutes> minutes
Then the chicken has found <insectCount> insects
Examples:
| type | minutes | insectCount |
| regular | 1 | 3 |
| regular | 10 | 30 |