Sha256: 18da3c3597e4e0e0db63e12d17586104a072545be1f5a0f19aaac2f83de5c9cc

Contents?: true

Size: 909 Bytes

Versions: 7

Compression:

Stored size: 909 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 FactoryGirl" do
      MyUserModel = Class.new
      allow(FactoryGirl).to receive(:create)
      allow(Clearance.configuration).to receive(:user_model).
        and_return(MyUserModel)

      TestClass.new.sign_in

      expect(FactoryGirl).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

7 entries across 7 versions & 1 rubygems

Version Path
clearance-1.16.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-1.15.1 spec/clearance/testing/controller_helpers_spec.rb
clearance-1.15.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-1.14.2 spec/clearance/testing/controller_helpers_spec.rb
clearance-1.14.1 spec/clearance/testing/controller_helpers_spec.rb
clearance-1.14.0 spec/clearance/testing/controller_helpers_spec.rb
clearance-1.13.0 spec/clearance/testing/controller_helpers_spec.rb