GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / web / taglib / GroovyGrepTagTests.groovy
blobdedeeae583f7d1d1279329d645358a15e9a098af
1 package org.codehaus.groovy.grails.web.taglib;
4 class GroovyGrepTagTests extends GroovyTestCase {
6 void testDoStartTag() {
7 def sw = new StringWriter()
9 def tag = new GroovyGrepTag()
10 tag.init(out: new PrintWriter(sw))
12 try {
13 tag.doStartTag()
14 fail("Should throw exception for required attributes")
16 catch(Exception e) {
17 // expected
20 tag.setAttributes('"in"': 'test', '"filter"':'\${~/regex/}')
22 tag.doStartTag();
24 assert sw.toString().startsWith("test.grep(~/regex/).each {")
28 void testWithStatus() {
29 def sw = new StringWriter()
31 def tag = new GroovyGrepTag()
32 tag.init(out: new PrintWriter(sw))
34 tag.setAttributes('"in"': 'test', '"filter"':'\${~/regex/}','"status"':"i",'"var"':"t")
36 tag.doStartTag();
38 assertEquals( "test.grep(~/regex/).eachWithIndex { t,i ->"+System.getProperty("line.separator"), sw.toString() )