Sha256: 291b87352f783daafa414506606fffa9bf574ca0b81de8cb0e621e8a9f331cb3

Contents?: true

Size: 1.41 KB

Versions: 49

Compression:

Stored size: 1.41 KB

Contents

Shindo.tests('Fog::Parsers', 'core') do

  class TestParser < Fog::Parsers::Base
    def reset
      super
      reset_my_array
    end

    def reset_my_array
      @my_array = []
    end

    def end_element(name)
      case name
      when 'key1', 'key2', 'key3', 'longText'
        @response[name] = value
      when 'myArray'
        @response[name] = @my_array
        reset_my_array
      when 'id'
        @my_array << value.to_i
      end

    end
  end

  @xml = %{
<MyResponse>
  <MyObject>
    <key1>value1</key1>
    <key2>value2</key2>
    <myArray>
      <id>1</id>
      <id>2</id>
      <id>3</id>
    </myArray>
    <longText>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec quis metus arcu, quis cursus turpis.
Aliquam leo lacus, luctus vel iaculis id,
posuere eu odio. Donec sodales, ante porta condimentum
</longText>
    <key3>value3</key3>
  </MyObject>
<MyResponse>
}

  @response = {
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3',
    'myArray' => [1,2,3],
    'longText' => %{
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec quis metus arcu, quis cursus turpis.
Aliquam leo lacus, luctus vel iaculis id,
posuere eu odio. Donec sodales, ante porta condimentum
}
  }


  tests('TestParser').returns(@response, "returns the response") do
    test_parser = TestParser.new
    Nokogiri::XML::SAX::Parser.new(test_parser).parse(@xml)
    test_parser.response
  end
end

Version data entries

49 entries across 49 versions & 14 rubygems

Version Path
fog-nirvanix-1.8.2 tests/core/parser_tests.rb
fog-nirvanix-1.8.1 tests/core/parser_tests.rb
fog-parser-fix-1.6.1 tests/core/parser_tests.rb
fog-test-again-1.6.0 tests/core/parser_tests.rb
fog-parser-fix-1.6.0 tests/core/parser_tests.rb
fog-maestrodev-1.8.0.20130114204828 tests/core/parser_tests.rb
fog-maestrodev-1.8.0.20130111070250 tests/core/parser_tests.rb
fog-maestrodev-1.8.0.20130109172219 tests/core/parser_tests.rb
fog-sgonyea-1.8.1 tests/core/parser_tests.rb
fog-1.8.0 tests/core/parser_tests.rb
fog-maestrodev-1.7.0.20121114190951 tests/core/parser_tests.rb
fog-1.7.0 tests/core/parser_tests.rb
fog-1.6.0 tests/core/parser_tests.rb
fog-1.5.0 tests/core/parser_tests.rb
rackspace-fog-1.4.2 tests/core/parser_tests.rb
fog-1.4.0 tests/core/parser_tests.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/tests/core/parser_tests.rb
michiels-fog-1.3.1 tests/core/parser_tests.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/tests/core/parser_tests.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/tests/core/parser_tests.rb