Skip to content

Instantly share code, notes, and snippets.

Embed
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) }
end
post = Post.first
find(post).click_link("Hello")
within post do
fill_in("What's going on here", :with => "Holy shit this works??")
click_button("Yes")
end
@andrewhr

This comment has been minimized.

Copy link

@andrewhr andrewhr commented Nov 14, 2012

❤️

@gmile

This comment has been minimized.

Copy link

@gmile gmile commented Nov 14, 2012

Maybe?

Capybara.add_selector :post
@jnicklas

This comment has been minimized.

Copy link
Owner Author

@jnicklas jnicklas commented Nov 14, 2012

@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.

@colszowka

This comment has been minimized.

Copy link

@colszowka colszowka commented Nov 14, 2012

Awesome :)

@jipiboily

This comment has been minimized.

Copy link

@jipiboily jipiboily commented Nov 14, 2012

🍻

@dcaliri

This comment has been minimized.

Copy link

@dcaliri dcaliri commented Nov 14, 2012

nice

@Hakon

This comment has been minimized.

Copy link

@Hakon Hakon commented Nov 14, 2012

@JuarezLustosa

This comment has been minimized.

Copy link

@JuarezLustosa JuarezLustosa commented Nov 14, 2012

\o/

@thiagofm

This comment has been minimized.

Copy link

@thiagofm thiagofm commented Nov 14, 2012

nice

@sush

This comment has been minimized.

Copy link

@sush sush commented Nov 14, 2012

Awesome ❤️

@pcreux

This comment has been minimized.

Copy link

@pcreux pcreux commented Nov 15, 2012

😻

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