Skip to content

Instantly share code, notes, and snippets.

@jwo
Created November 5, 2013 18:16
Show Gist options
  • Save jwo/7323530 to your computer and use it in GitHub Desktop.
Save jwo/7323530 to your computer and use it in GitHub Desktop.
RSpec controller testing devise
require 'spec_helper'
describe SecretController do
let(:user) { User.create! email: "[email protected]",
password: "the-secrets",
password_confirmation: "the-secrets"
}
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
end
it "logged in should get show" do
sign_in user
get :show
response.should be_success
end
it "not authenticated should get redirect" do
get :show
response.should be_redirect
end
end
# include in the RSpec.config block
config.include Devise::TestHelpers, :type => :controller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment