Sha256: 61db8064022f0584987f88e1d5b428992d54ac96f356b2a462370a02d8888649

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

module BerkeleyLibrary
  module TIND
    module Export
      describe Column do
        describe :each_value do
          let(:values) { %w[a b c d] }
          attr_reader :col

          before(:each) do
            cg = instance_double(ColumnGroup)
            allow(cg).to receive(:row_count).and_return(values.size)
            allow(cg).to receive(:value_at) { |r, _| values[r] }
            allow(cg).to receive(:prefix).and_return('99999')
            allow(cg).to receive(:index_in_tag).and_return(9)
            allow(cg).to receive(:subfield_codes).and_return(['9'])
            @col = Column.new(cg, 0)
          end

          it 'yields each value' do
            actual = [].tap do |vv|
              col.each_value { |v| vv << v }
            end
            expect(actual).to eq(values)
          end

          it 'returns an enumerator' do
            enum = col.each_value
            expect(enum.to_a).to eq(values)
          end

          it 'optionally returns the header' do
            enum = col.each_value(include_header: true)
            enum_values = enum.to_a
            expect(enum_values[0]).to eq(col.header)
            expect(enum_values[1..]).to eq(values)
          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/column_spec.rb
berkeley_library-tind-0.7.1 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.7.0 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.6.0 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.5.1 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.5.0 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.4.3 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.4.2 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.4.1 spec/berkeley_library/tind/export/column_spec.rb
berkeley_library-tind-0.4.0 spec/berkeley_library/tind/export/column_spec.rb