nokogiri-happymapper 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/CHANGELOG.md +5 -1
- data/README.md +74 -53
- data/lib/happymapper/anonymous_mapper.rb +114 -0
- data/lib/happymapper/attribute.rb +20 -2
- data/lib/happymapper/element.rb +52 -2
- data/lib/happymapper/item.rb +89 -182
- data/lib/happymapper/supported_types.rb +140 -0
- data/lib/happymapper/text_node.rb +6 -1
- data/lib/happymapper/version.rb +3 -0
- data/lib/happymapper.rb +42 -22
- data/spec/attribute_default_value_spec.rb +50 -0
- data/spec/fixtures/default_namespace_combi.xml +2 -1
- data/spec/happymapper/attribute_spec.rb +12 -0
- data/spec/happymapper/element_spec.rb +9 -0
- data/spec/{happymapper_item_spec.rb → happymapper/item_spec.rb} +5 -5
- data/spec/happymapper/text_node_spec.rb +9 -0
- data/spec/happymapper_parse_spec.rb +87 -0
- data/spec/happymapper_spec.rb +9 -3
- data/spec/ignay_spec.rb +22 -22
- data/spec/inheritance_spec.rb +61 -0
- data/spec/parse_with_object_to_update_spec.rb +111 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/to_xml_spec.rb +200 -0
- data/spec/to_xml_with_namespaces_spec.rb +196 -0
- data/spec/wilcard_tag_name_spec.rb +96 -0
- data/spec/wrap_spec.rb +82 -0
- data/spec/xpath_spec.rb +60 -59
- metadata +34 -33
- data/TODO +0 -0
- data/spec/happymapper_attribute_spec.rb +0 -21
- data/spec/happymapper_element_spec.rb +0 -21
- data/spec/happymapper_generic_base_spec.rb +0 -92
- data/spec/happymapper_text_node_spec.rb +0 -21
- data/spec/happymapper_to_xml_namespaces_spec.rb +0 -196
- data/spec/happymapper_to_xml_spec.rb +0 -203
- data/spec/happymapper_wrap_spec.rb +0 -69
- data/spec/parse_instance_spec.rb +0 -129
data/spec/parse_instance_spec.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
parse_instance_initial_xml = %{
|
4
|
-
<root attr1="initial">
|
5
|
-
<item attr1="initial">
|
6
|
-
<description>initial</description>
|
7
|
-
<subitem attr1="initial">
|
8
|
-
<name>initial</name>
|
9
|
-
</subitem>
|
10
|
-
<subitem attr1="initial">
|
11
|
-
<name>initial</name>
|
12
|
-
</subitem>
|
13
|
-
</item>
|
14
|
-
<item attr1="initial">
|
15
|
-
<description>initial</description>
|
16
|
-
<subitem attr1="initial">
|
17
|
-
<name>initial</name>
|
18
|
-
</subitem>
|
19
|
-
<subitem attr1="initial">
|
20
|
-
<name>initial</name>
|
21
|
-
</subitem>
|
22
|
-
</item>
|
23
|
-
</root>
|
24
|
-
}
|
25
|
-
|
26
|
-
parse_instance_updated_xml = %{
|
27
|
-
<root attr1="updated">
|
28
|
-
<item attr1="updated">
|
29
|
-
<description>updated</description>
|
30
|
-
<subitem attr1="updated">
|
31
|
-
<name>updated</name>
|
32
|
-
</subitem>
|
33
|
-
<subitem attr1="updated">
|
34
|
-
<name>updated</name>
|
35
|
-
</subitem>
|
36
|
-
</item>
|
37
|
-
<item attr1="updated">
|
38
|
-
<description>updated</description>
|
39
|
-
<subitem attr1="updated">
|
40
|
-
<name>updated</name>
|
41
|
-
</subitem>
|
42
|
-
<subitem attr1="updated">
|
43
|
-
<name>updated</name>
|
44
|
-
</subitem>
|
45
|
-
</item>
|
46
|
-
</root>
|
47
|
-
}
|
48
|
-
|
49
|
-
module ParseInstanceSpec
|
50
|
-
class SubItem
|
51
|
-
include HappyMapper
|
52
|
-
tag 'subitem'
|
53
|
-
attribute :attr1, String
|
54
|
-
element :name, String
|
55
|
-
end
|
56
|
-
class Item
|
57
|
-
include HappyMapper
|
58
|
-
tag 'item'
|
59
|
-
attribute :attr1, String
|
60
|
-
element :description, String
|
61
|
-
has_many :sub_items, SubItem
|
62
|
-
end
|
63
|
-
class Root
|
64
|
-
include HappyMapper
|
65
|
-
tag 'root'
|
66
|
-
attribute :attr1, String
|
67
|
-
has_many :items, Item
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe HappyMapper do
|
72
|
-
describe "update existing instance by parsing new xml" do
|
73
|
-
|
74
|
-
it 'should have initial values' do
|
75
|
-
@initial.attr1.should == 'initial'
|
76
|
-
@initial.items[0].attr1.should == 'initial'
|
77
|
-
@initial.items[0].description.should == 'initial'
|
78
|
-
@initial.items[0].sub_items[0].attr1.should == 'initial'
|
79
|
-
@initial.items[0].sub_items[0].name.should == 'initial'
|
80
|
-
@initial.items[0].sub_items[1].attr1.should == 'initial'
|
81
|
-
@initial.items[0].sub_items[1].name.should == 'initial'
|
82
|
-
@initial.items[1].attr1.should == 'initial'
|
83
|
-
@initial.items[1].description.should == 'initial'
|
84
|
-
@initial.items[1].sub_items[0].attr1.should == 'initial'
|
85
|
-
@initial.items[1].sub_items[0].name.should == 'initial'
|
86
|
-
@initial.items[1].sub_items[1].attr1.should == 'initial'
|
87
|
-
@initial.items[1].sub_items[1].name.should == 'initial'
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should have updated values' do
|
91
|
-
ParseInstanceSpec::Root.parse(parse_instance_updated_xml, :update => @initial)
|
92
|
-
@initial.attr1.should == 'updated'
|
93
|
-
@initial.items[0].attr1.should == 'updated'
|
94
|
-
@initial.items[0].description.should == 'updated'
|
95
|
-
@initial.items[0].sub_items[0].attr1.should == 'updated'
|
96
|
-
@initial.items[0].sub_items[0].name.should == 'updated'
|
97
|
-
@initial.items[0].sub_items[1].attr1.should == 'updated'
|
98
|
-
@initial.items[0].sub_items[1].name.should == 'updated'
|
99
|
-
@initial.items[1].attr1.should == 'updated'
|
100
|
-
@initial.items[1].description.should == 'updated'
|
101
|
-
@initial.items[1].sub_items[0].attr1.should == 'updated'
|
102
|
-
@initial.items[1].sub_items[0].name.should == 'updated'
|
103
|
-
@initial.items[1].sub_items[1].attr1.should == 'updated'
|
104
|
-
@initial.items[1].sub_items[1].name.should == 'updated'
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should be able to update instance from 'parse()' instance method" do
|
108
|
-
@initial.parse(parse_instance_updated_xml)
|
109
|
-
@initial.attr1.should == 'updated'
|
110
|
-
@initial.items[0].attr1.should == 'updated'
|
111
|
-
@initial.items[0].description.should == 'updated'
|
112
|
-
@initial.items[0].sub_items[0].attr1.should == 'updated'
|
113
|
-
@initial.items[0].sub_items[0].name.should == 'updated'
|
114
|
-
@initial.items[0].sub_items[1].attr1.should == 'updated'
|
115
|
-
@initial.items[0].sub_items[1].name.should == 'updated'
|
116
|
-
@initial.items[1].attr1.should == 'updated'
|
117
|
-
@initial.items[1].description.should == 'updated'
|
118
|
-
@initial.items[1].sub_items[0].attr1.should == 'updated'
|
119
|
-
@initial.items[1].sub_items[0].name.should == 'updated'
|
120
|
-
@initial.items[1].sub_items[1].attr1.should == 'updated'
|
121
|
-
@initial.items[1].sub_items[1].name.should == 'updated'
|
122
|
-
end
|
123
|
-
|
124
|
-
before(:each) do
|
125
|
-
@initial = ParseInstanceSpec::Root.parse(parse_instance_initial_xml)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|