yob-roxml 3.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/.gitignore +7 -0
  2. data/.gitmodules +3 -0
  3. data/History.txt +354 -0
  4. data/LICENSE +20 -0
  5. data/README.rdoc +195 -0
  6. data/Rakefile +117 -0
  7. data/TODO +37 -0
  8. data/VERSION +1 -0
  9. data/examples/amazon.rb +35 -0
  10. data/examples/current_weather.rb +27 -0
  11. data/examples/dashed_elements.rb +20 -0
  12. data/examples/library.rb +40 -0
  13. data/examples/posts.rb +27 -0
  14. data/examples/rails.rb +70 -0
  15. data/examples/twitter.rb +37 -0
  16. data/examples/xml/active_record.xml +70 -0
  17. data/examples/xml/amazon.xml +133 -0
  18. data/examples/xml/current_weather.xml +89 -0
  19. data/examples/xml/dashed_elements.xml +52 -0
  20. data/examples/xml/posts.xml +23 -0
  21. data/examples/xml/twitter.xml +422 -0
  22. data/lib/roxml.rb +556 -0
  23. data/lib/roxml/definition.rb +238 -0
  24. data/lib/roxml/hash_definition.rb +25 -0
  25. data/lib/roxml/xml.rb +40 -0
  26. data/lib/roxml/xml/parsers/libxml.rb +85 -0
  27. data/lib/roxml/xml/parsers/nokogiri.rb +82 -0
  28. data/lib/roxml/xml/references.rb +322 -0
  29. data/roxml.gemspec +206 -0
  30. data/spec/definition_spec.rb +494 -0
  31. data/spec/examples/active_record_spec.rb +40 -0
  32. data/spec/examples/amazon_spec.rb +54 -0
  33. data/spec/examples/current_weather_spec.rb +37 -0
  34. data/spec/examples/dashed_elements_spec.rb +20 -0
  35. data/spec/examples/library_spec.rb +46 -0
  36. data/spec/examples/post_spec.rb +24 -0
  37. data/spec/examples/twitter_spec.rb +32 -0
  38. data/spec/roxml_spec.rb +372 -0
  39. data/spec/shared_specs.rb +15 -0
  40. data/spec/spec.opts +1 -0
  41. data/spec/spec_helper.rb +14 -0
  42. data/spec/support/libxml.rb +3 -0
  43. data/spec/support/nokogiri.rb +3 -0
  44. data/spec/xml/array_spec.rb +36 -0
  45. data/spec/xml/attributes_spec.rb +71 -0
  46. data/spec/xml/encoding_spec.rb +52 -0
  47. data/spec/xml/namespace_spec.rb +270 -0
  48. data/spec/xml/namespaces_spec.rb +67 -0
  49. data/spec/xml/object_spec.rb +82 -0
  50. data/spec/xml/parser_spec.rb +21 -0
  51. data/spec/xml/text_spec.rb +71 -0
  52. data/test/fixtures/book_malformed.xml +5 -0
  53. data/test/fixtures/book_pair.xml +8 -0
  54. data/test/fixtures/book_text_with_attribute.xml +5 -0
  55. data/test/fixtures/book_valid.xml +5 -0
  56. data/test/fixtures/book_with_authors.xml +7 -0
  57. data/test/fixtures/book_with_contributions.xml +9 -0
  58. data/test/fixtures/book_with_contributors.xml +7 -0
  59. data/test/fixtures/book_with_contributors_attrs.xml +7 -0
  60. data/test/fixtures/book_with_default_namespace.xml +9 -0
  61. data/test/fixtures/book_with_depth.xml +6 -0
  62. data/test/fixtures/book_with_octal_pages.xml +4 -0
  63. data/test/fixtures/book_with_publisher.xml +7 -0
  64. data/test/fixtures/book_with_wrapped_attr.xml +3 -0
  65. data/test/fixtures/dictionary_of_attr_name_clashes.xml +8 -0
  66. data/test/fixtures/dictionary_of_attrs.xml +6 -0
  67. data/test/fixtures/dictionary_of_guarded_names.xml +6 -0
  68. data/test/fixtures/dictionary_of_mixeds.xml +4 -0
  69. data/test/fixtures/dictionary_of_name_clashes.xml +10 -0
  70. data/test/fixtures/dictionary_of_names.xml +4 -0
  71. data/test/fixtures/dictionary_of_texts.xml +10 -0
  72. data/test/fixtures/library.xml +30 -0
  73. data/test/fixtures/library_uppercase.xml +30 -0
  74. data/test/fixtures/muffins.xml +3 -0
  75. data/test/fixtures/nameless_ageless_youth.xml +2 -0
  76. data/test/fixtures/node_with_attr_name_conflicts.xml +1 -0
  77. data/test/fixtures/node_with_name_conflicts.xml +4 -0
  78. data/test/fixtures/numerology.xml +4 -0
  79. data/test/fixtures/person.xml +1 -0
  80. data/test/fixtures/person_with_guarded_mothers.xml +13 -0
  81. data/test/fixtures/person_with_mothers.xml +10 -0
  82. data/test/load_test.rb +6 -0
  83. data/test/mocks/dictionaries.rb +57 -0
  84. data/test/mocks/mocks.rb +279 -0
  85. data/test/support/fixtures.rb +11 -0
  86. data/test/test_helper.rb +34 -0
  87. data/test/unit/definition_test.rb +235 -0
  88. data/test/unit/deprecations_test.rb +24 -0
  89. data/test/unit/to_xml_test.rb +81 -0
  90. data/test/unit/xml_attribute_test.rb +39 -0
  91. data/test/unit/xml_block_test.rb +81 -0
  92. data/test/unit/xml_bool_test.rb +122 -0
  93. data/test/unit/xml_convention_test.rb +150 -0
  94. data/test/unit/xml_hash_test.rb +115 -0
  95. data/test/unit/xml_initialize_test.rb +49 -0
  96. data/test/unit/xml_name_test.rb +141 -0
  97. data/test/unit/xml_namespace_test.rb +31 -0
  98. data/test/unit/xml_object_test.rb +205 -0
  99. data/test/unit/xml_required_test.rb +94 -0
  100. data/test/unit/xml_text_test.rb +71 -0
  101. data/website/index.html +98 -0
  102. metadata +300 -0
@@ -0,0 +1,15 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "freezable xml reference", :shared => true do
4
+ describe "with :frozen option" do
5
+ it "should be frozen" do
6
+ @frozen.frozen?.should be_true
7
+ end
8
+ end
9
+
10
+ describe "without :frozen option" do
11
+ it "should not be frozen" do
12
+ @unfrozen.frozen?.should be_false
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'pathname'
3
+ require 'test/support/fixtures'
4
+ require 'lib/roxml'
5
+
6
+ require 'spec/shared_specs' if defined?(Spec)
7
+
8
+ def xml_for(name)
9
+ Pathname.new(File.dirname(__FILE__)).expand_path.dirname.join("examples/xml/#{name}.xml")
10
+ end
11
+
12
+ class RoxmlObject
13
+ include ROXML
14
+ end
@@ -0,0 +1,3 @@
1
+ module ROXML
2
+ XML_PARSER = 'libxml'
3
+ end
@@ -0,0 +1,3 @@
1
+ module ROXML
2
+ XML_PARSER = 'nokogiri'
3
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec/spec_helper'
2
+
3
+ module ArraySpec
4
+ class Book
5
+ include ROXML
6
+ xml_reader :id, :as => Integer
7
+ xml_reader :title
8
+ end
9
+
10
+ class Store
11
+ include ROXML
12
+ xml_reader :books, :from => 'books', :as => [Book]
13
+ end
14
+
15
+ class MyXml
16
+ include ROXML
17
+ xml_reader :store, :as => Store
18
+ end
19
+ end
20
+
21
+
22
+ describe ":as => []" do
23
+ context "with plural from" do
24
+ it "should accept the plural name as the name for each item" do
25
+ ArraySpec::MyXml.from_xml(%(
26
+ <myxml>
27
+ <store>
28
+ <books><id>1</id><title>first book</title></books>
29
+ <books><id>2</id><title>second book</title></books>
30
+ <books><id>3</id><title>third book</title></books>
31
+ </store>
32
+ </myxml>
33
+ )).store.books.size.should == 3
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe ROXML::XMLAttributeRef do
4
+ before do
5
+ @xml = ROXML::XML.parse_string %(
6
+ <myxml>
7
+ <node name="first" />
8
+ <node name="second" />
9
+ <node name="third" />
10
+ </myxml>)
11
+ end
12
+
13
+ context "plain vanilla" do
14
+ before do
15
+ @ref = ROXML::XMLAttributeRef.new(OpenStruct.new(:name => 'name', :wrapper => 'node', :array? => false), RoxmlObject.new)
16
+ end
17
+
18
+ it "should return one instance" do
19
+ @ref.value_in(@xml).should == "first"
20
+ end
21
+ it "should output one instance"
22
+ end
23
+
24
+ context "with :as => []" do
25
+ before do
26
+ @ref = ROXML::XMLAttributeRef.new(OpenStruct.new(:name => 'name', :wrapper => 'node', :array? => true), RoxmlObject.new)
27
+ end
28
+
29
+ it "should collect all instances" do
30
+ @ref.value_in(@xml).should == ["first", "second", "third"]
31
+ end
32
+
33
+ it "should output all instances" do
34
+ xml = ROXML::XML.new_node('myxml')
35
+ @ref.update_xml(xml, ["first", "second", "third"])
36
+ xml.to_s.squeeze(' ').should == @xml.root.to_s.squeeze(' ')
37
+ end
38
+ end
39
+
40
+ context "when the namespaces are different" do
41
+ before do
42
+ @xml = ROXML::XML.parse_string %(
43
+ <document>
44
+ <myxml xmlns="http://example.com/three" xmlns:one="http://example.com/one" xmlns:two="http://example.com/two">
45
+ <one:node name="first" />
46
+ <two:node name="second" />
47
+ <node name="third" />
48
+ </myxml>
49
+ </document>
50
+ )
51
+ end
52
+
53
+ context "with :namespace => '*'" do
54
+ before do
55
+ @ref = ROXML::XMLAttributeRef.new(OpenStruct.new(:name => 'name', :wrapper => 'node', :array? => true, :namespace => '*'), RoxmlObject.new)
56
+ end
57
+
58
+ it "should collect all instances" do
59
+ pending "Test bug?"
60
+ @ref.value_in(@xml).should == ["first", "second", "third"]
61
+ end
62
+
63
+ it "should output all instances with namespaces" do
64
+ pending "Full namespace write support"
65
+ xml = ROXML::XML.new_node('result')
66
+ @ref.update_xml(xml, ["first", "second", "third"])
67
+ xml.should == @xml.root
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe ROXML, "encoding" do
4
+ class TestResult
5
+ include ROXML
6
+ xml_accessor :message
7
+ end
8
+
9
+ context "when provided non-latin characters" do
10
+ it "should output those characters as input via methods" do
11
+ res = TestResult.new
12
+ res.message = "sadfk одловыа jjklsd " #random russian and english charecters
13
+ doc = ROXML::XML::Document.new
14
+ doc.root = res.to_xml
15
+ if defined?(Nokogiri)
16
+ doc.at('message').inner_text
17
+ else
18
+ doc.find_first('message').inner_xml
19
+ end.should == "sadfk одловыа jjklsd "
20
+ end
21
+
22
+ it "should output those characters as input via xml" do
23
+ res = TestResult.from_xml("<test_result><message>sadfk одловыа jjklsd </message></test_result>")
24
+ doc = ROXML::XML::Document.new
25
+ doc.root = res.to_xml
26
+ if defined?(Nokogiri)
27
+ doc.at('message').inner_text
28
+ else
29
+ doc.find_first('message').inner_xml
30
+ end.should == "sadfk одловыа jjklsd "
31
+ end
32
+
33
+ it "should allow override via the document" do
34
+ res = TestResult.from_xml("<test_result><message>sadfk одловыа jjklsd </message></test_result>")
35
+ if defined?(Nokogiri)
36
+ xml = res.to_xml
37
+ doc = xml.document
38
+ doc.root = xml
39
+ doc.encoding = 'ISO-8859-1'
40
+ doc.to_s.should include('ISO-8859-1')
41
+ doc.at('message').inner_text
42
+ else
43
+ doc = LibXML::XML::Document.new
44
+ doc.encoding = LibXML::XML::Encoding::ASCII
45
+ doc.root = res.to_xml
46
+ pending "Libxml bug"
47
+ doc.to_s.should include('ISO-8859-1')
48
+ doc.find_first('message').inner_xml
49
+ end.should == "sadfk одловыа jjklsd "
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,270 @@
1
+ require 'spec/spec_helper.rb'
2
+
3
+ describe ROXML, "with namespaces" do
4
+ describe "for writing" do
5
+ before do
6
+ @xml = <<EOS
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <gronk:VApp name="My new vApp" status="1" href="https://vcloud.example.com/vapp/833" type="application/vnd.vmware.vcloud.vapp+xml" xmlns:vmw="http://foo.example.com" xmlns:gronk="http://gronk.example.com">
9
+ <gronk:NetworkConfig name="Network 1">
10
+ <vmw:FenceMode>allowInOut</vmw:FenceMode>
11
+ <vmw:Dhcp>true</vmw:Dhcp>
12
+ <gronk:errors>
13
+ <gronk:error>OhNo!</gronk:error>
14
+ <gronk:error>Another!</gronk:error>
15
+ </gronk:errors>
16
+ </gronk:NetworkConfig>
17
+ <foo />
18
+ <bar>
19
+ gronk
20
+ </bar>
21
+ </gronk:VApp>
22
+ EOS
23
+ end
24
+
25
+ class NetworkConfig
26
+ include ROXML
27
+ xml_namespace :gronk
28
+
29
+ xml_name 'NetworkConfig'
30
+ xml_reader :name, :from => '@name'
31
+ xml_reader :errors, :as => []
32
+ xml_accessor :fence_mode, :from => 'vmw:FenceMode'
33
+ xml_accessor :dhcp?, :from => 'vmw:Dhcp'
34
+ end
35
+
36
+ class VApp
37
+ include ROXML
38
+ xml_namespace :gronk
39
+
40
+ xml_name "VApp"
41
+ xml_reader :name, :from => '@name'
42
+ xml_reader :status, :from => '@status'
43
+ xml_reader :href, :from => '@href'
44
+ xml_reader :type, :from => '@type'
45
+ xml_accessor :foo, :from => 'foo', :namespace => false
46
+ xml_accessor :bar, :from => 'bar', :namespace => false
47
+ xml_accessor :network_configs, :as => [NetworkConfig], :namespace => :gronk
48
+ end
49
+
50
+ describe "#to_xml" do
51
+ it "should reproduce the input xml" do
52
+ output = ROXML::XML::Document.new
53
+ output.root = VApp.from_xml(@xml).to_xml
54
+ pending "Full namespace write support"
55
+ output.should == ROXML::XML.parse_string(@xml)
56
+ end
57
+ end
58
+ end
59
+
60
+ describe "roxml namespacey declaration", :shared => true do
61
+ context "with a namespacey :from" do
62
+ context "and an explicit :namespace" do
63
+ it "should raise" do
64
+ proc do
65
+ Class.new do
66
+ include ROXML
67
+ xml_reader :default_namespace_with_namespacey_from_and_explicit_namespace, :from => 'namespacey:with_namespacey_from', :namespace => 'explicit'
68
+ end
69
+ end.should raise_error(ROXML::ContradictoryNamespaces)
70
+ end
71
+ end
72
+
73
+ context "and :namespace => false" do
74
+ it "should raise" do
75
+ proc do
76
+ Class.new do
77
+ include ROXML
78
+ xml_reader :default_namespace_with_namespacey_from_and_namespace_false, :from => 'namespacey:with_namespacey_from', :namespace => false
79
+ end
80
+ end.should raise_error(ROXML::ContradictoryNamespaces)
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ describe "roxml namespacey declaration with default", :shared => true do
87
+ it_should_behave_like "roxml namespacey declaration"
88
+
89
+ it "should use the default namespace" do
90
+ @instance.default_namespace.should == 'default namespace node'
91
+ end
92
+
93
+ context "and :namespace => false" do
94
+ it "should find the namespace-less node" do
95
+ @instance.default_namespace_with_namespace_false.should == 'namespaceless node'
96
+ end
97
+ end
98
+
99
+ context "with an explicit :namespace" do
100
+ it "should use the explicit namespace" do
101
+ @instance.default_and_explicit_namespace == 'explicit namespace node'
102
+ end
103
+ end
104
+
105
+ context "with a namespace-less :from" do
106
+ it "should use the default namespace" do
107
+ @instance.default_namespace_with_namespaceless_from.should == 'default namespace node'
108
+ end
109
+
110
+ context "and :namespace => false" do
111
+ it "should find the namespace-less node" do
112
+ @instance.default_namespace_with_namespaceless_from_and_namespace_false.should == 'namespaceless node'
113
+ end
114
+ end
115
+
116
+ context "and an explicit :namespace" do
117
+ it "should use the explicit namespace" do
118
+ @instance.default_namespace_with_namespaceless_from_and_explicit_namespace.should == 'explicit namespace node'
119
+ end
120
+ end
121
+ end
122
+
123
+ context "with a namespacey :from" do
124
+ it "should use the :from namespace" do
125
+ @instance.default_namespace_with_namespacey_from.should == 'namespacey node'
126
+ end
127
+ end
128
+ end
129
+
130
+ context "with a default namespace declared" do
131
+ class DefaultNamespaceyObject
132
+ include ROXML
133
+ xml_namespace :default_declared
134
+
135
+ xml_reader :default_namespace
136
+ xml_reader :default_namespace_with_namespace_false, :namespace => false
137
+ xml_reader :default_and_explicit_namespace, :namespace => 'explicit'
138
+ xml_reader :default_namespace_with_namespaceless_from, :from => 'with_namespaceless_from'
139
+ xml_reader :default_namespace_with_namespaceless_from_and_explicit_namespace, :from => 'with_namespaceless_from', :namespace => 'explicit'
140
+ xml_reader :default_namespace_with_namespaceless_from_and_namespace_false, :from => 'with_namespaceless_from', :namespace => false
141
+ xml_reader :default_namespace_with_namespacey_from, :from => 'namespacey:with_namespacey_from'
142
+
143
+ # These are handled in the "roxml namespacey declaration" shared spec
144
+ # xml_reader :default_namespace_with_namespacey_from_and_namespace_false, :from => 'namespacey:with_namespaceless_from', :namespace => false
145
+ # xml_reader :default_namespace_with_namespacey_from_and_explicit_namespace, :from => 'namespacey:with_namespaceless_from', :namespace => 'explicit'
146
+ end
147
+
148
+ before do
149
+ @instance = DefaultNamespaceyObject.from_xml(%{
150
+ <book xmlns:namespacey="http://www.aws.com/aws" xmlns:default_declared="http://www.aws.com/default" xmlns:explicit="http://www.aws.com/different">
151
+ <default_declared:default_namespace>default namespace node</default_declared:default_namespace>
152
+ <namespacey:with_namespacey_from>namespacey node</namespacey:with_namespacey_from>
153
+ <explicit:with_namespaceless_from>explicit namespace node</explicit:with_namespaceless_from>
154
+ <with_namespaceless_from>namespaceless node</with_namespaceless_from>
155
+ <default_declared:with_namespaceless_from>default namespace node</default_declared:with_namespaceless_from>
156
+ <explicit:default_and_explicit_namespace>explicit namespace node</explicit:default_and_explicit_namespace>
157
+ <default_namespace_with_namespace_false>namespaceless node</default_namespace_with_namespace_false>
158
+ </book>
159
+ })
160
+ end
161
+
162
+ it_should_behave_like "roxml namespacey declaration with default"
163
+ end
164
+
165
+ context "with a default namespace on the root node" do
166
+ class XmlDefaultNamespaceyObject
167
+ include ROXML
168
+ xml_reader :default_namespace
169
+ xml_reader :default_namespace_with_namespace_false, :namespace => false
170
+ xml_reader :default_and_explicit_namespace, :namespace => 'explicit'
171
+ xml_reader :default_namespace_with_namespaceless_from, :from => 'with_namespaceless_from'
172
+ xml_reader :default_namespace_with_namespaceless_from_and_explicit_namespace, :from => 'with_namespaceless_from', :namespace => 'explicit'
173
+ xml_reader :default_namespace_with_namespaceless_from_and_namespace_false, :from => 'with_namespaceless_from', :namespace => false
174
+ xml_reader :default_namespace_with_namespacey_from, :from => 'namespacey:with_namespacey_from'
175
+
176
+ # These are handled in the "roxml namespacey declaration" shared spec
177
+ # xml_reader :default_namespace_with_namespacey_from_and_namespace_false, :from => 'namespacey:with_namespaceless_from', :namespace => false
178
+ # xml_reader :default_namespace_with_namespacey_from_and_explicit_namespace, :from => 'namespacey:with_namespaceless_from', :namespace => 'explicit'
179
+ end
180
+
181
+ before do
182
+ @instance = XmlDefaultNamespaceyObject.from_xml(%{
183
+ <book xmlns="http://www.aws.com/xml_default" xmlns:namespacey="http://www.aws.com/aws" xmlns:default_declared="http://www.aws.com/default" xmlns:explicit="http://www.aws.com/different">
184
+ <default_namespace>default namespace node</default_namespace>
185
+ <namespacey:with_namespacey_from>namespacey node</namespacey:with_namespacey_from>
186
+ <explicit:with_namespaceless_from>explicit namespace node</explicit:with_namespaceless_from>
187
+ <with_namespaceless_from xmlns="">namespaceless node</with_namespaceless_from>
188
+ <with_namespaceless_from>default namespace node</with_namespaceless_from>
189
+ <explicit:default_and_explicit_namespace>explicit namespace node</explicit:default_and_explicit_namespace>
190
+ <default_namespace_with_namespace_false xmlns="">namespaceless node</default_namespace_with_namespace_false>
191
+ </book>
192
+ })
193
+ end
194
+
195
+ it_should_behave_like "roxml namespacey declaration with default"
196
+ end
197
+
198
+ context "without a default namespace" do
199
+ class NamespaceyObject
200
+ include ROXML
201
+
202
+ xml_reader :no_default_namespace
203
+ xml_reader :no_default_namespace_with_namespace_false, :namespace => false
204
+ xml_reader :no_default_but_an_explicit_namespace, :namespace => 'explicit'
205
+ xml_reader :no_default_namespace_with_namespaceless_from, :from => 'with_namespaceless_from'
206
+ xml_reader :no_default_namespace_with_namespaceless_from_and_explicit_namespace, :from => 'with_namespaceless_from', :namespace => 'explicit'
207
+ xml_reader :no_default_namespace_with_namespaceless_from_and_namespace_false, :from => 'with_namespaceless_from', :namespace => false
208
+ xml_reader :no_default_namespace_with_namespacey_from, :from => 'namespacey:with_namespacey_from'
209
+
210
+ # These are handled in the "roxml namespacey declaration" shared spec
211
+ # xml_reader :no_default_namespace_with_namespacey_from_and_explicit_namespace, :from => 'namespacey:with_namespacey_from', :namespace => 'explicit'
212
+ # xml_reader :no_default_namespace_with_namespacey_from_and_namespace_false, :from => 'namespacey:with_namespacey_from', :namespace => false
213
+ end
214
+
215
+ before do
216
+ @instance = NamespaceyObject.from_xml(%{
217
+ <book xmlns:namespacey="http://www.aws.com/aws" xmlns:explicit="http://www.aws.com/different">
218
+ <namespacey:with_namespacey_from>namespacey node</namespacey:with_namespacey_from>
219
+ <explicit:with_namespaceless_from>explicit namespace node</explicit:with_namespaceless_from>
220
+ <with_namespaceless_from>namespaceless node</with_namespaceless_from>
221
+ <explicit:no_default_but_an_explicit_namespace>explicit namespace node</explicit:no_default_but_an_explicit_namespace>
222
+ <no_default_namespace_with_namespace_false>namespaceless node</no_default_namespace_with_namespace_false>
223
+ <no_default_namespace>namespaceless node</no_default_namespace>
224
+ </book>
225
+ })
226
+ end
227
+
228
+ it_should_behave_like "roxml namespacey declaration"
229
+
230
+ it "should find the namespace-less node" do
231
+ @instance.no_default_namespace.should == 'namespaceless node'
232
+ end
233
+
234
+ context "with :namespace => false" do
235
+ it "should find the namespace-less node" do
236
+ @instance.no_default_namespace_with_namespace_false.should == 'namespaceless node'
237
+ end
238
+ end
239
+
240
+ context "with an explicit :namespace" do
241
+ it "should use the explicit namespace" do
242
+ @instance.no_default_but_an_explicit_namespace.should == 'explicit namespace node'
243
+ end
244
+ end
245
+
246
+ context "with a namespace-less :from" do
247
+ it "should find the namespace-less node" do
248
+ @instance.no_default_namespace_with_namespaceless_from.should == 'namespaceless node'
249
+ end
250
+
251
+ context "and an explicit :namespace" do
252
+ it "should use the explicit namespace" do
253
+ @instance.no_default_namespace_with_namespaceless_from_and_explicit_namespace.should == 'explicit namespace node'
254
+ end
255
+ end
256
+
257
+ context "with :namespace => false" do
258
+ it "should find the namespace-less node" do
259
+ @instance.no_default_namespace_with_namespaceless_from_and_namespace_false.should == 'namespaceless node'
260
+ end
261
+ end
262
+ end
263
+
264
+ context "with a namespacey :from" do
265
+ it "should use the :from namespace" do
266
+ @instance.no_default_namespace_with_namespacey_from.should == 'namespacey node'
267
+ end
268
+ end
269
+ end
270
+ end