Sha256: 0cd4bc02e85337d7e8ab641c9b8048283e643d1dd6f2c4022ea50fd772b3c639

Contents?: true

Size: 906 Bytes

Versions: 22

Compression:

Stored size: 906 Bytes

Contents

require "spec_helper"

describe Clearance::Testing::ControllerHelpers do
  class TestClass
    include Clearance::Testing::ControllerHelpers

    def initialize
      @request = Class.new do
        def env
          { clearance: Clearance::Session.new({}) }
        end
      end.new
    end
  end

  describe "#sign_in" do
    it "creates an instance of the clearance user model with FactoryBot" do
      MyUserModel = Class.new
      allow(FactoryBot).to receive(:create)
      allow(Clearance.configuration).to receive(:user_model).
        and_return(MyUserModel)

      TestClass.new.sign_in

      expect(FactoryBot).to have_received(:create).with(:my_user_model)
    end
  end

  describe "#sign_in_as" do
    it "returns the user if signed in successfully" do
      user = build(:user)

      returned_user = TestClass.new.sign_in_as user

      expect(returned_user).to eq user
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
clearance-2.9.2 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.9.1 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.9.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.8.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.7.2 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.7.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.6.2 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.6.1 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.6.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.5.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.4.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.3.1 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.3.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.2.1 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.2.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.1.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.0.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.0.0.beta2 spec/clearance/testing/controller_helpers_spec.rb
clearance-2.0.0.beta1 spec/clearance/testing/controller_helpers_spec.rb
clearance-1.17.0 spec/clearance/testing/controller_helpers_spec.rb