Sha256: 00e9795ad3132afbb323d0f665756268e0761a5a0ce58121fb09e47edbea5613

Contents?: true

Size: 993 Bytes

Versions: 4

Compression:

Stored size: 993 Bytes

Contents

shared_examples "a cell collection" do
  it { is_expected.to respond_to :header }
  it { is_expected.to respond_to :data }
  it { is_expected.to respond_to :value_name }
  it { is_expected.to respond_to :total }
  it { is_expected.to respond_to :orthogonal_headers }

  subject(:instance) { klass.new(attrs) }

  let(:data) do
    { a: 1, b: 2 }
  end

  let(:attrs) do
    { header: 'header', data: data.values, value_name: "value_name", orthogonal_headers: data.keys }
  end

  context 'initialize with hash' do
    its(:header) { is_expected.to eq attrs[:header] }
    its(:data) { is_expected.to eq attrs[:data] }
    its(:value_name) { is_expected.to eq attrs[:value_name] }
    its(:orthogonal_headers) { is_expected.to eq attrs[:orthogonal_headers] }
  end

  it "finds data by orthogonal header name" do
    expect(instance.send :find_data, :a).to equal(data[:a])
    expect(instance.send :find_data, :b).to equal(data[:b])
    expect(instance.send :find_data, :c).to be_nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pivot_table-1.0.0 spec/support/shared_examples_for_a_cell_collection_.rb
pivot_table-0.5.0 spec/support/shared_examples_for_a_cell_collection_.rb
pivot_table-0.4.0 spec/support/shared_examples_for_a_cell_collection_.rb
pivot_table-0.3.0 spec/support/shared_examples_for_a_cell_collection_.rb