spec/unit/ext/error_symbols_spec.rb in ffi-gdal-1.0.0.beta3 vs spec/unit/ext/error_symbols_spec.rb in ffi-gdal-1.0.0.beta4
- old
+ new
@@ -1,79 +1,67 @@
require 'spec_helper'
require 'ext/error_symbols'
-describe Symbol do
- describe '#to_ruby' do
- context ':CE_None' do
- subject { :CE_None }
+RSpec.describe Symbol do
+ describe '#handle_result' do
+ context ':OGRERR_NONE' do
+ subject { :OGRERR_NONE.handle_result }
+ it { is_expected.to eq true }
+ end
- it 'returns :none' do
- expect(subject.to_ruby).to eq :none
+ context ':OGRERR_NOT_ENOUGH_DATA' do
+ it 'raises an OGR::NotEnoughData exception' do
+ expect { :OGRERR_NOT_ENOUGH_DATA.handle_result }.
+ to raise_exception OGR::NotEnoughData
end
+ 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
+ context ':OGRERR_NOT_ENOUGH_MEMORY' do
+ it 'raises an NoMemoryError exception' do
+ expect { :OGRERR_NOT_ENOUGH_MEMORY.handle_result }.
+ to raise_exception NoMemoryError
end
end
- context ':CE_Debug' do
- subject { :CE_Debug }
-
- it 'returns :debug' do
- expect(subject.to_ruby).to eq :debug
+ context ':OGRERR_UNSUPPORTED_GEOMETRY_TYPE' do
+ it 'raises an OGR::UnsupportedGeometryType exception' do
+ expect { :OGRERR_UNSUPPORTED_GEOMETRY_TYPE.handle_result }.
+ to raise_exception OGR::UnsupportedGeometryType
end
+ 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
+ context ':OGRERR_UNSUPPORTED_OPERATION' do
+ it 'raises an OGR::UnsupportedOperation exception' do
+ expect { :OGRERR_UNSUPPORTED_OPERATION.handle_result }.
+ to raise_exception OGR::UnsupportedOperation
end
end
- context ':CE_Warning' do
- subject { :CE_Warning }
-
- it 'returns :warning' do
- expect(subject.to_ruby).to eq :warning
+ context ':OGRERR_CORRUPT_DATA' do
+ it 'raises an OGR::CorruptData exception' do
+ expect { :OGRERR_CORRUPT_DATA.handle_result }.
+ to raise_exception OGR::CorruptData
end
+ 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
+ context ':OGRERR_FAILURE' do
+ it 'raises an OGR::Failure exception' do
+ expect { :OGRERR_FAILURE.handle_result }.
+ to raise_exception OGR::Failure
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
+ context ':OGRERR_UNSUPPORTED_SRS' do
+ it 'raises an OGR::UnsupportedSRS exception' do
+ expect { :OGRERR_UNSUPPORTED_SRS.handle_result }.
+ to raise_exception OGR::UnsupportedSRS
end
end
- context ':CE_Fatal' do
- subject { :CE_Fatal }
- it 'raises a CPLErrFailure' do
- expect { subject.to_bool }.to raise_error GDAL::CPLErrFailure
+ context ':OGRERR_INVALID_HANDLE' do
+ it 'raises an OGR::InvalidHandle exception' do
+ expect { :OGRERR_INVALID_HANDLE.handle_result }.
+ to raise_exception OGR::InvalidHandle
end
end
end
end