roxml 3.3.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +7 -0
- data/Gemfile +9 -6
- data/Gemfile.lock +96 -40
- data/History.txt +9 -0
- data/README.rdoc +3 -2
- data/Rakefile +6 -9
- data/VERSION +1 -1
- data/examples/search_query.rb +17 -0
- data/lib/roxml.rb +8 -2
- data/lib/roxml/definition.rb +2 -7
- data/lib/roxml/xml/references.rb +22 -7
- data/roxml.gemspec +48 -36
- data/spec/definition_spec.rb +81 -101
- data/spec/examples/active_record_spec.rb +13 -13
- data/spec/examples/amazon_spec.rb +13 -13
- data/spec/examples/current_weather_spec.rb +6 -6
- data/spec/examples/dashed_elements_spec.rb +3 -3
- data/spec/examples/library_spec.rb +3 -3
- data/spec/examples/library_with_fines_spec.rb +7 -7
- data/spec/examples/person_spec.rb +3 -3
- data/spec/examples/post_spec.rb +4 -4
- data/spec/examples/search_query_spec.rb +26 -0
- data/spec/examples/twitter_spec.rb +4 -4
- data/spec/reference_spec.rb +2 -2
- data/spec/regression_spec.rb +13 -8
- data/spec/roxml_spec.rb +30 -43
- data/spec/shared_specs.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/xml/array_spec.rb +2 -2
- data/spec/xml/attributes_spec.rb +7 -7
- data/spec/xml/encoding_spec.rb +9 -9
- data/spec/xml/namespace_spec.rb +40 -21
- data/spec/xml/namespaces_spec.rb +3 -3
- data/spec/xml/object_spec.rb +7 -7
- data/spec/xml/parser_spec.rb +2 -2
- data/spec/xml/text_spec.rb +6 -6
- data/test/fixtures/book_with_octal_pages.xml +2 -3
- data/test/test_helper.rb +1 -2
- data/test/unit/definition_test.rb +26 -27
- data/test/unit/deprecations_test.rb +23 -2
- data/test/unit/to_xml_test.rb +7 -7
- data/test/unit/xml_attribute_test.rb +3 -2
- data/test/unit/xml_block_test.rb +3 -2
- data/test/unit/xml_bool_test.rb +7 -8
- data/test/unit/xml_convention_test.rb +4 -3
- data/test/unit/xml_hash_test.rb +5 -13
- data/test/unit/xml_initialize_test.rb +4 -3
- data/test/unit/xml_name_test.rb +3 -2
- data/test/unit/xml_namespace_test.rb +4 -3
- data/test/unit/xml_object_test.rb +8 -7
- data/test/unit/xml_required_test.rb +7 -6
- data/test/unit/xml_text_test.rb +3 -2
- data/website/index.html +11 -11
- metadata +115 -60
@@ -8,26 +8,26 @@ describe PITA::ItemSearchResponse do
|
|
8
8
|
|
9
9
|
describe "#total_results" do
|
10
10
|
it "should be parsed as a number" do
|
11
|
-
@response.total_results.
|
11
|
+
expect(@response.total_results).to be > 0
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#total_pages" do
|
16
16
|
it "should be parsed as a number" do
|
17
|
-
@response.total_pages.
|
17
|
+
expect(@response.total_pages).to be > 0
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#items" do
|
22
22
|
it "should return a collection of items" do
|
23
|
-
@response.items.
|
24
|
-
@response.items.size.
|
25
|
-
@response.items.each {|item| item.
|
23
|
+
expect(@response.items).to be_an_instance_of(Array)
|
24
|
+
expect(@response.items.size).to be > 0
|
25
|
+
@response.items.each {|item| expect(item).to be_an_instance_of(PITA::Item) }
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should have the some number less than or equal to #total_results" do
|
29
|
-
@response.items.size.
|
30
|
-
@response.items.size.
|
29
|
+
expect(@response.items.size).to be > 0
|
30
|
+
expect(@response.items.size).to be <= @response.total_results
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -38,17 +38,17 @@ describe PITA::Item do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should extract asin" do
|
41
|
-
@items.each {|item| item.asin.
|
42
|
-
@items.each {|item| item.asin.
|
41
|
+
@items.each {|item| expect(item.asin).to be_an_instance_of(String) }
|
42
|
+
@items.each {|item| expect(item.asin).to_not be_empty }
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should extract detail_page_url" do
|
46
|
-
@items.each {|item| item.detail_page_url.
|
47
|
-
@items.each {|item| item.detail_page_url.
|
46
|
+
@items.each {|item| expect(item.detail_page_url).to be_an_instance_of(String) }
|
47
|
+
@items.each {|item| expect(item.detail_page_url).to_not be_empty }
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should extract manufacturer" do
|
51
|
-
@items.each {|item| item.manufacturer.
|
52
|
-
@items.each {|item| item.manufacturer.
|
51
|
+
@items.each {|item| expect(item.manufacturer).to be_an_instance_of(String) }
|
52
|
+
@items.each {|item| expect(item.manufacturer).to_not be_empty }
|
53
53
|
end
|
54
54
|
end
|
@@ -7,7 +7,7 @@ describe Weather do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should extract observations" do
|
10
|
-
@weather.observation.
|
10
|
+
expect(@weather.observation).to be_an_instance_of(WeatherObservation)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -17,21 +17,21 @@ describe WeatherObservation do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should extract temperature" do
|
20
|
-
@observation.temperature.
|
20
|
+
expect(@observation.temperature).to be > 0
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should extract feels_like" do
|
24
|
-
@observation.feels_like.
|
24
|
+
expect(@observation.feels_like).to be > 0
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "#current_condition" do
|
28
28
|
it "should extract current_condition" do
|
29
|
-
@observation.current_condition.
|
29
|
+
expect(@observation.current_condition).to_not be_empty
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should extract icon attribute" do
|
33
|
-
|
34
|
-
@observation.current_condition.icon.
|
33
|
+
skip "need to think options through for HappyMapper-style :attributes extensions"
|
34
|
+
expect(@observation.current_condition.icon).to_not be_empty
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -7,14 +7,14 @@ describe GitHub::Commit do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should extract committed date" do
|
10
|
-
@commit.committed_date.
|
10
|
+
expect(@commit.committed_date).to be_an_instance_of(Date)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should extract url" do
|
14
|
-
@commit.url.
|
14
|
+
expect(@commit.url).to_not be_empty
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should extract id" do
|
18
|
-
@commit.id.
|
18
|
+
expect(@commit.id).to_not be_empty
|
19
19
|
end
|
20
20
|
end
|
@@ -17,7 +17,7 @@ describe Library do
|
|
17
17
|
|
18
18
|
describe "#to_xml" do
|
19
19
|
it "should contain the expected information" do
|
20
|
-
@lib.to_xml.to_s.
|
20
|
+
expect(@lib.to_xml.to_s).to eq(ROXML::XML.parse_string(%{<library><NAME><![CDATA[Favorite Books]]></NAME><novel ISBN='0201710897'><title>The PickAxe</title><description><![CDATA[Best Ruby book out there!]]></description><author>David Thomas, Andrew Hunt, Dave Thomas</author><publisher><name>Addison Wesley Longman, Inc.</name></publisher></novel></library>}).root.to_s)
|
21
21
|
end
|
22
22
|
|
23
23
|
context "when written to a file" do
|
@@ -33,12 +33,12 @@ describe Library do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should be contain the expected xml" do
|
36
|
-
ROXML::XML.parse_string(File.read(@path)).to_s.
|
36
|
+
expect(ROXML::XML.parse_string(File.read(@path)).to_s).to eq(ROXML::XML.parse_string(%{<?xml version="1.0"?><library><NAME><![CDATA[Favorite Books]]></NAME><novel ISBN='0201710897'><title>The PickAxe</title><description><![CDATA[Best Ruby book out there!]]></description><author>David Thomas, Andrew Hunt, Dave Thomas</author><publisher><name>Addison Wesley Longman, Inc.</name></publisher></novel></library>}).to_s)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should be re-parsable via .from_xml" do
|
40
40
|
File.open("spec/examples/library.xml") do |file|
|
41
|
-
Library.from_xml(file).
|
41
|
+
expect(Library.from_xml(file)).to eq(@lib)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -7,10 +7,10 @@ describe LibraryWithFines do
|
|
7
7
|
let(:library) { LibraryWithFines.from_xml(xml) }
|
8
8
|
|
9
9
|
it "should read nested elements" do
|
10
|
-
library.fines.
|
10
|
+
expect(library.fines).to be_a(Hash)
|
11
11
|
library.fines.size == 3
|
12
|
-
library.fines.
|
13
|
-
library.fines['talking'].
|
12
|
+
expect(library.fines).to have_key('talking')
|
13
|
+
expect(library.fines['talking']).to match(/Stop asking/)
|
14
14
|
end
|
15
15
|
|
16
16
|
class String
|
@@ -21,17 +21,17 @@ describe LibraryWithFines do
|
|
21
21
|
|
22
22
|
it "should write deeply nested elements" do
|
23
23
|
xml_out = library.to_xml.to_s
|
24
|
-
xml_out.remove_whitespace.
|
24
|
+
expect(xml_out.remove_whitespace).to eq(xml.remove_whitespace)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should write two children of library: name and policy" do
|
28
|
-
library.to_xml.children.map{|e| e.name }.
|
28
|
+
expect(library.to_xml.children.map{|e| e.name }).to eq(['name', 'policy'])
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should be re-parsable via .from_xml" do
|
32
32
|
lib_reparsed = LibraryWithFines.from_xml(library.to_xml.to_s)
|
33
|
-
lib_reparsed.name.
|
34
|
-
lib_reparsed.fines.
|
33
|
+
expect(lib_reparsed.name).to eq(library.name)
|
34
|
+
expect(lib_reparsed.fines).to eq(library.fines)
|
35
35
|
end
|
36
36
|
|
37
37
|
|
@@ -14,7 +14,7 @@ describe Person do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should only contain one location element' do
|
17
|
-
ROXML::XML.search(@person.to_xml, 'location').count.
|
17
|
+
expect(ROXML::XML.search(@person.to_xml, 'location').count).to eq(1)
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#to_xml' do
|
@@ -24,13 +24,13 @@ describe Person do
|
|
24
24
|
|
25
25
|
it 'should generate the expected xml' do
|
26
26
|
xml_file = File.read(xml_for('person')).gsub("\n",'').squeeze(' ')
|
27
|
-
xml_file.
|
27
|
+
expect(xml_file).to eq(@xml_generated)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should generate identical xml after a full roundtrip' do
|
31
31
|
p = Person.from_xml(@xml_generated)
|
32
32
|
xml_roundtrip = p.to_xml.to_s.gsub("\n",'').squeeze(' ')
|
33
|
-
xml_roundtrip.
|
33
|
+
expect(xml_roundtrip).to eq(@xml_generated)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
data/spec/examples/post_spec.rb
CHANGED
@@ -7,18 +7,18 @@ describe Post do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should extract description" do
|
10
|
-
@posts.each {|post| post.description.
|
10
|
+
@posts.each {|post| expect(post.description).to_not be_empty }
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should extract href" do
|
14
|
-
@posts.each {|post| post.href.
|
14
|
+
@posts.each {|post| expect(post.href).to_not be_empty }
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should extract extended" do
|
18
|
-
@posts.each {|post| post.extended.
|
18
|
+
@posts.each {|post| expect(post.extended).to_not be_empty }
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should extract time" do
|
22
|
-
@posts.each {|post| post.created_at.
|
22
|
+
@posts.each {|post| expect(post.created_at).to be_an_instance_of(DateTime) }
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative './../../examples/search_query'
|
3
|
+
|
4
|
+
describe SearchQuery do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@search = SearchQuery.new
|
8
|
+
@search.query = 'This is a random search query.'
|
9
|
+
|
10
|
+
@saved_search = SearchQuery.from_xml("<searchquery><query>Search for something</query></searchquery>")
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should return the default value for all attributes where no value is set' do
|
14
|
+
expect(@search.language).to eq('EN')
|
15
|
+
@search.max_results == 20
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should return the same object for the default value' do
|
19
|
+
expect(@search.language.object_id).to eq(@search.language.object_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should respect the defaults when loading from xml' do
|
23
|
+
expect(@saved_search.language).to eq('EN')
|
24
|
+
@saved_search.max_results == 20
|
25
|
+
end
|
26
|
+
end
|
@@ -8,11 +8,11 @@ describe Statuses do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should extract text" do
|
11
|
-
@statuses.each {|status| status.text.
|
11
|
+
@statuses.each {|status| expect(status.text).to_not be_empty }
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should extract source" do
|
15
|
-
@statuses.each {|status| status.source.
|
15
|
+
@statuses.each {|status| expect(status.source).to_not be_empty }
|
16
16
|
end
|
17
17
|
|
18
18
|
describe User do
|
@@ -21,11 +21,11 @@ describe Statuses do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should extract name" do
|
24
|
-
@users.each {|user| user.name.
|
24
|
+
@users.each {|user| expect(user.name).to eq("John Nunemaker") }
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should extract screen_name" do
|
28
|
-
@users.each {|user| user.screen_name.
|
28
|
+
@users.each {|user| expect(user.screen_name).to eq("jnunemaker") }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/spec/reference_spec.rb
CHANGED
@@ -23,12 +23,12 @@ describe ROXML::XMLRef do
|
|
23
23
|
|
24
24
|
it "should properly reconstruct wrappers with multiple elements" do
|
25
25
|
|
26
|
-
reference.
|
26
|
+
expect(reference).to be_a(ROXML::XMLHashRef)
|
27
27
|
|
28
28
|
xml = ROXML::XML.new_node('org').tap do |root|
|
29
29
|
reference.update_xml(root, org.fines)
|
30
30
|
end
|
31
31
|
|
32
|
-
xml_path( xml ).
|
32
|
+
expect(xml_path( xml )).to eq(%w{org policy fines fine name})
|
33
33
|
end
|
34
34
|
end
|
data/spec/regression_spec.rb
CHANGED
@@ -4,16 +4,21 @@ describe ROXML do
|
|
4
4
|
describe 'frozen nils' do
|
5
5
|
subject { nil }
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
lib = Library.from_xml(fixture(:library))
|
7
|
+
# Prior to ruby-2.2, nil was not frozen. This test watches for
|
8
|
+
# a regression in previous versions of roxml that caused nil to
|
9
|
+
# become frozen. FIXME: remove after ruby-2.1 support is removed.
|
10
|
+
if RUBY_VERSION < "2.2"
|
11
|
+
context 'before unmarshalling an XML document' do
|
12
|
+
it { is_expected.to_not be_frozen }
|
14
13
|
end
|
15
14
|
|
16
|
-
|
15
|
+
context 'after unmarshalling an XML document' do
|
16
|
+
before do
|
17
|
+
lib = Library.from_xml(fixture(:library))
|
18
|
+
end
|
19
|
+
|
20
|
+
it { is_expected.to_not be_frozen }
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
data/spec/roxml_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative './spec_helper'
|
|
3
3
|
describe ROXML do
|
4
4
|
describe "::VERSION" do
|
5
5
|
it "should be equal to the VERSION file contents" do
|
6
|
-
ROXML::VERSION.
|
6
|
+
expect(ROXML::VERSION).to eq(File.read('VERSION'))
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -11,8 +11,8 @@ describe ROXML do
|
|
11
11
|
shared_examples_for "from_xml call" do
|
12
12
|
it "should fetch values" do
|
13
13
|
book = BookWithContributors.from_xml(@path)
|
14
|
-
book.title.
|
15
|
-
book.contributors.map(&:name).
|
14
|
+
expect(book.title).to eq("Programming Ruby - 2nd Edition")
|
15
|
+
expect(book.contributors.map(&:name)).to eq(["David Thomas","Andrew Hunt","Chad Fowler"])
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -81,14 +81,14 @@ describe ROXML, "#xml" do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should raise on duplicate accessor name" do
|
84
|
-
|
84
|
+
expect do
|
85
85
|
Class.new do
|
86
86
|
include ROXML
|
87
87
|
|
88
88
|
xml_reader :id
|
89
89
|
xml_accessor :id
|
90
90
|
end
|
91
|
-
end.
|
91
|
+
end.to raise_error(RuntimeError)
|
92
92
|
end
|
93
93
|
|
94
94
|
class OctalInteger
|
@@ -139,19 +139,6 @@ describe ROXML, "#xml" do
|
|
139
139
|
@expected_pages = 239
|
140
140
|
end
|
141
141
|
|
142
|
-
describe "with :as block shorthand" do
|
143
|
-
class BookWithOctalPagesBlockShorthand
|
144
|
-
include ROXML
|
145
|
-
|
146
|
-
xml_accessor :pages, :as => Integer, :required => true
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should apply filtering on input" do
|
150
|
-
book = BookWithOctalPagesBlockShorthand.from_xml(@book_with_octal_pages_xml)
|
151
|
-
book.pages.should == @expected_pages
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
142
|
describe "with #from_xml defined on the object" do
|
156
143
|
class BookWithOctalPagesType
|
157
144
|
include ROXML
|
@@ -161,7 +148,7 @@ describe ROXML, "#xml" do
|
|
161
148
|
|
162
149
|
it "should apply filtering on input" do
|
163
150
|
book = BookWithOctalPagesType.from_xml(@book_with_octal_pages_xml)
|
164
|
-
book.pages.
|
151
|
+
expect(book.pages).to eq(@expected_pages)
|
165
152
|
end
|
166
153
|
end
|
167
154
|
end
|
@@ -194,11 +181,11 @@ describe ROXML, "#xml" do
|
|
194
181
|
|
195
182
|
describe "indirect reference via an object" do
|
196
183
|
it "does not inherit the frozen status from its parent" do
|
197
|
-
@frozen.writable.frozen
|
198
|
-
@frozen.readonly.frozen
|
184
|
+
expect(@frozen.writable.frozen?).to be_falsey
|
185
|
+
expect(@frozen.readonly.frozen?).to be_truthy
|
199
186
|
|
200
|
-
@unfrozen.writable.frozen
|
201
|
-
@unfrozen.readonly.frozen
|
187
|
+
expect(@unfrozen.writable.frozen?).to be_falsey
|
188
|
+
expect(@unfrozen.readonly.frozen?).to be_truthy
|
202
189
|
end
|
203
190
|
end
|
204
191
|
end
|
@@ -212,8 +199,8 @@ describe ROXML, "#xml" do
|
|
212
199
|
it_should_behave_like "freezable xml reference"
|
213
200
|
|
214
201
|
it "should apply :frozen to the constituent elements" do
|
215
|
-
@frozen.all?(&:frozen?).
|
216
|
-
@unfrozen.any?(&:frozen?).
|
202
|
+
expect(@frozen.all?(&:frozen?)).to be_truthy
|
203
|
+
expect(@unfrozen.any?(&:frozen?)).to be_falsey
|
217
204
|
end
|
218
205
|
|
219
206
|
context "no elements are present in root, no :in is specified" do
|
@@ -237,7 +224,7 @@ describe ROXML, "#xml" do
|
|
237
224
|
</contributors>
|
238
225
|
</book>
|
239
226
|
})
|
240
|
-
book.contributors.map(&:name).sort.
|
227
|
+
expect(book.contributors.map(&:name).sort).to eq(["David Thomas","Andrew Hunt","Chad Fowler"].sort)
|
241
228
|
end
|
242
229
|
end
|
243
230
|
end
|
@@ -267,13 +254,13 @@ describe ROXML, "#xml" do
|
|
267
254
|
it_should_behave_like "freezable xml reference"
|
268
255
|
|
269
256
|
it "should have frozen keys, as with all hashes" do
|
270
|
-
@frozen.keys.all?(&:frozen?).
|
271
|
-
@unfrozen.keys.all?(&:frozen?).
|
257
|
+
expect(@frozen.keys.all?(&:frozen?)).to be_truthy
|
258
|
+
expect(@unfrozen.keys.all?(&:frozen?)).to be_truthy
|
272
259
|
end
|
273
260
|
|
274
261
|
it "should apply :frozen to the constituent values" do
|
275
|
-
@frozen.values.all?(&:frozen?).
|
276
|
-
@unfrozen.values.any?(&:frozen?).
|
262
|
+
expect(@frozen.values.all?(&:frozen?)).to be_truthy
|
263
|
+
expect(@unfrozen.values.any?(&:frozen?)).to be_falsey
|
277
264
|
end
|
278
265
|
end
|
279
266
|
end
|
@@ -343,29 +330,29 @@ describe ROXML, "inheritance" do
|
|
343
330
|
|
344
331
|
describe "parent" do
|
345
332
|
it "should include its attributes" do
|
346
|
-
@child.isbn.
|
347
|
-
@child.title.
|
348
|
-
@child.description.
|
349
|
-
@child.author.
|
350
|
-
@child.pages.
|
333
|
+
expect(@child.isbn).to eq("0201710897")
|
334
|
+
expect(@child.title).to eq("The PickAxe")
|
335
|
+
expect(@child.description).to eq("Probably the best Ruby book out there")
|
336
|
+
expect(@child.author).to eq('David Thomas, Andrew Hunt, Dave Thomas')
|
337
|
+
expect(@child.pages).to eq(nil)
|
351
338
|
end
|
352
339
|
|
353
340
|
it "should not include its child's attributes" do
|
354
|
-
@parent.
|
341
|
+
expect(@parent).to_not respond_to(:depth)
|
355
342
|
end
|
356
343
|
end
|
357
344
|
|
358
345
|
describe "child" do
|
359
346
|
it "should include its parent's attributes" do
|
360
|
-
@child.isbn.
|
361
|
-
@child.title.
|
362
|
-
@child.description.
|
363
|
-
@child.author.
|
364
|
-
@child.pages.
|
347
|
+
expect(@child.isbn).to eq(@parent.isbn)
|
348
|
+
expect(@child.title).to eq(@parent.title)
|
349
|
+
expect(@child.description).to eq(@parent.description)
|
350
|
+
expect(@child.author).to eq(@parent.author)
|
351
|
+
expect(@child.pages).to eq(@parent.pages)
|
365
352
|
end
|
366
353
|
|
367
354
|
it "should include its attributes" do
|
368
|
-
@child.depth.to_s.
|
355
|
+
expect(@child.depth.to_s).to eq('11.3 meters')
|
369
356
|
end
|
370
357
|
|
371
358
|
it "should include parent's attributes added after declaration" do
|
@@ -374,7 +361,7 @@ describe ROXML, "inheritance" do
|
|
374
361
|
end
|
375
362
|
|
376
363
|
book = InheritedBookWithDepth.from_xml(@book_xml)
|
377
|
-
book.publisher.
|
364
|
+
expect(book.publisher).to eq("Pragmattic Programmers")
|
378
365
|
end
|
379
366
|
end
|
380
367
|
end
|