7digital 0.0.1 → 0.0.2
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.
- data/README.rdoc +9 -7
- data/lib/sevendigital.rb +54 -53
- data/lib/sevendigital/api_operator.rb +33 -30
- data/lib/sevendigital/api_operator_cached.rb +23 -23
- data/lib/sevendigital/api_request.rb +23 -23
- data/lib/sevendigital/client.rb +136 -124
- data/lib/sevendigital/default_configuration.yml +2 -2
- data/lib/sevendigital/digestion_tract/api_response_digestor.rb +52 -52
- data/lib/sevendigital/digestion_tract/artist_digestor.rb +31 -31
- data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +27 -27
- data/lib/sevendigital/digestion_tract/digestor.rb +66 -66
- data/lib/sevendigital/digestion_tract/format_digestor.rb +21 -21
- data/lib/sevendigital/digestion_tract/label_digestor.rb +19 -19
- data/lib/sevendigital/digestion_tract/pager_digestor.rb +23 -23
- data/lib/sevendigital/digestion_tract/price_digestor.rb +24 -24
- data/lib/sevendigital/digestion_tract/release_digestor.rb +52 -52
- data/lib/sevendigital/digestion_tract/track_digestor.rb +37 -37
- data/lib/sevendigital/management/artist_manager.rb +45 -39
- data/lib/sevendigital/management/manager.rb +11 -11
- data/lib/sevendigital/management/release_manager.rb +57 -50
- data/lib/sevendigital/management/track_manager.rb +28 -17
- data/lib/sevendigital/model/api_response.rb +24 -12
- data/lib/sevendigital/model/artist.rb +46 -36
- data/lib/sevendigital/model/chart_item.rb +9 -9
- data/lib/sevendigital/model/format.rb +9 -9
- data/lib/sevendigital/model/label.rb +9 -9
- data/lib/sevendigital/model/price.rb +11 -11
- data/lib/sevendigital/model/release.rb +33 -33
- data/lib/sevendigital/model/sevendigital_error.rb +3 -3
- data/lib/sevendigital/model/sevendigital_object.rb +51 -51
- data/lib/sevendigital/model/track.rb +28 -7
- data/lib/sevendigital/pager.rb +16 -16
- data/lib/sevendigital/peachy_patch.rb +19 -0
- data/lib/sevendigital/proxy_police.rb +23 -23
- data/spec/api_operator_cached_spec.rb +47 -46
- data/spec/api_operator_spec.rb +114 -107
- data/spec/api_request_spec.rb +26 -27
- data/spec/client_spec.rb +75 -45
- data/spec/data/config/sevendigital.yml +5 -5
- data/spec/data/configuration_env_override.yml +5 -5
- data/spec/digestion_tract/api_response_digestor_spec.rb +78 -74
- data/spec/digestion_tract/artist_digestor_spec.rb +81 -82
- data/spec/digestion_tract/chart_digestor_spec.rb +52 -53
- data/spec/digestion_tract/format_digestor_spec.rb +38 -39
- data/spec/digestion_tract/label_digestor_spec.rb +33 -34
- data/spec/digestion_tract/pager_digestor_spec.rb +50 -51
- data/spec/digestion_tract/price_digestor_spec.rb +57 -57
- data/spec/digestion_tract/release_digestor_spec.rb +101 -102
- data/spec/digestion_tract/track_digestor_spec.rb +104 -106
- data/spec/management/artist_manager_spec.rb +128 -107
- data/spec/management/release_manager_spec.rb +222 -178
- data/spec/management/track_manager_spec.rb +88 -52
- data/spec/model/api_response_spec.rb +44 -31
- data/spec/model/artist_spec.rb +166 -121
- data/spec/model/release_spec.rb +109 -110
- data/spec/model/track_spec.rb +140 -0
- data/spec/pager_spec.rb +7 -8
- data/spec/peachy_spec_helper_patch.rb +7 -0
- data/spec/proxy_police_spec.rb +47 -48
- data/spec/spec_helper.rb +52 -48
- data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
- data/spec/test-xml/methods/artist/details.xml +9 -9
- data/spec/test-xml/methods/artist/releases.xml +544 -544
- data/spec/test-xml/methods/artist/search.xml +19 -0
- data/spec/test-xml/methods/artist/similar.xml +39 -39
- data/spec/test-xml/methods/artist/toptracks.xml +279 -279
- data/spec/test-xml/methods/release/bydate.xml +173 -173
- data/spec/test-xml/methods/release/bytag/top.xml +150 -150
- data/spec/test-xml/methods/release/chart.xml +181 -181
- data/spec/test-xml/methods/release/details.xml +48 -48
- data/spec/test-xml/methods/release/recommend.xml +89 -89
- data/spec/test-xml/methods/release/search.xml +195 -0
- data/spec/test-xml/methods/release/tracks.xml +28 -28
- data/spec/test-xml/methods/track/chart.xml +149 -149
- data/spec/test-xml/methods/track/details.xml +30 -30
- data/spec/test-xml/methods/track/search.xml +160 -0
- data/spec/test-xml/objects/artist.xml +6 -6
- data/spec/test-xml/objects/artist_chart_item.xml +7 -7
- data/spec/test-xml/objects/artist_list.xml +22 -22
- data/spec/test-xml/objects/artist_list_empty.xml +4 -4
- data/spec/test-xml/objects/price.xml +7 -7
- data/spec/test-xml/objects/release.xml +40 -40
- data/spec/test-xml/objects/release_chart_item.xml +39 -34
- data/spec/test-xml/objects/release_list.xml +18 -18
- data/spec/test-xml/objects/release_list_empty.xml +4 -4
- data/spec/test-xml/objects/response.xml +39 -0
- data/spec/test-xml/objects/track.xml +33 -33
- data/spec/test-xml/objects/track_chart_item.xml +27 -27
- metadata +10 -5
- data/lib/peachy_patchy.rb +0 -14
- data/lib/sevendigital/version.rb +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
common:
|
|
2
|
-
api_url: test-yml-rails-common.7digital.com
|
|
3
|
-
|
|
4
|
-
development:
|
|
5
|
-
api_url: test-yml-development.7digital.com
|
|
1
|
+
common:
|
|
2
|
+
api_url: test-yml-rails-common.7digital.com
|
|
3
|
+
|
|
4
|
+
development:
|
|
5
|
+
api_url: test-yml-development.7digital.com
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
common:
|
|
2
|
-
api_url: test-yml-common.7digital.com
|
|
3
|
-
|
|
4
|
-
development:
|
|
5
|
-
api_url: test-yml-development.7digital.com
|
|
1
|
+
common:
|
|
2
|
+
api_url: test-yml-common.7digital.com
|
|
3
|
+
|
|
4
|
+
development:
|
|
5
|
+
api_url: test-yml-development.7digital.com
|
|
@@ -1,74 +1,78 @@
|
|
|
1
|
-
require
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
stub_http_response
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
stub_http_response
|
|
26
|
-
stub_http_response.stub!(:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
response
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
response
|
|
44
|
-
response.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
response
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
response
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[../spec_helper])
|
|
2
|
+
|
|
3
|
+
describe "ApiResponseDigestor" do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@api_response_digestor = Sevendigital::ApiResponseDigestor.new(nil)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should create a response with body from http ok response" do
|
|
10
|
+
|
|
11
|
+
stub_http_response = stub(Net::HTTPSuccess)
|
|
12
|
+
stub_http_response.stub!(:is_a?).with(Net::HTTPSuccess).and_return(true)
|
|
13
|
+
stub_http_response.stub!(:body).and_return('<response status="ok"></response>')
|
|
14
|
+
|
|
15
|
+
response = @api_response_digestor.from_http_response(stub_http_response)
|
|
16
|
+
response.error_code.should == 0
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should create an error response from http non-ok response" do
|
|
20
|
+
expected_message = 'Authorisation failed'
|
|
21
|
+
expected_error_code = 401
|
|
22
|
+
|
|
23
|
+
stub_http_response = stub(Net::HTTPSuccess)
|
|
24
|
+
stub_http_response.stub!(:is_a?).with(Net::HTTPSuccess).and_return(false)
|
|
25
|
+
stub_http_response.stub!(:code).and_return(expected_error_code.to_s)
|
|
26
|
+
stub_http_response.stub!(:body).and_return(expected_message)
|
|
27
|
+
|
|
28
|
+
response = @api_response_digestor.from_http_response(stub_http_response)
|
|
29
|
+
response.error_code.should == 401
|
|
30
|
+
response.error_message.should == expected_message
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
it "should create a response with body from xml ok response" do
|
|
37
|
+
|
|
38
|
+
xml_response = <<XML
|
|
39
|
+
<response status="ok"><test>aaa</test></response>
|
|
40
|
+
XML
|
|
41
|
+
response = @api_response_digestor.from_xml(xml_response)
|
|
42
|
+
response.error_code.should == 0
|
|
43
|
+
response.content.test.should_not == nil
|
|
44
|
+
response.content.nothing.should == nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
it "should create a response with error details from xml error response" do
|
|
49
|
+
|
|
50
|
+
xml_response = '<response status="error"><error code="1000"><errorMessage>expected error message</errorMessage></error></response>'
|
|
51
|
+
response = @api_response_digestor.from_xml(xml_response)
|
|
52
|
+
response.error_code.should == 1000
|
|
53
|
+
response.error_message.should == 'expected error message'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should create a response with error details from invalid xml response" do
|
|
57
|
+
|
|
58
|
+
xml_response = '<wrongresponse status="ok"><test /></wrongresponse>'
|
|
59
|
+
response = @api_response_digestor.from_xml(xml_response)
|
|
60
|
+
response.error_code.should == 10000
|
|
61
|
+
response.error_message.should == 'Invalid 7digital API response'
|
|
62
|
+
|
|
63
|
+
xml_response = '<response><test /></response>'
|
|
64
|
+
response = @api_response_digestor.from_xml(xml_response)
|
|
65
|
+
response.error_code.should == 10000
|
|
66
|
+
response.error_message.should == 'Invalid 7digital API response'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
it "should create a response with error details from valid xml response with invalid status" do
|
|
71
|
+
|
|
72
|
+
xml_response = '<response status="unkown"><test></test></response>'
|
|
73
|
+
response = @api_response_digestor.from_xml(xml_response)
|
|
74
|
+
response.error_code.should == 10000
|
|
75
|
+
response.error_message.should == 'Invalid 7digital API response'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
@@ -1,83 +1,82 @@
|
|
|
1
|
-
require
|
|
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
|
-
artist
|
|
31
|
-
artist.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
artist
|
|
40
|
-
artist.
|
|
41
|
-
artist.
|
|
42
|
-
artist.
|
|
43
|
-
artist.
|
|
44
|
-
artist.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
artists
|
|
53
|
-
artists[
|
|
54
|
-
artists[
|
|
55
|
-
artists
|
|
56
|
-
artists.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
artists
|
|
66
|
-
artists.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[../spec_helper])
|
|
2
|
+
|
|
3
|
+
describe "ArtistDigestor" do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@artist_digestor = Sevendigital::ArtistDigestor.new(Sevendigital::Client.new(nil))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
|
10
|
+
|
|
11
|
+
xml_response = <<XML
|
|
12
|
+
<release id="123">
|
|
13
|
+
<name>expected artist name</name>
|
|
14
|
+
</release>
|
|
15
|
+
XML
|
|
16
|
+
|
|
17
|
+
running {@artist_digestor.from_xml(xml_response)}.should raise_error Sevendigital::DigestiveProblem
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should digest artist xml and populate minimum available properties" do
|
|
22
|
+
|
|
23
|
+
xml_response = <<XML
|
|
24
|
+
<artist id="123">
|
|
25
|
+
<name>expected artist name</name>
|
|
26
|
+
</artist>
|
|
27
|
+
XML
|
|
28
|
+
|
|
29
|
+
artist = @artist_digestor.from_xml(xml_response)
|
|
30
|
+
artist.id.should == 123
|
|
31
|
+
artist.name.should == "expected artist name"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should digest artist xml and populate all available properties" do
|
|
35
|
+
|
|
36
|
+
xml_response = load_sample_object_xml("artist")
|
|
37
|
+
|
|
38
|
+
artist = @artist_digestor.from_xml(xml_response)
|
|
39
|
+
artist.id.should == 123
|
|
40
|
+
artist.name.should == "The Expected Artist"
|
|
41
|
+
artist.sort_name.should == "Expected Artist, The"
|
|
42
|
+
artist.appears_as.should == "The E.A."
|
|
43
|
+
artist.image.should == "http://somewhere.com/tea.jpg"
|
|
44
|
+
artist.url.should == "http://7digital.com/artists/tea?partner=1"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should digest xml containing list of artists and return a paginated array" do
|
|
48
|
+
|
|
49
|
+
xml_response = load_sample_object_xml("artist_list")
|
|
50
|
+
|
|
51
|
+
artists = @artist_digestor.list_from_xml(xml_response, :artists)
|
|
52
|
+
artists[0].id.should == 14
|
|
53
|
+
artists[1].id.should == 20
|
|
54
|
+
artists[2].id.should == 106
|
|
55
|
+
artists.size.should == 3
|
|
56
|
+
artists.total_entries.should == 26
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should digest xml containing empty list of releases and return an empty paginated array" do
|
|
61
|
+
|
|
62
|
+
xml_response = load_sample_object_xml("artist_list_empty")
|
|
63
|
+
|
|
64
|
+
artists = @artist_digestor.list_from_xml(xml_response, :artists)
|
|
65
|
+
artists.size.should == 0
|
|
66
|
+
artists.total_entries.should == 0
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should not digest list from invalid xml but throw up (exception)" do
|
|
71
|
+
|
|
72
|
+
xml_response = <<XML
|
|
73
|
+
<release id="123">
|
|
74
|
+
<name>expected artist name</name>
|
|
75
|
+
</release>
|
|
76
|
+
XML
|
|
77
|
+
|
|
78
|
+
running {@artist_digestor.list_from_xml(xml_response)}.should raise_error Sevendigital::DigestiveProblem
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
83
82
|
end
|
|
@@ -1,54 +1,53 @@
|
|
|
1
|
-
require
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
chart_item
|
|
25
|
-
chart_item.
|
|
26
|
-
chart_item.
|
|
27
|
-
chart_item.item.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
chart_item
|
|
36
|
-
chart_item.
|
|
37
|
-
chart_item.
|
|
38
|
-
chart_item.item.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
chart_item
|
|
47
|
-
chart_item.
|
|
48
|
-
chart_item.
|
|
49
|
-
chart_item.item.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[../spec_helper])
|
|
2
|
+
|
|
3
|
+
describe "ChartItemDigestor" do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@chart_item_digestor = Sevendigital::ChartItemDigestor.new(Sevendigital::Client.new(nil))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
|
10
|
+
|
|
11
|
+
xml_response = <<XML
|
|
12
|
+
<release id="123">
|
|
13
|
+
<name>expected artist name</name>
|
|
14
|
+
</release>
|
|
15
|
+
XML
|
|
16
|
+
|
|
17
|
+
running {@chart_item_digestor.from_xml(xml_response)}.should raise_error Sevendigital::DigestiveProblem
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should digest artist chart item" do
|
|
21
|
+
xml_response = load_sample_object_xml("artist_chart_item")
|
|
22
|
+
|
|
23
|
+
chart_item = @chart_item_digestor.from_xml(xml_response)
|
|
24
|
+
chart_item.position.should == 2
|
|
25
|
+
chart_item.change.should == :up
|
|
26
|
+
chart_item.item.id.should == 33154
|
|
27
|
+
chart_item.item.class.should == Sevendigital::Artist
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
it "should digest release chart item" do
|
|
32
|
+
xml_response = load_sample_object_xml("release_chart_item")
|
|
33
|
+
|
|
34
|
+
chart_item = @chart_item_digestor.from_xml(xml_response)
|
|
35
|
+
chart_item.position.should == 1
|
|
36
|
+
chart_item.change.should == :up
|
|
37
|
+
chart_item.item.id.should == 932151
|
|
38
|
+
chart_item.item.class.should == Sevendigital::Release
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should digest track chart item" do
|
|
42
|
+
|
|
43
|
+
xml_response = load_sample_object_xml("track_chart_item")
|
|
44
|
+
|
|
45
|
+
chart_item = @chart_item_digestor.from_xml(xml_response)
|
|
46
|
+
chart_item.position.should == 99
|
|
47
|
+
chart_item.change.should == :down
|
|
48
|
+
chart_item.item.id.should == 2825304
|
|
49
|
+
chart_item.item.class.should == Sevendigital::Track
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
54
53
|
end
|
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
require
|
|
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
|
-
format
|
|
34
|
-
format.
|
|
35
|
-
format.
|
|
36
|
-
format.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[../spec_helper])
|
|
2
|
+
|
|
3
|
+
describe "FormatDigestor" do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@format_digestor = Sevendigital::FormatDigestor.new(nil)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
|
10
|
+
|
|
11
|
+
xml_response = <<XML
|
|
12
|
+
<zzz id="17">
|
|
13
|
+
<fileFormat>MP3</fileFormat>
|
|
14
|
+
<bitRate>320</bitRate>
|
|
15
|
+
<drmFree>True</drmFree>
|
|
16
|
+
</zzz>
|
|
17
|
+
XML
|
|
18
|
+
|
|
19
|
+
running {@format_digestor.from_xml(xml_response)}.should raise_error Sevendigital::DigestiveProblem
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should parse from xml and populate all properties" do
|
|
23
|
+
|
|
24
|
+
xml_response = <<XML
|
|
25
|
+
<format id="17">
|
|
26
|
+
<fileFormat>MP3</fileFormat>
|
|
27
|
+
<bitRate>320</bitRate>
|
|
28
|
+
<drmFree>True</drmFree>
|
|
29
|
+
</format>
|
|
30
|
+
XML
|
|
31
|
+
|
|
32
|
+
format = @format_digestor.from_xml(xml_response)
|
|
33
|
+
format.id.should == 17
|
|
34
|
+
format.file_format.should == :MP3
|
|
35
|
+
format.bit_rate.should == 320
|
|
36
|
+
format.drm_free.should == true
|
|
37
|
+
end
|
|
38
|
+
|
|
40
39
|
end
|