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.
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With