(first posted: May 29, 2007)
(8766 Reads)
keywords: restful authentication rspec
Permalink
Rspec 1.0 and Restful Authentication
I've started using RSpec on Rails for spec'ing (aka testing). More about that in a separate post (I haven't had time to write up a walkthrough of my great experience with it).
Anyway, my project uses restful_authentication plugin so I started looking around and found a set of spec files for it on Jonathan.inspect blog but they're out of date with regard to the the Rspec 1.03 API.
I've updated the files. I didnt make any changes to the code except what was needed to make it work with the current API. (In fact, for example, I did not change "context" to "describe" or "specify" to "it"). Here they are:
The zip includes the files
- user_spec.rb : User model specs
- user_notifier_spec.rb : UserNotifier model specs
- user_observer_spec.rb : UserObserver model specs
- users_controller_spec.rb : Users controller specs
- sessions_controller_spec.rb : Sessions controller specs
Per Jonathan,
You should also add :
def set_mailer_in_test
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
end
to Spec::Rails::EvalContext class in your spec_helper.rb.




Rspec 1.0 and Restful Authentication
Posted by: David Chelimsky on May 29, 2007 10:57 PMmodule Helpers #can be named anything def set_mailer_in_test ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] end end Spec::Runner.configure do |config| config.include Helpers end#