Skip to content

Instantly share code, notes, and snippets.

@mike-burns
Created June 25, 2010 14:00
Show Gist options
  • Save mike-burns/452881 to your computer and use it in GitHub Desktop.
Save mike-burns/452881 to your computer and use it in GitHub Desktop.
require 'test_helper'
class PostsTest < ActionController::IntegrationTest
def updating_a_post_successfully
user = Factory(:user)
i_am_signed_in_as(user)
post = Factory(:post, :user => user)
go_to(edit_post_path(post))
fill_in(:title, :with => 'Willard Scott')
press_button('Update')
assert_select '.flash', :text => 'Your post was updated successfully'
end
def updating_a_post_unsuccessfully
{:title => 'Awesome Post Name', :body => 'Awesome story'}.each do |field, value|
user = Factory(:user)
i_am_signed_in_as(user)
post = Factory(:post, :user => user)
go_to(edit_post_path(post))
fill_in(field, :with => '')
press_button('Update')
assert_select '.flash', :text => 'Your post was updated successfully', :count => 0
fill_in(field, :with => value)
press_button('Update')
assert_select '.flash', :text => 'Your post was updated successfully'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment