Sha256: 4bcaca0bcee5c9a7b7fabf662d8147519457c7e21833d2230fa4eabe394a9543

Contents?: true

Size: 902 Bytes

Versions: 7

Compression:

Stored size: 902 Bytes

Contents

describe 'Conditional Raising' do

  describe '#raise_if' do

    it 'should raise the specified error if the condition is true' do
      expect {
        raise_if true, RuntimeError, 'MESSAGE'
      }.to raise_error(RuntimeError, 'MESSAGE')
    end

    it 'should not raise the specified error if the condition is false' do
      expect {
        raise_if false, RuntimeError, 'MESSAGE'
      }.to_not raise_error(RuntimeError, 'MESSAGE')
    end

  end

  describe '#raise_unless' do

    it 'should not raise the specified error unless the condition is true' do
      expect {
        raise_unless true, RuntimeError, 'MESSAGE'
      }.to_not raise_error(RuntimeError, 'MESSAGE')
    end

    it 'should raise the specified error unless the condition is false' do
      expect {
        raise_unless false, RuntimeError, 'MESSAGE'
      }.to raise_error(RuntimeError, 'MESSAGE')
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
elasticity-2.4 spec/lib/elasticity/support/conditional_raise_spec.rb
elasticity-2.3.1 spec/lib/elasticity/support/conditional_raise_spec.rb
elasticity-2.3 spec/lib/elasticity/support/conditional_raise_spec.rb
elasticity-2.2 spec/lib/elasticity/support/conditional_raise_spec.rb
elasticity-2.1.1 spec/lib/elasticity/support/conditional_raise_spec.rb
elasticity-2.1 spec/lib/elasticity/support/conditional_raise_spec.rb
elasticity-2.0 spec/lib/elasticity/support/conditional_raise_spec.rb