Sha256: 261df21b0aab1d3bd69dfe759907aa79205d13394d8b4741baabbc4ce7841a06

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require "rails_helper_for_engine"

RSpec.describe Omniauth::Rails::ApplicationHelper do
  describe ".authenticated_email" do
    context "authenticated user" do
      let(:email) { "foo@bar.com" }

      before do
        expect(helper).to receive(:authenticated?).and_return(true)

        fake_session = {}
        data_store = Omniauth::Rails::AuthenticationDataStore.new(fake_session)
        data_store.set("email", email)
        expect(Omniauth::Rails::AuthenticationDataStore).to receive(:new).and_return(data_store)

        expect(helper).to receive(:authentication_session).and_return(authentication_session)
      end

      it "returns the email address" do
        expect(helper.authenticated_email).to eq(email)
      end
    end

    context "unauthenticated user in dev_mode" do
      before do
        expect(helper).to receive(:authenticated?).and_return(false)

        @original_value_dev_mode = Omniauth::Rails::Configuration.dev_mode
        Omniauth::Rails::Configuration.dev_mode = true
      end

      after do
        Omniauth::Rails::Configuration.dev_mode = @original_value_dev_mode
      end

      it "the correct string" do
        expect(helper.authenticated_email).to eq("[not logged in - dev mode]")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
omniauth-rails-0.6.0 spec/helpers/application_helper_spec.rb
omniauth-rails-0.5.0 spec/helpers/application_helper_spec.rb
omniauth-rails-0.4.0 spec/helpers/application_helper_spec.rb
omniauth-rails-0.3.0 spec/helpers/application_helper_spec.rb