Skip to content

Instantly share code, notes, and snippets.

@r38y
Created August 18, 2009 20:42
Show Gist options
  • Save r38y/169948 to your computer and use it in GitHub Desktop.
Save r38y/169948 to your computer and use it in GitHub Desktop.
# enqueue two emails to be sent later
UserMailer.send_later(:deliver_new_enrollment, @user, @offering.course, course_url(@offering.course.permalink))
UserMailer.send_later(:deliver_new_user, @user, @user.password)
# test that they are being sent the right arguments and being enqueued
# both tests are failing with the expectation of the other one.
# any suggestions on how I should spec this?
it "should send a new user email to the user" do
UserMailer.should_receive(:send_later).once.with(:deliver_new_user, @new_user, @new_user.password)
do_post
end
it "should send a new enrollment email to the user" do
UserMailer.should_receive(:send_later).once.with(:deliver_new_enrollment, @new_user, @course, course_url(@course.permalink))
do_post
end
1)
Spec::Mocks::MockExpectationError in 'Admin::UsersController handling POST /admin/users should send a new user email to the user'
<UserMailer (class)> expected :send_later with (:deliver_new_user, #<User:0x212ff6e @name="User_1031">, "password") but received it with (:deliver_new_enrollment, #<User:0x212ff6e @name="User_1031">, #<Course:0x21320d4 @name="Course_1030">, "http://test.host/courses/1030")
/forge38/clients/extra_credit/kotter/app/controllers/admin/users_controller.rb:20:in `create'
./spec/controllers/admin/users_controller_spec.rb:61:in `do_post'
./spec/controllers/admin/users_controller_spec.rb:71:
2)
Spec::Mocks::MockExpectationError in 'Admin::UsersController handling POST /admin/users should send a new enrollment email to the user'
<UserMailer (class)> expected :send_later with (:deliver_new_enrollment, #<User:0x211151e @name="User_1036">, #<Course:0x2114c5a @name="Course_1035">, "http://test.host/courses/1035") but received it with (:deliver_new_user, #<User:0x211151e @name="User_1036">, "password")
/forge38/clients/extra_credit/kotter/app/controllers/admin/users_controller.rb:21:in `create'
./spec/controllers/admin/users_controller_spec.rb:61:in `do_post'
./spec/controllers/admin/users_controller_spec.rb:76:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment