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
))
14 fail("Should throw exception for required attributes")
20 tag
.setAttributes('"in"': 'test', '"filter"':'\${~/regex/}')
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")
38 assertEquals( "test.grep(~/regex/).eachWithIndex { t,i ->"+System
.getProperty("line.separator"), sw
.toString() )