Skip to content

Instantly share code, notes, and snippets.

@chrissie1
Created April 23, 2014 12:52
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 chrissie1/11214114 to your computer and use it in GitHub Desktop.
Save chrissie1/11214114 to your computer and use it in GitHub Desktop.
val data = listOf(
-1 to "one second ago",
-10 to "10 seconds ago",
-59 to "59 seconds ago",
-60 to "a minute ago",
1 to "one second from now",
10 to "10 seconds from now",
59 to "59 seconds from now",
60 to "a minute from now"
)
givenData("timeunit in seconds" ,data) {
val (input, excpected) = it
on("calling humanize with ${input}", {
val datetouse = GregorianCalendar(2014,Calendar.JANUARY, 5).getTime()
val (input, excpected) = it
val cal = GregorianCalendar()
cal.setTime(input)
cal.add(Calendar.SECOND, input)
val actual = cal.getTime().humanize(input)
it("should be ${expected}", {
shouldEqual(expected, actual)
})
})
}
@hhariri
Copy link

hhariri commented Apr 23, 2014

Yes, good but calling humanize on what?

@chrissie1
Copy link
Author

"calling humanize on Date comparing against inputdate ${input} seconds"

@chrissie1
Copy link
Author

Seems like I'm writing a book.

@hhariri
Copy link

hhariri commented Apr 23, 2014

given("current time")
on("calling humanize with ${input} in seconds") {
it("should give ${expected}")

Also, the datetouse should be defined in the given. The On should only contain the actual action. Everything that is setting up the context should be in given.

@chrissie1
Copy link
Author

So I need you to create a givenData with a description in Spek and then I'll make it work for you.

@hhariri
Copy link

hhariri commented Apr 23, 2014

IT also makes me realize we need to rename givenData and also maybe add annotation title.

@hhariri
Copy link

hhariri commented Apr 23, 2014

IT also makes me realize we need to rename givenData and also maybe add annotation title.

@hhariri
Copy link

hhariri commented Apr 23, 2014

IT also makes me realize we need to rename givenData and also maybe add annotation title.

@chrissie1
Copy link
Author

I get IT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment