Skip to content

Instantly share code, notes, and snippets.

Created November 14, 2012 12:40
  • Star 37 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
post = Post.first
within post do
fill_in("What's going on here", :with => "Holy shit this works??")
Copy link


Copy link

gmile commented Nov 14, 2012


Capybara.add_selector :post

Copy link

@gmile, it works with any ActiveRecord instance, not just Posts. That's the beauty of it. In fact it could be made to work with anything that works with dom_id, not just ActiveRecord, but I'm too lazy to figure out how.

Copy link

Awesome :)

Copy link


Copy link

dcaliri commented Nov 14, 2012


Copy link

Hakon commented Nov 14, 2012

Copy link


Copy link


Copy link

sush commented Nov 14, 2012

Awesome ❤️

Copy link

pcreux commented Nov 15, 2012


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment