Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When testing, do I have to precompile assets every time I adjust Javascript files in Rails 3.2?

I'm trying to learn TDD and BDD and do it the right way. The stack I'm using ( or trying to use, Spork doesn't work with Guard for me) is Minitest-Guard-Spork-Capybara. I am focusing on Unit Tests for models and Specs for integration tests.

I have a lot of Ajax in this application. I just did a save_and_open_page on one of my tests and of course the page came up hideous of course, because it couldn't find any of the assets.

My question is, if I am to test JS functionality, do I have to precompile assets every single time in order to test them, or is there some way to have the pipeline default to dev mode for testing purposes.

I am certain this is a n00b question, but that's where I am with testing. Trying to do things right.

like image 788
AKWF Avatar asked Apr 30 '13 19:04

AKWF


2 Answers

No, you don't have to do it every single time. Just work in development environment (test environment?), production environment and precompiling is for public working system. In your environment for work there should be config.assets.compile = true.

like image 87
Danil Speransky Avatar answered Oct 25 '22 09:10

Danil Speransky


You don't need to compile the assets, actually you don't need to do anything at all. save_and_open_page works differently and doesn't load your assets so don't be scared if everything looks ugly, your capybara tests still works fine with javascript without any changes in the setup of the test environment.

However you have to setup capybara and mini test to work with javascript, and remember to tag your specs to activate javascript.

like image 24
jokklan Avatar answered Oct 25 '22 09:10

jokklan