Sha256: 91003672e741d7926ad01d2d2d791211e8fb414e1211df856c0912091d75afba

Contents?: true

Size: 859 Bytes

Versions: 7

Compression:

Stored size: 859 Bytes

Contents

require 'spec_helper'

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

    def initialize
      @controller = Controller.new
    end

    class Controller
      def sign_in(user); end
    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.10.1 spec/clearance/testing/helpers_spec.rb
clearance-1.9.0 spec/clearance/testing/helpers_spec.rb
clearance-1.8.1 spec/clearance/testing/helpers_spec.rb
clearance-1.8.0 spec/clearance/testing/helpers_spec.rb
clearance-1.7.0 spec/clearance/testing/helpers_spec.rb
clearance-1.6.1 spec/clearance/testing/helpers_spec.rb
clearance-1.6.0 spec/clearance/testing/helpers_spec.rb