Sha256: 4f46d108935d0e58a24654f4643c43e95166fddce9919a7899c1c434051a0cef
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper.rb' describe Daru::Index do context "#initialize" do it "creates an Index from Array" do idx = Daru::Index.new ['speaker', 'mic', 'guitar', 'amp'] expect(idx.to_a).to eq([:speaker, :mic, :guitar, :amp]) end end context "#size" do it "correctly returns the size of the index" do idx = Daru::Index.new ['speaker', 'mic', 'guitar', 'amp'] expect(idx.size).to eq(4) end end context "#re_index" do before :each do @old = Daru::Index.new [:bob, :fisher, :zakir] end it "returns a new index object" do n = @old.re_index(@old + [:john, :shrinivas]) expect(n.object_id).not_to eq(@old.object_id) expect(n.to_a).to eq([:bob, :fisher, :zakir, :john, :shrinivas]) end it "does not over-ride existing indexes" do n = @old.re_index(@old + :bob) expect(n.object_id).not_to eq(@old.object_id) expect(n.to_a) .to eq([:bob, :fisher, :zakir]) end end context "#+" do before :each do @left = Daru::Index.new [:miles, :geddy, :eric] @right = Daru::Index.new [:bob, :jimi, :richie] end it "adds 2 indexes and returns an Index" do expect(@left + @right).to eq([:miles, :geddy, :eric, :bob, :jimi, :richie].to_index) end it "adds an Index and an Array to return an Index" do expect(@left + [:bob, :jimi, :richie]).to eq([:miles, :geddy, :eric, :bob, :jimi, :richie].to_index) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
daru-0.0.3.1 | spec/index_spec.rb |
daru-0.0.3 | spec/index_spec.rb |