Sha256: 62b65b5f1b0d856d95244d68a7e63f006e6dc26a163ba1f8ca33218cdb1af4ad

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'spec/spec_helper'
require 'taza/entity'

describe Taza::Entity do
  it "should add methods for hash string keys" do
    entity = Taza::Entity.new({'apple' => 'pie'},nil)
    entity.should respond_to(:apple)
  end

  it "should be accessible like a hash(foo[:bar])" do
    entity = Taza::Entity.new({:apple => 'pie'},nil)
    entity[:apple].should eql('pie')
  end

  it "should be able to define methods for multiple levels" do
    entity = Taza::Entity.new({:fruits => {:apple => 'pie'} },nil)
    entity.fruits.apple.should eql('pie')
  end

  it "should be able to return a hash object" do
    entity = Taza::Entity.new({:apple => 'pie' },nil)
    entity.to_hash[:apple].should eql('pie')
  end
  
  it "should be able to do string-to-symbol conversion for hash keys using to_hash" do
    entity = Taza::Entity.new({'apple' => 'pie' },nil)
    entity.to_hash[:apple].should eql('pie')
  end

  it "should be able to do string-to-symbol conversion for hash keys" do
    entity = Taza::Entity.new({'fruits' => {'apple' => 'pie' }},nil)
    entity.to_hash[:fruits][:apple].should eql('pie')
  end

end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
makevoid-taza-0.8.6 spec/entity_spec.rb
scudco-taza-0.8.7 spec/entity_spec.rb
taza-0.8.7 spec/entity_spec.rb