test/unit/service/serialization_test.rb in azure-0.7.0 vs test/unit/service/serialization_test.rb in azure-0.7.1

- old
+ new

@@ -34,31 +34,31 @@ let(:signed_identifiers_xml) { Fixtures["container_acl"]} it "accepts an XML string" do subject.signed_identifiers_from_xml signed_identifiers_xml end - + it "returns an Array of SignedIdentifier instances" do results = subject.signed_identifiers_from_xml signed_identifiers_xml results.must_be_kind_of Array results[0].must_be_kind_of Azure::Service::SignedIdentifier results.count.must_equal 1 end end describe "#signed_identifiers_to_xml" do - let(:signed_identifiers) { + let(:signed_identifiers) { identifier = Azure::Service::SignedIdentifier.new identifier.id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=" identifier.access_policy.start = "2009-09-28T08:49:37.0000000Z" identifier.access_policy.expiry = "2009-09-29T08:49:37.0000000Z" identifier.access_policy.permission = "rwd" [identifier] } - + let(:signed_identifiers_xml) { Fixtures["container_acl"]} - + it "accepts a list of SignedIdentifier instances" do subject.signed_identifiers_to_xml signed_identifiers end it "returns a XML graph of the provided values" do @@ -73,11 +73,11 @@ before { subject.expects(:access_policy_from_xml).with(signed_identifier_xml.AccessPolicy).returns(mock_access_policy) } it "accepts an XML node" do subject.signed_identifier_from_xml signed_identifier_xml end - + it "returns a SignedIdentifier instance" do identifier = subject.signed_identifier_from_xml signed_identifier_xml identifier.must_be_kind_of Azure::Service::SignedIdentifier end @@ -92,11 +92,11 @@ let(:access_policy_xml) { Nokogiri.Slop(Fixtures["container_acl"]).root.SignedIdentifier.AccessPolicy } it "accepts an XML node" do subject.access_policy_from_xml access_policy_xml end - + it "returns a AccessPolicy instance" do access_policy = subject.access_policy_from_xml access_policy_xml access_policy.must_be_kind_of Azure::Service::AccessPolicy end @@ -113,11 +113,11 @@ describe "#enumeration_results_from_xml" do let(:enumeration_results_xml) { Fixtures[:list_containers] } describe "when passed an instance of EnumerationResults" do let(:enumeration_results) { Azure::Service::EnumerationResults.new } - + it "parses the XML and populates the provided EnumerationResults instance" do result = subject.enumeration_results_from_xml enumeration_results_xml, enumeration_results result.must_be :kind_of?, Azure::Service::EnumerationResults result.continuation_token.must_equal "video" end @@ -187,20 +187,20 @@ hash["MyMetadata2"].must_equal "second value" end end describe "#retention_policy_to_xml" do - let(:retention_policy) { + let(:retention_policy) { retention_policy = Azure::Service::RetentionPolicy.new retention_policy.enabled = true retention_policy.days = 7 - + retention_policy } - + let(:retention_policy_xml) { Fixtures["retention_policy"]} - + it "accepts a RetentionPolicy instance and an Nokogiri::XML::Builder instance" do Nokogiri::XML::Builder.new do |xml| subject.retention_policy_to_xml retention_policy, xml end end @@ -213,15 +213,15 @@ end end describe "#retention_policy_from_xml" do let(:retention_policy_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.HourMetrics.RetentionPolicy } - + it "accepts an XML Node" do subject.retention_policy_from_xml retention_policy_xml end - + it "returns an RetentionPolicy instance" do retention_policy = subject.retention_policy_from_xml retention_policy_xml retention_policy.wont_be_nil retention_policy.must_be_kind_of Azure::Service::RetentionPolicy end @@ -232,24 +232,24 @@ retention_policy.days.must_equal 7 end end describe "#hour_metrics_to_xml" do - let(:metrics) { + let(:metrics) { metrics = Azure::Service::Metrics.new metrics.version = "1.0" metrics.enabled = true metrics.include_apis = false retention_policy = metrics.retention_policy = Azure::Service::RetentionPolicy.new retention_policy.enabled = true retention_policy.days = 7 - + metrics } - + let(:metrics_xml) { Fixtures["metrics"]} - + it "accepts a Metrics instance and an Nokogiri::XML::Builder instance" do Nokogiri::XML::Builder.new do |xml| subject.hour_metrics_to_xml metrics, xml end end @@ -259,23 +259,23 @@ subject.hour_metrics_to_xml metrics, xml end builder.to_xml.must_equal metrics_xml end end - + describe "#metrics_from_xml" do let(:metrics_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.HourMetrics } let(:mock_retention_policy) { mock } - before { + before { subject.expects(:retention_policy_from_xml).returns(mock_retention_policy) } - + it "accepts an XML Node" do subject.metrics_from_xml metrics_xml end - + it "returns an Metrics instance" do metrics = subject.metrics_from_xml metrics_xml metrics.wont_be_nil metrics.must_be_kind_of Azure::Service::Metrics end @@ -287,28 +287,28 @@ metrics.include_apis.must_equal false metrics.retention_policy.must_equal mock_retention_policy end end - + describe "#logging_to_xml" do - let(:logging) { + let(:logging) { logging = Azure::Service::Logging.new logging.version = "1.0" logging.delete = true logging.read = false logging.write = true retention_policy = logging.retention_policy = Azure::Service::RetentionPolicy.new retention_policy.enabled = true retention_policy.days = 7 - + logging } - + let(:logging_xml) { Fixtures["logging"]} - + it "accepts a Logging instance and an Nokogiri::XML::Builder instance" do Nokogiri::XML::Builder.new do |xml| subject.logging_to_xml logging, xml end end @@ -323,18 +323,18 @@ describe "#logging_from_xml" do let(:logging_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.Logging } let(:mock_retention_policy) { mock } - before { + before { subject.expects(:retention_policy_from_xml).returns(mock_retention_policy) } - + it "accepts an XML Node" do subject.logging_from_xml logging_xml end - + it "returns an Logging instance" do logging = subject.logging_from_xml logging_xml logging.wont_be_nil logging.must_be_kind_of Azure::Service::Logging end @@ -348,11 +348,11 @@ logging.retention_policy.must_equal mock_retention_policy end end describe "#service_properties_to_xml" do - let(:service_properties) { + let(:service_properties) { service_properties = Azure::Service::StorageServiceProperties.new service_properties.default_service_version = "2011-08-18" logging = service_properties.logging = Azure::Service::Logging.new logging.version = "1.0" logging.delete = true @@ -399,13 +399,13 @@ }) end service_properties } - + let(:service_properties_xml) { Fixtures["storage_service_properties"]} - + it "accepts a StorageServiceProperties instance" do subject.service_properties_to_xml service_properties end it "returns a XML graph of the provided values" do @@ -418,20 +418,20 @@ let(:service_properties_xml) { Fixtures["storage_service_properties"]} let(:mock_logging) { mock } let(:mock_metrics) { mock } let(:mock_cors) { mock } - before { + before { subject.expects(:logging_from_xml).returns(mock_logging) subject.expects(:metrics_from_xml).twice.returns(mock_metrics) subject.expects(:cors_from_xml).returns(mock_cors) } - + it "accepts an XML string" do subject.service_properties_from_xml service_properties_xml end - + it "returns an StorageServiceProperties instance" do service_properties = subject.service_properties_from_xml service_properties_xml service_properties.wont_be_nil service_properties.must_be_kind_of Azure::Service::StorageServiceProperties end @@ -467,47 +467,47 @@ describe "#slopify" do let(:xml_data) { '<?xml version="1.0" encoding="utf-8"?><Foo></Foo>' } let(:document) { Nokogiri.Slop xml_data } let(:root_node) { document.root } let(:non_slop_node) { Nokogiri.parse(xml_data).root } - + describe "when passed a String" do - it "parses the string into a Nokogiri::XML::Element node" do + it "parses the string into a Nokogiri::XML::Element node" do result = subject.slopify(xml_data) result.must_be_kind_of Nokogiri::XML::Element end - - it "returns the root of the parsed Document" do + + it "returns the root of the parsed Document" do result = subject.slopify(xml_data) result.name.must_equal root_node.name end it "enables Nokogiri 'Slop' mode on the returned Element" do result = subject.slopify(xml_data) result.must_respond_to :method_missing end end - + describe "when passed a Nokogiri::XML::Document" do - it "returns a Nokogiri::XML::Element node" do + it "returns a Nokogiri::XML::Element node" do result = subject.slopify(document) result.must_be_kind_of Nokogiri::XML::Element end - it "returns the root of the Document" do + it "returns the root of the Document" do result = subject.slopify(document) result.name.must_equal root_node.name end - + it "enables Nokogiri 'Slop' mode on the returned Element" do result = subject.slopify(xml_data) result.must_respond_to :method_missing end end describe "when passed a Nokogiri::XML::Element" do - it "returns the Element unchanged" do + it "returns the Element unchanged" do result = subject.slopify(root_node) result.must_equal root_node end it "does not enable Nokogiri 'Slop' mode on the returned Element if it didn't already have it" do \ No newline at end of file