spray / twirl

The Play framework Scala template engine, stand-alone and packaged as an SBT plugin
Apache License 2.0
215 stars 20 forks source link

Using twirl in integration tests #21

Open talkol opened 10 years ago

talkol commented 10 years ago

I'm trying to use twirl as part of my integration tests.

My integration tests have an HTTP simplicator that mimics a real world service. To implement this simplicator in the tests, I'm using spray-can embedded HTTP server which needs to spit out responses based on twirl templates.

My tests are located at /src/it/scala so naturally I want to place these twirl templates inside /src/it/twirl. This doesn't work since the twirl compiler ignores this directory.

If I place the twirl templates in /src/main/twirl, everything works fine - but I'm trying to avoid this because I don't want these templates to clutter the production package (the templates only come into play in the tests so they should only compile inside when the tests are run).

How can I tell the twirl compiler to look for templates in the new directory?

jrudolph commented 10 years ago

That's currently not supported. As a workaround you can look at the keys defined in https://github.com/spray/twirl/blob/master/sbt-twirl/src/main/scala/twirl/sbt/TwirlPlugin.scala and CnP and redefine all for the integration scope, i.e. copy all those settings that have in Compile and replace it with in IntegrationTest.