Sha256: e3c273fd0953a3d3edd92b5d21823a141d00bc02336a38d96fc2e1cc36d0a36c

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require_relative '../../../../test_helper'

module Troo
  describe Behaviours::NullEntity do
    let(:described_class) { Behaviours::NullEntity }

    describe '#default?' do
      subject { described_class.new.default? }

      it { subject.must_be_instance_of(FalseClass) }

      it { subject.must_equal false }
    end
  end

  describe Behaviours::SetDefault do
    let(:described_class) { Behaviours::SetDefault }

    describe '#set_default!' do
      before do
        @board_1 = Fabricate(:board, default: true)
        @board_2 = Fabricate(:board, default: false)
      end

      after { database_cleanup }

      subject { described_class.for(entity) }

      context 'when the entity is already the default' do
        let(:entity) { @board_1 }

        it { subject.must_be_instance_of(TrueClass) }

        it { subject.must_equal true }
      end

      context 'when the entity is not already the default' do
        let(:entity) { @board_2 }

        it 'sets the specified entity to be the default' do
          subject.default.must_equal(true)

          subject.must_equal(@board_2)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.15 test/lib/troo/models/behaviours/set_default_test.rb
troo-0.0.14 test/lib/troo/models/behaviours/set_default_test.rb
troo-0.0.13 test/lib/troo/models/behaviours/set_default_test.rb