Sha256: f4cf3099cc52b97c085a7cc1b416518a980111024b95c977f4fc168626bdd425
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') module Recliner describe Document do define_recliner_document :TestDocument subject { TestDocument.new } describe "#read_attribute" do context "internal attribute same as property name" do before(:each) do subject.properties = { :foo => Recliner::Property.new('foo', String, 'foo', nil) } subject.stub(:attributes).and_return('foo' => 'value of foo') end it "should return the attribute value" do subject.read_attribute(:foo).should == 'value of foo' end end context "internal attribute different from property name" do before(:each) do subject.properties = { :foo => Recliner::Property.new('foo', String, '_internal', nil) } subject.stub(:attributes).and_return('_internal' => 'value of foo') end it "should return the attribute value" do subject.read_attribute(:foo).should == 'value of foo' end end context "no property" do before(:each) do subject.properties = {} subject.stub!(:attributes).and_return('foo' => 'value of foo') end it "should return the attribute value" do subject.read_attribute(:foo).should == 'value of foo' end end end describe "#[]" do it "should read the given attribute" do subject.should_receive(:read_attribute).with(:foo).and_return('value of foo') subject[:foo].should == 'value of foo' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
recliner-0.0.1 | spec/recliner/document/attribute_methods/read_spec.rb |