Created
November 5, 2013 18:16
-
-
Save jwo/7323530 to your computer and use it in GitHub Desktop.
RSpec controller testing devise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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