title: Scala / Lift: How do I write unit tests that test a snippet's response to different parameters
body: <p>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.</p>
  
  <p>For instance, with the snippet callout in this div:</p>
  
  <pre><code>&lt;div class="lift:Snippet.method?param1=foo"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I'm passing the parameter param1 to the snippet. My snippet would look something like this:</p>
  
  <pre><code>class Snippet {
    def method(in:NodeSeq):NodeSeq = {
      val param1 = S.attr("param1") openOr ""
      param1 match {
        case "foo" =&gt; //do something
        case "bar" =&gt; //do something else
        case _ =&gt; //do yet another thing
      }
    }
  }
  </code></pre>
  
  <p>So within my test, I want to test how the snippet responds to different param1 values</p>
  
  <pre><code>class SnippetTest extends Specification {
    "Snippet" should {
      "do something" in {
        val html = &lt;ul&gt;
            &lt;li class="first"&gt;
            &lt;li class="second"&gt;
            &lt;li class="third"&gt;
          &lt;/ul&gt;
  
        //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"
      }
    }
  }
  </code></pre>
  
  <p>How do I set param1?</p>
  
  <p>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.</p>
  
  <p>Thanks,</p>
  
  <p>Blake</p>