You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Listing is as follows:
Listing 3.3 Saving and retrieving a domain object from the database
package com.grailsinaction
import spock.lang.*
import grails.plugin.spock.*
class UserIntegrationSpec extends IntegrationSpec { #1
def "Saving our first user to the database"() {
given: "A brand new user"
def joe = new User(loginId: 'joe', password: 'secret',
homepage: 'http://www.grailsinaction.com')
when: "the user is saved" joe.save() #2
then: "it saved successfully and can be found in the database"
joe.errors.errorCount == 0 #3
joe.id != null #4
User.get(joe.id).userId == joe.userId #5
}
}
Last line should be:
User.get(joe.id).loginId == joe.loginId #5
test-app output before and after the above correction:
| Compiling 1 source files....
| Compiling 1 source files.....
| Running 1 spock test... 1 of 1
| Failure: Saving our first user to the database(com.grailsinaction.UserIntegrationSpec)
| groovy.lang.MissingPropertyException: No such property: userId for class: com.grailsinaction.User
at com.grailsinaction.UserIntegrationSpec.Saving our first user to the database(UserIntegrationSpec.groovy:19)
| Completed 1 spock test, 1 failed in 602ms
| Tests FAILED - view reports in C:\netscripts\smcccd\hubbub\target\test-reports
Yes, there are still several references to 'userId' in the MEAP. I have updated the manuscripts for chapters 3 & 6. Chapter 11 is already fixed, but that's not managed to get into the MEAP yet.
Listing is as follows:
Listing 3.3 Saving and retrieving a domain object from the database
package com.grailsinaction
import spock.lang.*
import grails.plugin.spock.*
class UserIntegrationSpec extends IntegrationSpec { #1
def "Saving our first user to the database"() {
given: "A brand new user"
def joe = new User(loginId: 'joe', password: 'secret',
homepage: 'http://www.grailsinaction.com')
when: "the user is saved" joe.save() #2
then: "it saved successfully and can be found in the database"
joe.errors.errorCount == 0 #3
joe.id != null #4
User.get(joe.id).userId == joe.userId #5
}
}
Last line should be:
User.get(joe.id).loginId == joe.loginId #5
test-app output before and after the above correction:
| Compiling 1 source files....
| Compiling 1 source files.....
| Running 1 spock test... 1 of 1
| Failure: Saving our first user to the database(com.grailsinaction.UserIntegrationSpec)
| groovy.lang.MissingPropertyException: No such property: userId for class: com.grailsinaction.User
at com.grailsinaction.UserIntegrationSpec.Saving our first user to the database(UserIntegrationSpec.groovy:19)
| Completed 1 spock test, 1 failed in 602ms
| Tests FAILED - view reports in C:\netscripts\smcccd\hubbub\target\test-reports
| Compiling 1 source files.....
| Compiling 1 source files.....
| Completed 1 spock test, 0 failed in 378ms
| Tests PASSED - view reports in C:\netscripts\smcccd\hubbub\target\test-reports
The text was updated successfully, but these errors were encountered: