Sha256: 75691911f2da6143acc08976fe64d7fea2bca3c2456e6532ee8563f6873a836e

Contents?: true

Size: 1.69 KB

Versions: 9

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'ogr/internal_helpers'

RSpec.describe OGR::InternalHelpers do
  subject(:tester) do
    module Tester
      include OGR::InternalHelpers
    end
  end

  describe '._boolean_access_flag' do
    context "when 'w'" do
      subject { tester._boolean_access_flag('w') }
      it { is_expected.to eq true }
    end

    context "when 'r'" do
      subject { tester._boolean_access_flag('r') }
      it { is_expected.to eq false }
    end

    context 'when anything else' do
      it 'raises a RuntimeError' do
        expect { tester._boolean_access_flag('a') }.to raise_exception RuntimeError
      end
    end
  end

  describe '._format_time_zone_for_ruby' do
    context 'time_zone is 0' do
      subject { tester._format_time_zone_for_ruby(0) }
      it { is_expected.to be_nil }
    end

    context 'time_zone is 1' do
      subject { tester._format_time_zone_for_ruby(1) }
      it { is_expected.to be_a String }
      it { is_expected.to_not be_empty }
    end

    context 'time_zone is 100' do
      subject { tester._format_time_zone_for_ruby(100) }
      it { is_expected.to eq '+0' }
    end
  end

  describe '._format_time_zone_for_ogr' do
    context 'GMT' do
      subject { tester._format_time_zone_for_ogr('GMT') }
      it { is_expected.to eq 100 }
    end

    context '+00:00' do
      subject { tester._format_time_zone_for_ogr('+00:00') }
      it { is_expected.to eq 100 }
    end

    context 'not nil and not GMT' do
      subject { tester._format_time_zone_for_ogr('asdf') }
      it { is_expected.to eq 1 }
    end

    context 'nil' do
      subject { tester._format_time_zone_for_ogr(nil) }
      it { is_expected.to eq 0 }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta16 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta15 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta14 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta13 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta12 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta11 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta10 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta9 spec/unit/ogr/internal_helpers_spec.rb
ffi-gdal-1.0.0.beta8 spec/unit/ogr/internal_helpers_spec.rb