Sha256: 91b6112c78107b25aedd179d132670a62de96655ba7466ba54043919b9a4c9d4

Contents?: true

Size: 1.62 KB

Versions: 10

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

module BerkeleyLibrary
  module TIND
    module Export
      describe ExportFormat do
        describe :to_str do
          it 'returns the value' do
            ExportFormat.each do |fmt|
              # rubocop:disable Style/StringConcatenation
              expect('' + fmt).to eq(fmt.value)
              # rubocop:enable Style/StringConcatenation
            end
          end
        end

        describe :mime_type do
          it 'returns the correct MIME type' do
            {
              ExportFormat::CSV => 'text/csv',
              ExportFormat::ODS => 'application/vnd.oasis.opendocument.spreadsheet'
            }.each do |fmt, mime_type|
              expect(fmt.mime_type).to eq(mime_type)
            end
          end
        end

        describe :ensure_format do
          it 'rejects unsupported formats' do
            expect { ExportFormat.ensure_format(:wks) }.to raise_error(ArgumentError)
          end
        end

        describe :description do
          it 'returns a description' do
            ExportFormat.each do |fmt|
              expect(fmt.description).to be_a(String)
              expect(fmt.description).not_to be_empty
            end
          end
        end

        describe :DEFAULT do
          it 'defaults to ODS' do
            expect(ExportFormat::DEFAULT).to be(ExportFormat::ODS)
          end
        end

        describe :default? do
          it 'returns true for default, false otherwise' do
            ExportFormat.each do |fmt|
              expect(fmt.default?).to eq(fmt == ExportFormat::DEFAULT)
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
berkeley_library-tind-0.7.2 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.7.1 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.7.0 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.6.0 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.5.1 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.5.0 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.4.3 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.4.2 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.4.1 spec/berkeley_library/tind/export/export_format_spec.rb
berkeley_library-tind-0.4.0 spec/berkeley_library/tind/export/export_format_spec.rb