public
Description: sample app used to figure out grails testing plugin
Homepage:
Clone URL: git://github.com/mjhugo/bookstore.git
bookstore / test / unit / PublisherTests.groovy
100644 24 lines (16 sloc) 0.656 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class PublisherTests extends grails.test.GrailsUnitTestCase {
 
    Publisher publisher
 
    void setUp() {
        super.setUp()
 
        // in testing-plugin 0.4 you can just do "mockForConstraintsTests(Book)" instead of these two lines
        registerMetaClass(Publisher)
        grails.test.MockUtils.prepareForConstraintsTests(Publisher, [new Publisher(name:'Appress')])
 
        publisher = new Publisher(name: 'Manning')
        assertTrue publisher.validate()
    }
 
    void testNameConstraint(){
        publisher.name = 'Appress'
        assertFalse publisher.validate()
        assertEquals "unique", publisher.errors["name"]
    }
 
 
}