I'm trying to write a Specs2 test that will test a snippet's output in response to different parameters which would normally be passed in from a template, but I haven't been able to figure out how to do it.
For instance, with the snippet callout in this div:
<div class="lift:Snippet.method?param1=foo"></div>
I'm passing the parameter param1 to the snippet. My snippet would look something like this:
class Snippet {
def method(in:NodeSeq):NodeSeq = {
val param1 = S.attr("param1") openOr ""
param1 match {
case "foo" => //do something
case "bar" => //do something else
case _ => //do yet another thing
}
}
}
So within my test, I want to test how the snippet responds to different param1 values
class SnippetTest extends Specification {
"Snippet" should {
"do something" in {
val html = <ul>
<li class="first">
<li class="second">
<li class="third">
</ul>
//I need to set param1 here somehow
val out = Snippet.method(html)
//then check that it did what it was supposed to
out.something must be "xyz"
}
}
}
How do I set param1?
I am a big time scala and lift newb (coming from python+django), so if I'm barking up the wrong tree, please direct me to the right one. I think that might be the case, I've been googling on this all day and haven't found any questions remotely similar to this one.
Thanks,
Blake