Sha256: c55ab3b0d09e6aabd37e968f5f7742cbb2b8dba87a1f866cec5c94ac4dfba104

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'spec/spec_helper'

describe CloudQuery::Field do
  it "should initialize with a name and type" do
    field = CloudQuery::Field.new(:name, :string)
    
    field.name.should == :name
    field.type.should == :string
  end
  
  describe "#.to_node" do
    before :each do
      @field = CloudQuery::Field.new(:name, :string)
      @builder = Nokogiri::XML::Builder.new { |doc|
        @field.to_node(doc)
      }
    end
    
    it "should append a field element" do
      @builder.doc.at('field').should_not be_nil
    end
    
    it "should set the name attribute" do
      @builder.doc.at('field')['name'].should == 'name'
    end
    
    it "should set the type attribute" do
      @builder.doc.at('field')['type'].should == 'string'
    end
    
    it "should set the usage attribute if one is provided" do
      @field.usage = 'user'
      @builder = Nokogiri::XML::Builder.new { |doc|
        @field.to_node(doc)
      }
      @builder.doc.at('field')['usage'].should == 'user'
    end
    
    it "should not have a usage attribute if not set" do
      @builder.doc.at('field')['usage'].should be_nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xoopit-cloud_query-0.2.0 spec/lib/cloud_query/field_spec.rb
xoopit-cloud_query-0.2.1 spec/lib/cloud_query/field_spec.rb