Last active
August 29, 2015 14:05
-
-
Save tunaranch/a9c3eddbbadc0b0c0b42 to your computer and use it in GitHub Desktop.
Isn't this how you simulate a Grails datepicker? (Grails 2.4.2)
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 g242 | |
import grails.converters.JSON | |
class PersonController { | |
def testPost(Person person){ | |
log.debug "JSONning ${person}" | |
render person as JSON | |
} | |
} |
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 g242 | |
import spock.lang.* | |
class PersonControllerIntSpec extends Specification { | |
PersonController controller | |
def setup(){ | |
controller = new PersonController() | |
} | |
void "posting dates to testPost()"() { | |
given: | |
controller.params.name = "Johnny" | |
controller.params.birthday = "date.struct" | |
controller.params.birthday_day = 3 | |
controller.params.birthday_month = 6 | |
controller.params.birthday_year = 1980 | |
controller.request.method = 'POST' | |
when: | |
controller.testPost() | |
then: | |
controller.response.json.birthday | |
/* Fails with: | |
Condition not satisfied: | |
controller.response.json.birthday | |
| | | | | |
| | | null | |
| | [id:null, birthday:null, name:Johnny, class:g242.Person] | |
| org.codehaus.groovy.grails.plugins.testing.GrailsMockHttpServletResponse@9b05ade | |
g242.PersonController@40bc4a46 | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changing
controller.params.birthday = "date.struct"
tocontroller.params.birthday = "struct"
fixes it.