Skip to content

Instantly share code, notes, and snippets.

@fearoffish
Created May 11, 2009 09:41
Show Gist options
  • Save fearoffish/109932 to your computer and use it in GitHub Desktop.
Save fearoffish/109932 to your computer and use it in GitHub Desktop.
# Rails 2.1, with latest shoulda
context "POST #create" do
context "with an existing email address" do
setup do
@user = Factory.create(:user)
post :create, :email => @user.email
end
should_respond_with :redirect
should_assign_to(:user) { @user }
context "when sending the password reset email" do
should "have the correct subject line" do
assert_sent_email do |email|
email.subject = 'Password Reset Instructions'
end
end
end
end
context "with an unknown email address" do
setup do
post :create, :email => 'unknown@email.com'
end
should_respond_with :success
should_render_template :new
should "not send any emails" do
# This test fails because it picks up the emails from the other test
assert_did_not_send_email
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment