File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,17 @@ def parse_object(el)
15
15
product . attributes [ field . to_sym ] = el . at ( _field ) . content . gsub ( /\n \s +/ , ' ' ) . strip
16
16
end
17
17
end
18
+ product [ :offers ] = [ ]
19
+ el . at ( 'Offers' ) . elements . each do |offer |
20
+ o = %w[ id first_edition special_edition state price list_price availability_code availability_description comment second_hand seller ] . inject ( { } ) do |output , field |
21
+ _field = camelize ( field )
22
+ if offer . at ( _field )
23
+ output [ field ] = offer . at ( _field ) . content . gsub ( /\n \s +/ , ' ' ) . strip
24
+ end
25
+ output
26
+ end
27
+ product [ :offers ] << OpenStruct . new ( o )
28
+ end
18
29
product [ :url ] = el . at ( 'Urls' ) . at ( 'Main' ) . content . strip
19
30
if el . at ( 'ReleaseDate' )
20
31
product [ :release_date ] = Time . parse ( el . at ( 'ReleaseDate' ) . content )
Original file line number Diff line number Diff line change 33
33
product . release_date . day . should == 1
34
34
end
35
35
36
+ it 'should parse offers' do
37
+ product . offers . first . state . should == 'new'
38
+ product . offers . first . price . should == '70.99'
39
+ product . offers . first . list_price . should == '78.99'
40
+ product . offers . first . availability_code . should == '167'
41
+ product . offers . first . availability_description . should == '5-10 werkdagen'
42
+ end
43
+
36
44
it 'should parse cover' do
37
45
product . cover . should == 'http://s-bol.com/imgbase0/imagebase/thumb/FC/8/4/4/6/1001004006016448.jpg'
38
46
product . cover ( :medium ) . should == 'http://s-bol.com/imgbase0/imagebase/thumb/FC/8/4/4/6/1001004006016448.jpg'
You can’t perform that action at this time.
0 commit comments