[LRUG] Fwd: Testing JS in Rails 4

Murray Steele murray.steele at gmail.com
Wed Jul 31 07:32:45 PDT 2013


On 31 July 2013 15:05, James Coglan <jcoglan at gmail.com> wrote:

> On 31 July 2013 11:34, Murray Steele <murray.steele at gmail.com> wrote:
>
>> Could you customise the digest mechanism in sprockets to produce empty
>> (or knowable) digest suffixes.  Of course, you'd only want this for the JS
>> test run, so you're not testing your exact production files, but you're
>> testing something very close to it.
>>
>
> I'm not sure how to do this, and Rails 4 seems to have a bunch of stuff
> hard-coded that's not configurable (e.g. it minifies code in production but
> not development and none of the config flags for this change anything).
> Where are the docs?
>

I don't know that you actually *can* do this, but I'd hope that worst-case
you could use a massive monkey-patch hammer.  Spelunking sprockets-rails
might be you best bet.  Unfortunately.


>   Alternatively, could you asset compile the JS test harness so that it
> has the digested asset names in it?
>
> That's not a bad idea, and will work with a few test runners. Compile the
> code and tests into one static JS file, stick it on a web page, and have it
> run. Still probably requires the build target to have a stable un-digest-ed
> name in order to be easy to use. Or, you could run `cat
> public/assets/test-*.js > public/assets/test.js` after compiling.
>

Also that you rm public/assets/test-*.js so you don't end up concating
multiple versions.  But this seems like it might be the least painful
approach.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130731/e66491da/attachment-0003.html>


More information about the Chat mailing list