Skip to content

Instantly share code, notes, and snippets.

@schneems
Created January 16, 2012 14:11
Show Gist options
  • Select an option

  • Save schneems/1621039 to your computer and use it in GitHub Desktop.

Select an option

Save schneems/1621039 to your computer and use it in GitHub Desktop.
Devise stubbing in action
let(:user) { Factory.create(:user) }
# To use the methods you can call
# methods directly on them like this:
scenario 'works while logged in' do
as_user(user).visit teach_path
# ...
# Or you can pass the code you wish
# to run in a block:
scenario 'creating a class' do
as_user(user) do
visit teach_path
click_link('Create')
current_path.should == new_course_path
fill_in 'course_title', :with => course_stub.title
fill_in 'course_teaser', :with => course_stub.teaser
fill_in 'course_experience', :with => course_stub.experience
click_button 'Submit'
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment