Sha256: 72d1f9f39da73d781b20c9031b7deb50b4892f5c8ff4c9e09f9be16c3071b6ab

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'
require 'ext/error_symbols'

describe Symbol do
  describe '#to_ruby' do
    context ':CE_None' do
      subject { :CE_None }

      it 'returns :none' do
        expect(subject.to_ruby).to eq :none
      end

      context 'with an explicit value' do
        it 'returns what the given param is' do
          expect(subject.to_ruby(none: :pants)).to eq :pants
        end
      end
    end

    context ':CE_Debug' do
      subject { :CE_Debug }

      it 'returns :debug' do
        expect(subject.to_ruby).to eq :debug
      end

      context 'with an explicit value' do
        it 'returns what the given param is' do
          expect(subject.to_ruby(debug: :pants)).to eq :pants
        end
      end
    end

    context ':CE_Warning' do
      subject { :CE_Warning }

      it 'returns :warning' do
        expect(subject.to_ruby).to eq :warning
      end

      context 'with an explicit value' do
        it 'returns what the given param is' do
          expect(subject.to_ruby(warning: :pants)).to eq :pants
        end
      end
    end
  end

  describe '#to_bool' do
    context ':CE_None' do
      subject { :CE_None.to_bool }
      it { is_expected.to eq true }
    end

    context ':CE_Debug' do
      subject { :CE_Debug.to_bool }
      it { is_expected.to eq true }
    end

    context ':CE_Warning' do
      subject { :CE_Warning.to_bool }
      it { is_expected.to eq false }
    end

    context ':CE_Failure' do
      subject { :CE_Failure }
      it 'raises a CPLErrFailure' do
        expect { subject.to_bool }.to raise_error GDAL::CPLErrFailure
      end
    end

    context ':CE_Fatal' do
      subject { :CE_Fatal }
      it 'raises a CPLErrFailure' do
        expect { subject.to_bool }.to raise_error GDAL::CPLErrFailure
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta3 spec/unit/ext/error_symbols_spec.rb
ffi-gdal-1.0.0.beta1 spec/unit/ext/error_symbols_spec.rb