File: array_spec.rb

package info (click to toggle)
ruby-roxml 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 800 kB
  • sloc: ruby: 4,133; xml: 1,013; makefile: 7
file content (36 lines) | stat: -rw-r--r-- 775 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'spec_helper'

module ArraySpec
  class Book
    include ROXML
    xml_reader :id, :as => Integer
    xml_reader :title
  end

  class Store
    include ROXML
    xml_reader :books, :from => 'books', :as => [Book]
  end

  class MyXml
    include ROXML
    xml_reader :store, :as => Store
  end
end


describe ":as => []" do
  context "with plural from" do
    it "should accept the plural name as the name for each item" do
      expect(ArraySpec::MyXml.from_xml(%(
      <myxml>
        <store>
          <books><id>1</id><title>first book</title></books>
          <books><id>2</id><title>second book</title></books>
          <books><id>3</id><title>third book</title></books>
        </store>
      </myxml>
      )).store.books.size).to eq(3)
    end
  end
end