Sha256: 1b196fdba3391f3525668ec615d9ae861c0e5c2631f0273dac06c9e252f4f50a

Contents?: true

Size: 1004 Bytes

Versions: 94

Compression:

Stored size: 1004 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/data_dir'

describe 'HexaPDF.data_dir' do
  before do
    @local = File.expand_path(File.join(__dir__, '..', '..', 'data', 'hexapdf'))
    @global = File.expand_path(File.join(RbConfig::CONFIG["datadir"], "hexapdf"))
    HexaPDF.remove_instance_variable(:@data_dir) if HexaPDF.instance_variable_defined?(:@data_dir)
  end

  after do
    HexaPDF.remove_instance_variable(:@data_dir) if HexaPDF.instance_variable_defined?(:@data_dir)
  end

  it "returns the 'local' data directory by default, e.g. in case of gem installations" do
    assert_equal(@local, HexaPDF.data_dir)
  end

  it "returns the global data directory if the local one isn't found" do
    File.stub(:directory?, lambda {|path| path != @local }) do
      assert_equal(@global, HexaPDF.data_dir)
    end
  end

  it "fails if no data directory is found" do
    File.stub(:directory?, lambda {|_path| false }) do
      assert_raises { HexaPDF.data_dir }
    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
hexapdf-1.2.0 test/hexapdf/test_data_dir.rb
hexapdf-1.1.1 test/hexapdf/test_data_dir.rb
hexapdf-1.1.0 test/hexapdf/test_data_dir.rb
hexapdf-1.0.3 test/hexapdf/test_data_dir.rb
hexapdf-1.0.2 test/hexapdf/test_data_dir.rb
hexapdf-1.0.1 test/hexapdf/test_data_dir.rb
hexapdf-1.0.0 test/hexapdf/test_data_dir.rb
hexapdf-0.47.0 test/hexapdf/test_data_dir.rb
hexapdf-0.46.0 test/hexapdf/test_data_dir.rb
hexapdf-0.45.0 test/hexapdf/test_data_dir.rb
hexapdf-0.44.0 test/hexapdf/test_data_dir.rb
hexapdf-0.41.0 test/hexapdf/test_data_dir.rb
hexapdf-0.40.0 test/hexapdf/test_data_dir.rb
hexapdf-0.39.1 test/hexapdf/test_data_dir.rb
hexapdf-0.39.0 test/hexapdf/test_data_dir.rb
hexapdf-0.38.0 test/hexapdf/test_data_dir.rb
hexapdf-0.37.2 test/hexapdf/test_data_dir.rb
hexapdf-0.37.1 test/hexapdf/test_data_dir.rb
hexapdf-0.37.0 test/hexapdf/test_data_dir.rb
hexapdf-0.36.0 test/hexapdf/test_data_dir.rb