Sha256: a584dc721d6da4673c3cd89a2ea1c21021df3a9b265f59c690439f002d4024f5

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

shared_examples_for 'an aggregatable Vector' do
  context "#group_by" do
    let(:dv) { DaruLite::Vector.new [:a, :b, :a, :b, :c] }

    context 'vector not specified' do
      subject { dv.group_by }

      it { is_expected.to be_a DaruLite::Core::GroupBy }
      its(:'groups.size') { is_expected.to eq 3 }
      its(:groups) { is_expected.to eq({[:a]=>[0, 2], [:b]=>[1, 3], [:c]=>[4]}) }
    end

    context 'vector name specified' do
      before { dv.name = :hello }
      subject { dv.group_by :hello }

      it { is_expected.to be_a DaruLite::Core::GroupBy }
      its(:'groups.size') { is_expected.to eq 3 }
      its(:groups) { is_expected.to eq({[:a]=>[0, 2], [:b]=>[1, 3], [:c]=>[4]}) }
    end

    context 'vector name invalid' do
      before { dv.name = :hello }
      it { expect { dv.group_by :abc }.to raise_error }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daru_lite-0.1.3 spec/vector/aggregatable_example.rb
daru_lite-0.1.2 spec/vector/aggregatable_example.rb