Sha256: c8cee53c9a0b54c0d8d7a5e59efdc36ccb988a5cd1b90e55febf0592548ac816

Contents?: true

Size: 1.76 KB

Versions: 32

Compression:

Stored size: 1.76 KB

Contents

require 'test_helper'
require 'ndr_import/file/registry'

module NdrImport
  module File
    # Base file handler tests
    class BaseTest < ActiveSupport::TestCase
      # Handles a single table file, but for test purposes,
      # I could be bothered to implement it fully
      class SingleTableLazyDeveloper < ::NdrImport::File::Base
      end

      def setup
        @permanent_test_files = SafePath.new('permanent_test_files')
      end

      test 'should fail on not implementing rows' do
        begin
          Registry.register(SingleTableLazyDeveloper, 'lazy_dev')

          exception = assert_raises(RuntimeError) do
            file_path = @permanent_test_files.join('normal.csv')
            handler = SingleTableLazyDeveloper.new(file_path, 'lazy_dev')

            handler.tables.each do |tablename, sheet|
              assert_nil tablename
              assert_instance_of Enumerator, sheet
              sheet.to_a
            end
          end

          msg = 'Implement NdrImport::File::BaseTest::SingleTableLazyDeveloper#rows'
          assert_equal msg, exception.message
        ensure
          Registry.unregister('lazy_dev')
        end
      end

      test 'should not fail when set up with an readable safepath' do
        assert Base.new(SafePath.new('test_space_r'), nil)
        assert Base.new(SafePath.new('test_space_rw'), nil)
      end

      test 'should fail when set up with an unreadable safepath' do
        assert_raises(SecurityError) { Base.new(SafePath.new('test_space_w'), nil) }
      end

      test 'should fail when set up with a non-safepath' do
        exception = assert_raises(ArgumentError) { Base.new(NdrImport.root, nil) }
        assert exception.message =~ /file_name should be of type SafePath, but it is String/
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ndr_import-8.5.0 test/file/base_test.rb
ndr_import-8.4.0 test/file/base_test.rb
ndr_import-8.3.0 test/file/base_test.rb
ndr_import-8.2.0 test/file/base_test.rb
ndr_import-8.1.0 test/file/base_test.rb
ndr_import-8.0.0 test/file/base_test.rb
ndr_import-7.0.0 test/file/base_test.rb
ndr_import-6.4.1 test/file/base_test.rb
ndr_import-6.4.0 test/file/base_test.rb
ndr_import-6.3.0 test/file/base_test.rb
ndr_import-6.2.0 test/file/base_test.rb
ndr_import-6.1.1 test/file/base_test.rb
ndr_import-6.1.0 test/file/base_test.rb
ndr_import-6.0.0 test/file/base_test.rb
ndr_import-5.1.0 test/file/base_test.rb
ndr_import-5.0.0 test/file/base_test.rb
ndr_import-4.1.4 test/file/base_test.rb
ndr_import-4.1.3 test/file/base_test.rb
ndr_import-4.1.2 test/file/base_test.rb
ndr_import-4.1.1 test/file/base_test.rb