require 'spec_helper' describe CellSet::Member do context "attributes" do it { should have_accessor(:caption) } it { should have_accessor(:childMembers) } it { should have_accessor(:depth) } it { should have_accessor(:description) } it { should have_accessor(:dimension) } it { should have_accessor(:expression) } it { should have_accessor(:hierarchy) } it { should have_accessor(:level) } it { should have_accessor(:memberType) } it { should have_accessor(:name) } it { should have_accessor(:ordinal) } it { should have_accessor(:parentMember) } it { should have_accessor(:uniqueName) } context "initialize" do before(:each) do @member = Factory.build(:member) end it "should set childMembers to empty array" do @member.instance_variable_get(:@childMembers).should == [] end end end context "Serialization" do let(:name) { "Member" } let(:unique_name) { "[All].[Member]"} let(:member) do Factory.build(:member, :ordinal => 0, :name => name, :uniqueName => unique_name) end context "JSON" do it "should serialize" do member.as_json.should == { "caption" => nil, "childMembers" => [], "depth" => nil, "description" => nil, "dimension" => nil, "expression" => nil, "hierarchy" => nil, "level" => nil, "memberType" => nil, "name" => name, "ordinal" => 0, "parentMember" => nil, "uniqueName" => unique_name } end it "should serialize with root" do member.as_json(:root => true).should == { "member" => { "caption" => nil, "childMembers" => [], "depth" => nil, "description" => nil, "dimension" => nil, "expression" => nil, "hierarchy" => nil, "level" => nil, "memberType" => nil, "name" => name, "ordinal" => 0, "parentMember" => nil, "uniqueName" => unique_name } } end it "should deserialize" do ::CellSet::Member.new.from_json(member.to_json).should == member end it "should de-serialize frozen" do ::CellSet::Member.new.from_json(member.to_json).frozen?.should be_true end end end end