Skip to content

Instantly share code, notes, and snippets.

@teigen
Created September 16, 2009 09:04
Show Gist options
  • Save teigen/187942 to your computer and use it in GitHub Desktop.
Save teigen/187942 to your computer and use it in GitHub Desktop.
package cuke4duke
/*
static typing to the rescue :-)
scala version of http://wiki.github.com/aslakhellesoy/cucumber/step-argument-transforms
note that this version doesn't need the 'user' hint
since we can provide the same hint using types in the stepdefinition
*/
class ConvertTest extends ScalaDsl {
/* user stuff */
class User(name: String) {
def friends_with(user: User): Boolean = true
}
object User {
def find_by_username(name: String): Option[User] = null
}
var user: User = _
/* the conversion, called Transformed in the ruby verison */
convert[User](name => User.find_by_username(name))
Then("""^(\w+) should be friends with (\w+)$""") { (user: User, friend: User) =>
assert(user.friends_with(friend))
}
/*
# feature file
Scenario: friend'ing
Given ...
When ...
Then larrytheliquid should be friends with dastels
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment