Sha256: ee4991578d5255158943096db57fd11435193b7145a7c9a9e0681dca8a5d45fb

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

RSpec.shared_examples 'Nyauth::SessionConcern' do
  describe '#sign_in' do
    subject { controller.sign_in(user) }

    context 'as user' do
      let(:options) { { as: :user } }

      context 'given user' do
        let(:user) { create(:user) }
        it '#signed_in? should change result from false to true 'do
          expect {
            subject
          }.to change { controller.signed_in?(options) }.from(false).to(true)
        end

        it '#current_authenticated should change from result nil to user 'do
          expect {
            subject
          }.to change { controller.current_authenticated }.from(nil).to(user)
        end
      end

      context 'given nil' do
        let(:user) { nil }
        it '#signed_in? should not change result from false'do
          expect {
            subject
          }.not_to change { controller.signed_in?(options) }.from(false)
        end

        it '#current_authenticated should not change result from nil'do
          expect {
            subject
          }.not_to change { controller.current_authenticated }.from(nil)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nyauth-0.2.3 spec/support/controllers/nyauth/session_concern.rb
nyauth-0.2.2 spec/support/controllers/nyauth/session_concern.rb
nyauth-0.2.1 spec/support/controllers/nyauth/session_concern.rb
nyauth-0.2.0 spec/support/controllers/nyauth/session_concern.rb
nyauth-0.1.0 spec/support/controllers/nyauth/session_concern.rb
nyauth-0.0.3 spec/support/controllers/nyauth/session_concern.rb
nyauth-0.0.2 spec/support/controllers/nyauth/session_concern.rb
nyauth-0.0.1 spec/support/controllers/nyauth/session_concern.rb