Headless && Head OK

June 15, 2012 Brian Cunnie

Helps

  • asset pipeline testing with RSpec render_views

I’m trying to test the asset pipeline configuration in our project. I’ve tweaked our test environment to it won’t automatically compile assets;

environments/test.rb:

if ENV[‘ASSET_PIPELINE’]
config.assets.compile = false
else
config.assets.compile = true
end

alas in controller specs that have render_views, breaks:

ActionView::Template::Error:
controllers/application.js isn’t precompiled.

(which is not true)

in most cases I can remove render_views, but that’s not ideal.

To fix it, make sure digest is true.

  • capybara-webkit + headless + lobot CI => Locking assertion failure

Tried sloppy locking and downgrading libx11 to 1.0.3, but no success.

Probably a Qt error, make sure Qt is 4.8.1 or 4.8.2 or try recompiling Qt or dependencies.

Interestings

  • rake db:test:prepare with spork

We got frustrated having to shut down spork every time we wanted to run a migration.

We dug in, and found that we needed to close the ActiveRecord::Base connections in the prefork block. ActiveRecord automatically reestablishes the connection post fork.

We opened a pull request on spork-rails with the fix:
https://github.com/sporkrb/spork-rails/pull/9

  • javascript:

Chrome and other browsers are now stripping out ‘javascript:’ from the beginning of urls that are pasted into the addressbar. This is not a problem with links that start with ‘javascript:’

  • Head OK, empty body, JQuery == bad mixture

“Head OK” with an empty body returns a single space & confuses JQuery because a single-space string is invalid JSON. A work-around is to set the content-type to NOT be application/json. Or render :text => ” or render :json => {}

About the Author

Biography

More Content by Brian Cunnie
Previous
Birchbox is looking for experienced RoR Engineers
Birchbox is looking for experienced RoR Engineers

At Pivotal Labs, one of the services we provide our clients is helping them interview and hire. Pivotal Lab...

Next
Simplifying View-View Events in Backbone using the Mediator Pattern
Simplifying View-View Events in Backbone using the Mediator Pattern

In most single-page apps, you will inevitably end up having multiple views on one page at a time. It usuall...

Enter curious. Exit smarter.

Learn More