7digital 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,19 @@
|
|
1
|
+
module Peachy
|
2
|
+
module MorphIntoArray
|
3
|
+
private
|
4
|
+
|
5
|
+
def array_can? method_name
|
6
|
+
(Array.instance_methods - Object.instance_methods).include?( version_safe_method_id(method_name))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
if RUBY_VERSION < "1.9"
|
12
|
+
def version_safe_method_id(method_name)
|
13
|
+
method_name.to_s
|
14
|
+
end
|
15
|
+
else
|
16
|
+
def version_safe_method_id(method_name)
|
17
|
+
method_name.to_sym
|
18
|
+
end
|
19
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
module Sevendigital
|
2
|
-
class ProxyPolice
|
3
|
-
|
4
|
-
def ProxyPolice.ensure_is_proxy(xml_or_proxy, element_name)
|
5
|
-
if xml_or_proxy.kind_of? Peachy::Proxy then
|
6
|
-
return xml_or_proxy
|
7
|
-
else
|
8
|
-
return ProxyPolice.create_release_proxy(xml_or_proxy, element_name)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def ProxyPolice.create_release_proxy(xml, element_name)
|
13
|
-
#TODO don't use eval
|
14
|
-
parent_proxy = Peachy::Proxy.new(xml)
|
15
|
-
if element_name
|
16
|
-
# parent_proxy.send(element_name)
|
17
|
-
eval "parent_proxy.#{element_name.to_s}"
|
18
|
-
else
|
19
|
-
parent_proxy
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
1
|
+
module Sevendigital
|
2
|
+
class ProxyPolice
|
3
|
+
|
4
|
+
def ProxyPolice.ensure_is_proxy(xml_or_proxy, element_name)
|
5
|
+
if xml_or_proxy.kind_of? Peachy::Proxy then
|
6
|
+
return xml_or_proxy
|
7
|
+
else
|
8
|
+
return ProxyPolice.create_release_proxy(xml_or_proxy, element_name)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def ProxyPolice.create_release_proxy(xml, element_name)
|
13
|
+
#TODO don't use eval
|
14
|
+
parent_proxy = Peachy::Proxy.new(xml)
|
15
|
+
if element_name
|
16
|
+
# parent_proxy.send(element_name)
|
17
|
+
eval "parent_proxy.#{element_name.to_s}"
|
18
|
+
else
|
19
|
+
parent_proxy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
24
|
end
|
@@ -1,47 +1,48 @@
|
|
1
|
-
require
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@client
|
9
|
-
@
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@cached_operator.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
@cache.stub!(:
|
26
|
-
@
|
27
|
-
|
28
|
-
|
29
|
-
response
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe "ApiOperatorCached" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = stub(Sevendigital::Client)
|
8
|
+
@client.stub!(:verbose?).and_return(false)
|
9
|
+
@client.stub!(:very_verbose?).and_return(false)
|
10
|
+
@cache = stub(Hash)
|
11
|
+
@cached_operator = Sevendigital::ApiOperatorCached.new(@client, @cache)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should not make an http request if response already in cache " do
|
15
|
+
@cached_operator.stub(:create_request_uri).and_return("key")
|
16
|
+
@cache.stub!(:get).with("key").and_return(:something)
|
17
|
+
@cached_operator.should_not_receive(:make_http_request_and_digest)
|
18
|
+
@cached_operator.call_api(@stub_api_request)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should make an http request if response not yet in cache and return the result " do
|
22
|
+
api_response = fake_api_response()
|
23
|
+
|
24
|
+
@cached_operator.stub(:create_request_uri).and_return("key")
|
25
|
+
@cache.stub!(:get).with("key").and_return(nil)
|
26
|
+
@cache.stub!(:set).and_return(nil)
|
27
|
+
@cached_operator.should_receive(:make_http_request_and_digest).with("key").and_return(api_response)
|
28
|
+
|
29
|
+
response = @cached_operator.call_api(@stub_api_request)
|
30
|
+
response.should == api_response
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should cache uncached api response" do
|
34
|
+
api_response = fake_api_response()
|
35
|
+
|
36
|
+
@cached_operator.stub(:create_request_uri).and_return("key")
|
37
|
+
@cache.stub!(:get).with("key").and_return(nil)
|
38
|
+
@cached_operator.stub!(:make_http_request_and_digest).and_return(api_response)
|
39
|
+
|
40
|
+
@cache.should_receive(:set).with("key", api_response).and_return(nil)
|
41
|
+
response = @cached_operator.call_api(@stub_api_request)
|
42
|
+
end
|
43
|
+
|
44
|
+
def fake_api_response
|
45
|
+
return Net::HTTP.new("1.1", 200, "response_body")
|
46
|
+
end
|
47
|
+
|
47
48
|
end
|
data/spec/api_operator_spec.rb
CHANGED
@@ -1,108 +1,115 @@
|
|
1
|
-
require
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
response_digestor
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
uri.to_s.should
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@
|
36
|
-
|
37
|
-
@
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@api_operator.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
response
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
return
|
84
|
-
end
|
85
|
-
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe "ApiOperator" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
response_digestor = stub(Sevendigital::ApiResponseDigestor)
|
8
|
+
response_digestor.stub!(:from_http_response). and_return(fake_digested_response)
|
9
|
+
|
10
|
+
stub_api_client(test_configuration, response_digestor)
|
11
|
+
|
12
|
+
Net::HTTP.stub!(:get_response).and_return(fake_api_response)
|
13
|
+
|
14
|
+
@api_operator = Sevendigital::ApiOperator.new(@client)
|
15
|
+
|
16
|
+
@stub_api_request = stub_api_request()
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should create request URI based on api method and client configuration" do
|
21
|
+
|
22
|
+
api_request = Sevendigital::ApiRequest.new("api/method", {:param1 => "value", :paramTwo => 2})
|
23
|
+
|
24
|
+
uri = @api_operator.create_request_uri(api_request)
|
25
|
+
|
26
|
+
uri.kind_of?(URI).should == true
|
27
|
+
|
28
|
+
uri.to_s.should =~ /http:\/\/base.api.url\/version\/api\/method\?oauth_consumer_key=oauth_consumer_key/
|
29
|
+
uri.to_s.should =~ /\¶m1=value/
|
30
|
+
uri.to_s.should =~ /\¶mTwo=2/
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should make sure country is set before making request" do
|
35
|
+
@client.stub!(:country).and_return("sk")
|
36
|
+
|
37
|
+
@stub_api_request.should_receive(:ensure_country_is_set).with("sk")
|
38
|
+
|
39
|
+
@api_operator.call_api(@stub_api_request)
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should make HTTP request and get response" do
|
44
|
+
|
45
|
+
Net::HTTP.should_receive(:get_response).with(@api_operator.create_request_uri(@stub_api_request))
|
46
|
+
|
47
|
+
@api_operator.call_api(@stub_api_request)
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should digest the HTTP response and get it out" do
|
52
|
+
|
53
|
+
http_response = fake_api_response
|
54
|
+
digested_response = fake_digested_response
|
55
|
+
|
56
|
+
Net::HTTP.stub!(:get_response).and_return(http_response)
|
57
|
+
|
58
|
+
@client.api_response_digestor.should_receive(:from_http_response).with(http_response).and_return(digested_response)
|
59
|
+
|
60
|
+
response = @api_operator.call_api(@stub_api_request)
|
61
|
+
|
62
|
+
response.should == digested_response
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should throw an exception if response is not ok" do
|
67
|
+
|
68
|
+
Net::HTTP.stub(:get_response).and_return(fake_api_response)
|
69
|
+
failed_response = fake_digested_response(false)
|
70
|
+
failed_response.stub!(:error_code).and_return("4000")
|
71
|
+
failed_response.stub!(:error_message).and_return("error")
|
72
|
+
@client.api_response_digestor.stub!(:from_http_response).and_return(failed_response)
|
73
|
+
|
74
|
+
running { @api_operator.call_api(@stub_api_request) }.should raise_error(Sevendigital::SevendigitalError)
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_configuration
|
79
|
+
configuration = OpenStruct.new
|
80
|
+
configuration.api_url = "base.api.url"
|
81
|
+
configuration.api_version = "version"
|
82
|
+
configuration.oauth_consumer_key = "oauth_consumer_key"
|
83
|
+
return configuration
|
84
|
+
end
|
85
|
+
|
86
|
+
def fake_api_response(code = 200, body = "response_body")
|
87
|
+
return Net::HTTP.new("1.1", code, body)
|
88
|
+
end
|
89
|
+
|
90
|
+
def fake_digested_response(is_ok = true)
|
91
|
+
proxy = stub(Peachy::Proxy)#.new('<response status="ok"><content>test</content></response>')
|
92
|
+
proxy.stub!(:ok?).and_return(is_ok)
|
93
|
+
proxy
|
94
|
+
end
|
95
|
+
|
96
|
+
def stub_api_client(configuration, response_digestor)
|
97
|
+
@client = stub(Sevendigital::Client)
|
98
|
+
@client.stub!(:configuration).and_return(configuration)
|
99
|
+
@client.stub!(:api_response_digestor).and_return(response_digestor)
|
100
|
+
@client.stub!(:country).and_return("sk")
|
101
|
+
@client.stub!(:verbose?).and_return(false)
|
102
|
+
@client.stub!(:very_verbose?).and_return(false)
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
def stub_api_request
|
107
|
+
api_request = stub(Sevendigital::ApiRequest)
|
108
|
+
|
109
|
+
api_request.stub!(:parameters).and_return({})
|
110
|
+
api_request.stub!(:api_method).and_return("m")
|
111
|
+
api_request.stub!(:ensure_country_is_set)
|
112
|
+
return api_request
|
113
|
+
end
|
114
|
+
|
108
115
|
end
|
data/spec/api_request_spec.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
request
|
11
|
-
request.parameters[:
|
12
|
-
request.parameters[:
|
13
|
-
request.parameters[:
|
14
|
-
request.parameters
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
request
|
22
|
-
request.parameters[:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
|
3
|
+
describe "ApiRequest" do
|
4
|
+
|
5
|
+
it "should merge method parameters and options with parameters taking preference" do
|
6
|
+
|
7
|
+
parameters = {:trackId => 123, :releaseId => 456, :country => "CU"}
|
8
|
+
options = {:page => 1, :country => "US", :trackId => "SS"}
|
9
|
+
request = Sevendigital::ApiRequest.new('method', parameters, options)
|
10
|
+
request.parameters[:trackId].should == 123
|
11
|
+
request.parameters[:releaseId].should == 456
|
12
|
+
request.parameters[:country].should == "CU"
|
13
|
+
request.parameters[:page].should == 1
|
14
|
+
request.parameters.keys.size.should == 4 # page_size == null
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should provide paging parameters in 7digital API format" do
|
19
|
+
|
20
|
+
request = Sevendigital::ApiRequest.new('method', {}, {:page => 5, :per_page => 3 })
|
21
|
+
request.parameters[:page].should == 5
|
22
|
+
request.parameters[:pageSize].should == 3
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -1,46 +1,76 @@
|
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
|
3
|
+
describe "Client" do
|
4
|
+
|
5
|
+
it "should load default configuration" do
|
6
|
+
client = Sevendigital::Client.new
|
7
|
+
client.configuration.api_url.should == 'api.7digital.com'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should override default configuration with configuration hash" do
|
11
|
+
client = Sevendigital::Client.new(:api_url => "test-hash.7digital.com")
|
12
|
+
client.configuration.api_url.should == 'test-hash.7digital.com'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should override default configuration with configuration class" do
|
16
|
+
client = Sevendigital::Client.new(OpenStruct.new(:api_url => "test-openstruct.7digital.com"))
|
17
|
+
client.configuration.api_url.should == 'test-openstruct.7digital.com'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should use simple configuration file" do
|
21
|
+
client = Sevendigital::Client.new(File.join(File.dirname(__FILE__),"data", "configuration_override.yml"))
|
22
|
+
client.configuration.api_url.should == 'test-yml-simple.7digital.com'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should use environment specific configuration file" do
|
26
|
+
client = Sevendigital::Client.new(File.join(File.dirname(__FILE__),"data", "configuration_env_override.yml"))
|
27
|
+
client.configuration.api_url.should == 'test-yml-common.7digital.com'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should use environment specific configuration file with environment specific settings" do
|
31
|
+
Object.const_set(:RAILS_ENV, "development")
|
32
|
+
client = Sevendigital::Client.new(File.join(File.dirname(__FILE__),"data", "configuration_env_override.yml"))
|
33
|
+
client.configuration.api_url.should == 'test-yml-development.7digital.com'
|
34
|
+
Object.instance_eval{ remove_const :RAILS_ENV }
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should use rails/config/sevendigital configuration as default rails settings" do
|
38
|
+
Object.const_set(:RAILS_ROOT, File.join(File.dirname(__FILE__),"data"))
|
39
|
+
client = Sevendigital::Client.new()
|
40
|
+
client.configuration.api_url.should == 'test-yml-rails-common.7digital.com'
|
41
|
+
Object.instance_eval{ remove_const :RAILS_ROOT }
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not be verbose if not told to so" do
|
45
|
+
configuration = OpenStruct.new
|
46
|
+
client = Sevendigital::Client.new(configuration)
|
47
|
+
client.verbose?.should == false
|
48
|
+
client.very_verbose?.should == false
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be verbose if told to be verbose in configuration" do
|
52
|
+
configuration = OpenStruct.new
|
53
|
+
configuration.verbose = true
|
54
|
+
client = Sevendigital::Client.new(configuration)
|
55
|
+
client.verbose?.should == true
|
56
|
+
client.very_verbose?.should == false
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should be very verbose if told to be very verbose in configruation" do
|
60
|
+
configuration = OpenStruct.new
|
61
|
+
configuration.verbose = :very_verbose
|
62
|
+
client = Sevendigital::Client.new(configuration)
|
63
|
+
client.verbose?.should == true
|
64
|
+
client.very_verbose?.should == true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should be verbose if told so" do
|
68
|
+
configuration = OpenStruct.new
|
69
|
+
configuration.verbose = false
|
70
|
+
client = Sevendigital::Client.new(configuration)
|
71
|
+
client.verbose = true
|
72
|
+
client.verbose?.should == true
|
73
|
+
client.very_verbose?.should == false
|
74
|
+
end
|
75
|
+
|
46
76
|
end
|