sporkrb / spork

A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state.
spork.rubyforge.org
MIT License
1.4k stars 188 forks source link

Rails caches views in test environment by default #4

Closed eugenebolshakov closed 14 years ago

eugenebolshakov commented 14 years ago

And so changes you make in you views after spork is loaded are not hooked up.

config.action_view.cache_template_loading should be set to "false" in confing/environments/test.rb (and config/environments/cucumber.rb if you have that).

Maybe the instruction should be added to the README.

eugenebolshakov commented 14 years ago

The setting is available in rails 2.3 http://bit.ly/Nnasy. AFAIK in earlier versions templates are eager loaded if config.cache_classes is set to "true", which is required to use cucumber http://bit.ly/Hrc57. So there does not seem to be an easy way to disable that for cucumber in rails < 2.3.

timcharper commented 14 years ago

Thank you for reporting this, this is a very sensible default. Spork should definitely handle this out of the box - it already prevents the app from pre-loading.

timcharper commented 14 years ago

I just released Spork 0.5.7 which addresses this issue.

See the link below:

http://github.com/timcharper/spork/blob/ce042d5e6dff676e0394cd4b5b28199a5700dea2/lib/spork/app_framework/rails.rb#L97

Basically, rather than forcing cache_classes to be false, or cache_template_loading to be false, I 'trapped' the method responsible for eager loading views so it would just be delayed until after the fork.

Tested and passed in rails 2.3.2, 2.2.2, 2.1.2, 2.0.5