Sha256: dd03b7bedc176235637c1398110430687e4483fc5e6d4ff7b2d7954d20d15838

Contents?: true

Size: 1.53 KB

Versions: 16

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Azeroth::Options do
  subject(:options) { described_class.new }

  describe 'validation' do
    context 'when initializing with invalid options' do
      it do
        expect { described_class.new(invalid_option: 1) }
          .to raise_error(Sinclair::Exception::InvalidOptions)
      end
    end
  end

  describe '#actions' do
    it 'returns default actions' do
      expect(options.actions)
        .to eq(%i[create destroy edit index new show update])
    end

    context 'when passing only options' do
      subject(:options) { described_class.new(only: [:index]) }

      it 'returns defined actions' do
        expect(options.actions)
          .to eq(%i[index])
      end

      context 'when not passing an array' do
        subject(:options) { described_class.new(only: :index) }

        it 'returns defined actions as array' do
          expect(options.actions)
            .to eq(%i[index])
        end
      end
    end

    context 'when passing except options' do
      subject(:options) do
        described_class.new(except: %i[index create])
      end

      it 'returns not excluded actions' do
        expect(options.actions)
          .to eq(%i[destroy edit new show update])
      end

      context 'when not passing an array' do
        subject(:options) { described_class.new(except: :index) }

        it 'returns not excluded actions' do
          expect(options.actions)
            .to eq(%i[create destroy edit new show update])
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
azeroth-1.0.0 spec/lib/azeroth/options_spec.rb
azeroth-0.10.1 spec/lib/azeroth/options_spec.rb
azeroth-0.10.0 spec/lib/azeroth/options_spec.rb
azeroth-0.9.0 spec/lib/azeroth/options_spec.rb
azeroth-0.8.2 spec/lib/azeroth/options_spec.rb
azeroth-0.8.1 spec/lib/azeroth/options_spec.rb
azeroth-0.8.0 spec/lib/azeroth/options_spec.rb
azeroth-0.7.4 spec/lib/azeroth/options_spec.rb
azeroth-0.7.3 spec/lib/azeroth/options_spec.rb
azeroth-0.7.2 spec/lib/azeroth/options_spec.rb
azeroth-0.7.1 spec/lib/azeroth/options_spec.rb
azeroth-0.7.0 spec/lib/azeroth/options_spec.rb
azeroth-0.6.5 spec/lib/azeroth/options_spec.rb
azeroth-0.6.4 spec/lib/azeroth/options_spec.rb
azeroth-0.6.3 spec/lib/azeroth/options_spec.rb
azeroth-0.6.2 spec/lib/azeroth/options_spec.rb