Sha256: ba14317f3e4412c0d9da7d68e37334eee7013c3ba7d74a833b4838732fe208fd

Contents?: true

Size: 814 Bytes

Versions: 6

Compression:

Stored size: 814 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
      FactoryGirl.stubs(:create)
      Clearance.configuration.stubs(user_model: 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

6 entries across 6 versions & 1 rubygems

Version Path
clearance-1.5.1 spec/clearance/testing/helpers_spec.rb
clearance-1.5.0 spec/clearance/testing/helpers_spec.rb
clearance-1.4.3 spec/clearance/testing/helpers_spec.rb
clearance-1.4.2 spec/clearance/testing/helpers_spec.rb
clearance-1.4.1 spec/clearance/testing/helpers_spec.rb
clearance-1.4.0 spec/clearance/testing/helpers_spec.rb