Sha256: 4cc58104d9c7e6da70422352af675d9c6e7af64a2771525f3943fc886d7be54d

Contents?: true

Size: 1.48 KB

Versions: 41

Compression:

Stored size: 1.48 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe SessionsController do
  describe 'ログインする (XHR POST create)' do
    let(:params) {
      {
        username: '1102',
      }
    }

    context 'RAILS_ENVがstandaloneの場合', set_standalone_rails_env: true do
      before do
        xhr :post, :create, params, {}
      end

      describe 'レスポンスボディ' do
        subject { response.body }

        it { should eq('1102') }
      end

      describe 'session' do
        subject { session }

        describe '[:username]' do
          subject { super()[:username] }

          it { should eq(params[:username]) }
        end
      end
    end

    context 'RAILS_ENVがstandaloneではない場合' do
      it do
        expect {
          xhr :post, :create, params, {}
        }.to raise_exception
      end
    end
  end

  describe 'ログアウトする (DELETE destroy)' do
    let(:_session) {
      {
        username: '1102',
      }
    }

    context 'RAILS_ENVがstandaloneの場合', set_standalone_rails_env: true do
      before do
        xhr :delete, :destroy, {}, _session
      end

      describe 'session' do
        subject { session }

        describe '[:username]' do
          subject { super()[:username] }

          it { should be_nil }
        end
      end
    end

    context 'RAILS_ENVがstandaloneではない場合' do
      it do
        expect {
          xhr :post, :create, params, {}
        }.to raise_exception
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
smalruby-editor-0.2.6-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.6 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.5-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.5 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.4-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.4 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.3-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.3 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.2-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.2 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.1-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.1 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.0-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.2.0 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.1.24-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.1.24 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.1.23-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.1.23 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.1.22-x86-mingw32 spec/controllers/sessions_controller_spec.rb
smalruby-editor-0.1.22 spec/controllers/sessions_controller_spec.rb