Skip to content

Instantly share code, notes, and snippets.

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@jkongie
jkongie / polymorphic_factory.rb
Created March 1, 2010 05:53
Factory Girl - Polymorphic Factory
# Setting up a polymorphic factory for a join table
# Since rosterable is not the default name of the model we are calling, we can't use the convenience method
# that is used for area (f.association)
# All we have to do is fall back to the block way of doing it, calling f.rosterable and passing in the
# object you want to populate it with ( in this case a template). This will fill in both rosterable_id
# and rosterable_type for us
Factory.define(:template_rostered_area, :class => RosteredArea) do |f|
f.association :area
f.rosterable { |a| a.association(:template)}