ActionView::Template::Error: end of file reached Rails 4.0.4

I have an application I’m migrating from Rails 3.2 to 4.0. On my CI environment, I’m getting “ActionView::Template::Error: end of file reached” randomly in different controller specs pointing to a view in which I have “javascript_include_tag ‘application’”. Has anyone seen this before? Relevant gems:

rails (4.0.4)

sprockets (2.11.0)

sprockets-rails (2.0.1)

sass-rails (4.0.2)

coffee-rails (4.0.1)

We are having the exact same problem: We upgraded from Rails 3 to 4 and have started seeing these. We're running Capybara with PhantomJS and Cucumber.

We get intermittent "ActionView::Template::Error: end of file reached" errors, and have been since we upgraded to Rails 4. We are running spring in :development but not in :test (and Spring is causing weird problems, too, but they aren't related).

    rails (4.0.4)       actionmailer (= 4.0.4)       actionpack (= 4.0.4)       activerecord (= 4.0.4)       activesupport (= 4.0.4)       bundler (>= 1.3.0, < 2.0)       railties (= 4.0.4)       sprockets-rails (~> 2.0.0)     sprockets (2.12.0)       hike (~> 1.2)       multi_json (~> 1.0)       rack (~> 1.0)       tilt (~> 1.1, != 1.3.0)   sass-rails (~> 4.0.1)     coffee-rails (4.0.1)       coffee-script (>= 2.2.0)       railties (>= 4.0.0, < 5.0)     coffee-rails-source-maps (1.4.0)       coffee-script-source (>= 1.6.1)     coffee-script (2.2.0)       coffee-script-source       execjs

There is this Sprockets PR that we created trying to solve this issue fix file store by adding an atomic write and rescuing failures by rubemz · Pull Request #545 · sstephenson/sprockets · GitHub . Still WIP, but we would appreciate any feedback.