Scripts files required after spec executed
gregolsen opened this issue · 8 comments
Please, see this mailing list for more info http://groups.google.com/group/ruby-evergreen/browse_thread/thread/83f85115487b6a6c
Basically, what's going on is that when spec executed scripts, that added to page using require evergreen method are not loaded yet. It's seems like the problem is in the require method that use just document.write without waiting for script to be loaded on the page.
Have seen this problem too. It actually causes one of Evergreen's specs to randomly fail. I think we should integrate Sprockets properly into Evergreen, that way we can solve both this problem as well as properly integrating with the Rails 3.1 asset pipeline.
While integrating with asset pipeline and sprockets might be a good idea, I'm thinking of another one:
Maybe it will be better to run specs on window.onload - in this case we guarantee that all scripts are properly loaded.
So that require methods executed immediately, adding necessary scripts on the page. But specs are wrapped into window.onload. IMHO it's even a 'must' to run specs on window.onload in any case.
Does it makes any sense?
makes perfect sense! Do you want to provide a pull request?
Ok, I'll get familiar with the evergreen code and will think how it can be done.
Just changed it to use window.addEventListener to attach a load event, with a work-around for old IE versions. Unfortunately I don't have a windows VM lying around, so if someone could test that this works as expected, especially in IE 8 and below, that would be fantastic.
Hey, thanks for that fix.
I've made a pull request with a small fix for IE ('onload' should be used) and now it's working on IE. I've tested on real machine with IE8, also in IE7 compatibility mode works fine.
Also here's rails 3.1 test app so that anybody can verify if everything working properly.
Closing this issue then!
The version on rubygems still shows this problem -- wanna tick the version?