Sha256: 43d2dac01a3bf7747dcb7786308022cf5c22edddefa49d0b15a0acf0391bceed
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
require_relative 'helper/copyable_spec_helper' describe Copyable::ModelHooks do context 'callbacks' do # Note: the relevant callbacks are defined in CopyableTree in helper/test_models.rb describe '.disable!' do before(:each) do Copyable::ModelHooks.disable!(CopyableTree) end after(:each) do Copyable::ModelHooks.reenable!(CopyableTree) end it 'defines an instance variable on the class' do expect(CopyableTree.all_callbacks_disabled).to eq(true) end it 'should not prevent model actions from executing' do expect(CopyableTree.count).to eq(0) end end describe '.reenable!' do it 'defines an instance variable on the class' do Copyable::ModelHooks.reenable!(CopyableTree) expect(CopyableTree.all_callbacks_disabled).to eq(false) end it 'should allow callbacks to execute again' do expect { CopyableTree.create!(kind: 'magnolia') }.to raise_error(RuntimeError, "callback2 called") end end end end
Version data entries
5 entries across 5 versions & 1 rubygems