Sha256: 64665df8e4c40a27be56324cea0be04072bfdccf57725eb1d4616153f1520e0d

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

shared_examples_for "an implementation of EtapHash" do
  it "acts like a Hash" do
    @etaphash.should be_a_kind_of(Hash)
  end
  
  it "knows what it represents" do
    @etaphash.base.should == @basearray
  end
  
  it "returns the hashed value when called" do
    @basearray.each do |item| 
      cell = @etaphash[item.send(@keymethod).symbolize]
      val = item.send(@valmethod)
      if cell.kind_of?(Array)
        cell.should include(val)
      else
        cell.should == val
      end
    end
  end
  
  it "can set the hashed value in the base" do
    @etaphash[:fax] = 'foobar'
    @basearray.last.send(@valmethod).should == 'foobar'
  end

  it "can return the full Etapper object" do
    base = @basearray.last
    key = base.send(@keymethod).symbolize
    sec = base.send(@secondarymethod)
    @etaphash.detailed[key].send(@secondarymethod).should == sec
  end

  it "makes new values in the base when a key is added" do
    @etaphash[:voice] = 'yowza'
    @basearray.last.send(@valmethod).should == 'yowza'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
etapper-0.0.5 spec/shared_etap_hash_spec.rb
etapper-0.0.4 spec/shared_etap_hash_spec.rb
etapper-0.0.3 spec/shared_etap_hash_spec.rb
etapper-0.0.2 spec/shared_etap_hash_spec.rb
etapper-0.0.1 spec/shared_etap_hash_spec.rb
etapper-0.0.0 spec/shared_etap_hash_spec.rb