Sha256: c066e02fcfbeb1bb7ca6552cddbd2fe6a268ed3db9ffa7a0d4de99b3692447e8

Contents?: true

Size: 936 Bytes

Versions: 3

Compression:

Stored size: 936 Bytes

Contents

describe SessionsController, :omniauth do

  before do
    request.env['omniauth.auth'] = auth_mock
  end

  describe "#create" do

    it "creates a user" do
      expect {post :create, provider: :twitter}.to change{ User.count }.by(1)
    end

    it "creates a session" do
      expect(session[:user_id]).to be_nil
      post :create, provider: :twitter
      expect(session[:user_id]).to_not be_nil
    end

    it "redirects the user to the user profile" do
      post :create, provider: :twitter
      expect(response).to redirect_to edit_user_path(1)
    end

  end

  describe "#destroy" do

    before do
      post :create, provider: :twitter
    end

    it "resets the session" do
      session[:user_id].should_not be_nil
      delete :destroy
      expect(session[:user_id]).to be_nil
    end

    it "redirects to the home page" do
      delete :destroy
      expect(response).to redirect_to root_url
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_apps_testing-0.3.2 lib/generators/testing/configure/templates/spec/omniauth/controllers/sessions_controller_spec.rb
rails_apps_testing-0.3.1 lib/generators/testing/configure/templates/spec/omniauth/controllers/sessions_controller_spec.rb
rails_apps_testing-0.3.0 lib/generators/testing/configure/templates/spec/omniauth/controllers/sessions_controller_spec.rb