Skip to content

Instantly share code, notes, and snippets.

@cavalle
Created August 25, 2010 10:46
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save cavalle/549262 to your computer and use it in GitHub Desktop.
Save cavalle/549262 to your computer and use it in GitHub Desktop.
Testing Warden/Devise with Steak
# Create a file `spec/acceptance/support/warden.rb' with the following
# contents:
Spec::Runner.configure do |config|
config.include Warden::Test::Helpers, :type => :acceptance
config.after(:each, :type => :acceptance) { Warden.test_reset! }
end
# Or, if you're using RSpec 2 / Rails 3, the contents should be the following
# instead:
RSpec.configure do |config|
config.include Warden::Test::Helpers, :type => :acceptance
config.after(:each, :type => :acceptance) { Warden.test_reset! }
end
# Then in your features you'll only need to call the `login_as` or `logout`
# methods. More info here: http://wiki.github.com/hassox/warden/testing
feature "Home page" do
background do
@user = User.create(...) # Or use fixtures, factories or whatever, even a
# stub user
login_as @user
visit home_page
end
# ...
end
@cavalle
Copy link
Author

cavalle commented Mar 5, 2011

Alternatively, it might be a better practice to just visit the login page and fill and send the form.

This Warden helpers might be handy if you're using some kind of external authentication like OpenID, OAuth, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment