require 'spec/spec_helper' describe CloudQuery::Schema do describe "#.to_xml" do before :each do @schema = CloudQuery::Schema.new('user.schema') @schema.fields << CloudQuery::Field.new(:name, :string) @schema.fields << CloudQuery::Field.new(:type, :literal) @schema.fields << CloudQuery::Field.new(:description, :text) @document = Nokogiri::XML(@schema.to_xml) end it "should output a schema element" do @document.at('schema').should_not be_nil end it "should output the schema name as an attribute" do @document.at('schema')['name'].should == 'user.schema' end it "should output the store attribute set to yes" do @document.at('schema')['store'].should == 'yes' end it "should output each of the fields as elements" do @schema.fields.each do |field| @document.at('schema').css('field').detect { |element| element['name'] == field.name.to_s }.should_not be_nil end end end end