Sha256: 3cc77390a6051b5cb6fba22c3d070322f3289d1884142a26c537f89c75a1acc9

Contents?: true

Size: 780 Bytes

Versions: 55

Compression:

Stored size: 780 Bytes

Contents

require 'rails_helper'

shared_examples_for :deletable do
  let(:model) { described_class }
  let(:klass) { model.to_s.underscore.to_sym }

  describe 'after_intialize' do
    context 'new record' do
      it :true do
        expect(build(klass)).to be_deletable
      end

      it :false do
        expect(build(klass, deletable: false)).not_to be_deletable
      end
    end

    context 'existing record after create' do
      it :false do
        instance = create(klass, deletable: false)
        expect(instance).not_to be_deletable
      end
    end

    context 'existing record after save' do
      it :false do
        instance = create(klass)
        instance.update_attribute :deletable, false
        expect(instance).not_to be_deletable
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
udongo-7.9.0 spec/support/concerns/deletable.rb
udongo-7.8.1 spec/support/concerns/deletable.rb
udongo-7.8.0 spec/support/concerns/deletable.rb
udongo-7.7.2 spec/support/concerns/deletable.rb
udongo-7.7.1 spec/support/concerns/deletable.rb
udongo-7.7.0 spec/support/concerns/deletable.rb
udongo-7.6.2 spec/support/concerns/deletable.rb
udongo-7.6.1 spec/support/concerns/deletable.rb
udongo-7.6.0 spec/support/concerns/deletable.rb
udongo-7.5.1 spec/support/concerns/deletable.rb
udongo-7.5.0 spec/support/concerns/deletable.rb
udongo-7.4.2 spec/support/concerns/deletable.rb
udongo-7.4.1 spec/support/concerns/deletable.rb
udongo-7.4.0 spec/support/concerns/deletable.rb
udongo-7.3.5 spec/support/concerns/deletable.rb
udongo-7.3.4 spec/support/concerns/deletable.rb
udongo-7.3.3 spec/support/concerns/deletable.rb
udongo-7.3.2 spec/support/concerns/deletable.rb
udongo-7.3.1 spec/support/concerns/deletable.rb
udongo-7.2.1 spec/support/concerns/deletable.rb