thetvdb_api 0.2.3.1 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +30 -51
  4. data/lib/thetvdb_api/actor.rb +9 -9
  5. data/lib/thetvdb_api/banner.rb +9 -9
  6. data/lib/thetvdb_api/base.rb +10 -56
  7. data/lib/thetvdb_api/client.rb +6 -4
  8. data/lib/thetvdb_api/episode.rb +33 -34
  9. data/lib/thetvdb_api/search.rb +23 -35
  10. data/lib/thetvdb_api/series.rb +17 -17
  11. data/lib/thetvdb_api/update.rb +32 -32
  12. data/lib/thetvdb_api/version.rb +1 -1
  13. data/lib/thetvdb_api.rb +0 -12
  14. data/spec/fixtures/get_episode.xml +30 -0
  15. data/spec/fixtures/get_series.xml +24 -0
  16. data/spec/fixtures/get_series_by_remote.xml +14 -0
  17. data/spec/fixtures/updates.xml +35 -0
  18. data/spec/functionals/actor_spec.rb +30 -0
  19. data/spec/functionals/banner_spec.rb +30 -0
  20. data/spec/functionals/episode_spec.rb +85 -0
  21. data/spec/functionals/search_spec.rb +71 -0
  22. data/spec/functionals/series_spec.rb +48 -0
  23. data/spec/functionals/update_spec.rb +81 -0
  24. data/thetvdb_api.gemspec +2 -2
  25. metadata +34 -82
  26. data/lib/generators/templates/thetvdb_api.rb +0 -3
  27. data/lib/generators/thetvdb_api/install_generator.rb +0 -12
  28. data/lib/thetvdb_api/configuration.rb +0 -10
  29. data/lib/thetvdb_api/response/actors.rb +0 -7
  30. data/lib/thetvdb_api/response/banners.rb +0 -7
  31. data/lib/thetvdb_api/response/collection.rb +0 -9
  32. data/lib/thetvdb_api/response/episode.rb +0 -5
  33. data/lib/thetvdb_api/response/full_series.rb +0 -21
  34. data/lib/thetvdb_api/response/search_multiple_episode.rb +0 -7
  35. data/lib/thetvdb_api/response/search_multiple_series.rb +0 -7
  36. data/lib/thetvdb_api/response/search_series.rb +0 -5
  37. data/lib/thetvdb_api/response/series.rb +0 -5
  38. data/lib/thetvdb_api/response/update.rb +0 -31
  39. data/lib/thetvdb_api/response.rb +0 -52
  40. data/spec/functionals/classes/actor_spec.rb +0 -41
  41. data/spec/functionals/classes/banner_spec.rb +0 -42
  42. data/spec/functionals/classes/episode_spec.rb +0 -93
  43. data/spec/functionals/classes/series_spec.rb +0 -91
  44. data/spec/functionals/functional_spec_helper.rb +0 -7
  45. data/spec/functionals/support/stub_faraday.rb +0 -5
  46. data/spec/integrations/support/.keep +0 -0
  47. data/spec/units/classes/actor_spec.rb +0 -49
  48. data/spec/units/classes/banner_spec.rb +0 -49
  49. data/spec/units/classes/base_spec.rb +0 -123
  50. data/spec/units/classes/client_spec.rb +0 -41
  51. data/spec/units/classes/episode_spec.rb +0 -167
  52. data/spec/units/classes/response/actors_spec.rb +0 -15
  53. data/spec/units/classes/response/banners_spec.rb +0 -15
  54. data/spec/units/classes/response/collection_spec.rb +0 -38
  55. data/spec/units/classes/response/episode_spec.rb +0 -15
  56. data/spec/units/classes/response/full_series_spec.rb +0 -51
  57. data/spec/units/classes/response/search_multiple_episode_spec.rb +0 -15
  58. data/spec/units/classes/response/search_multiple_series_spec.rb +0 -15
  59. data/spec/units/classes/response/search_series_spec.rb +0 -15
  60. data/spec/units/classes/response/series_spec.rb +0 -15
  61. data/spec/units/classes/response/update_spec.rb +0 -79
  62. data/spec/units/classes/response_spec.rb +0 -100
  63. data/spec/units/classes/search_spec.rb +0 -178
  64. data/spec/units/classes/series_spec.rb +0 -92
  65. data/spec/units/classes/update_spec.rb +0 -178
  66. data/spec/units/unit_spec_helper.rb +0 -5
@@ -1,91 +0,0 @@
1
- require 'functionals/functional_spec_helper'
2
-
3
- describe ThetvdbApi::Series do
4
- include StubFaraday
5
-
6
- let(:model) { ThetvdbApi::Series.new(ThetvdbApi::Client.new) }
7
-
8
- let(:series_data) { File.read('spec/fixtures/series.xml') }
9
- let(:full_series_data) { File.read('spec/fixtures/full_series.xml') }
10
-
11
- let(:faraday_stubs) do
12
- Faraday::Adapter::Test::Stubs.new do |stub|
13
- stub.get('/api/123456789/series/1234/en.xml') { [200, {}, series_data] }
14
- stub.get('/api/123456789/series/1234/all/en.xml') { [200, {}, full_series_data] }
15
- end
16
- end
17
-
18
- def series_keys
19
- ['id', 'Actors', 'Airs_DayOfWeek', 'Airs_Time', 'ContentRating', 'FirstAired', 'Genre', 'IMDB_ID', 'Language',
20
- 'Network', 'NetworkID', 'Overview', 'Rating', 'RatingCount', 'Runtime', 'SeriesID', 'SeriesName', 'Status',
21
- 'added', 'addedBy', 'banner', 'fanart', 'lastupdated', 'poster', 'zap2it_id'].sort
22
- end
23
-
24
- def episode_keys
25
- ['Combined_episodenumber', 'Combined_season', 'DVD_chapter', 'DVD_discid', 'DVD_episodenumber', 'DVD_season',
26
- 'Director', 'EpImgFlag', 'EpisodeName', 'EpisodeNumber', 'FirstAired', 'GuestStars', 'IMDB_ID', 'Language',
27
- 'Overview', 'ProductionCode', 'Rating', 'RatingCount', 'SeasonNumber', 'Writer', 'absolute_number',
28
- 'airsafter_season', 'airsbefore_episode', 'airsbefore_season', 'filename', 'id', 'lastupdated', 'seasonid',
29
- 'seriesid', 'thumb_added', 'thumb_height', 'thumb_width'].sort
30
- end
31
-
32
- before do
33
- stub_request(model, faraday_stubs)
34
- end
35
-
36
- describe '.find' do
37
- it 'should return string without mapping' do
38
- model.find(1234).body.class.should == String
39
- end
40
-
41
- describe 'with mapping' do
42
- it 'should return Hash' do
43
- model.find(1234, mapping: true).body.class.should == Hash
44
- end
45
-
46
- it 'should return specific keys' do
47
- model.find(1234, mapping: true).body.keys.sort.should == series_keys
48
- end
49
- end
50
- end
51
-
52
- describe '.find_full' do
53
- it 'should return string without mapping' do
54
- model.find_full(1234).body.class.should == String
55
- end
56
-
57
- describe 'with mapping' do
58
- it 'should return Hash' do
59
- model.find_full(1234, mapping: true).body.class.should == Hash
60
- end
61
-
62
- it 'should return specific keys' do
63
- model.find_full(1234, mapping: true).body.keys.sort.should == ['Series', 'Episode'].sort
64
- end
65
-
66
- describe 'Series' do
67
- it 'should return Hash' do
68
- model.find_full(1234, mapping: true).body['Series'].class.should == Hash
69
- end
70
-
71
- it 'should return specific keys' do
72
- model.find_full(1234, mapping: true).body['Series'].keys.sort.should == series_keys
73
- end
74
- end
75
-
76
- describe 'Episode' do
77
- it 'should return Array' do
78
- model.find_full(1234, mapping: true).body['Episode'].class.should == Array
79
- end
80
-
81
- it 'should return not empty Array' do
82
- model.find_full(1234, mapping: true).body['Episode'].should_not be_empty
83
- end
84
-
85
- it 'should return specific keys for first element' do
86
- model.find_full(1234, mapping: true).body['Episode'].first.keys.sort.should == episode_keys
87
- end
88
- end
89
- end
90
- end
91
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
- require 'functionals/support/stub_faraday'
3
-
4
- ThetvdbApi::Configuration.configure do |config|
5
- config.api_key = '123456789'
6
- config.adapter = :test
7
- end
@@ -1,5 +0,0 @@
1
- module StubFaraday
2
- def stub_request(model, args)
3
- model.connection.instance_variable_get('@builder').handlers.first.instance_variable_set('@args', args)
4
- end
5
- end
File without changes
@@ -1,49 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Actor do
4
- let(:klass) { ThetvdbApi::Actor }
5
- let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
-
7
- describe '.find' do
8
- it 'should call find_get_with_params with specific arguments' do
9
- model.should_receive(:find_get_with_params).with('1234', {}).and_return(double(response: true))
10
-
11
- model.find('1234')
12
- end
13
-
14
- it 'should call response with specific arguments' do
15
- model.should_receive(:response).with(ThetvdbApi::Response::Actors)
16
-
17
- model.find('1234')
18
- end
19
- end
20
-
21
- describe '.find_url' do
22
- it 'should call find_get_with_params with specific arguments' do
23
- model.should_receive(:find_get_with_params).with('1234').and_return(double(url: true))
24
-
25
- model.find_url('1234')
26
- end
27
-
28
- it 'should call url' do
29
- model.should_receive(:url)
30
-
31
- model.find_url('1234')
32
- end
33
- end
34
-
35
- describe '.find_get_with_params' do
36
- it 'should call get with specific arguments' do
37
- model.stub(:find_path).and_return('PATH')
38
- model.should_receive(:get).with('PATH').and_return(double(params: true))
39
-
40
- model.find_get_with_params('1234')
41
- end
42
-
43
- it 'should call params with specific arguments' do
44
- model.should_receive(:params).with(series_id: '1234')
45
-
46
- model.find_get_with_params('1234')
47
- end
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Banner do
4
- let(:klass) { ThetvdbApi::Banner }
5
- let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
-
7
- describe '.find' do
8
- it 'should call find_get_with_params with specific arguments' do
9
- model.should_receive(:find_get_with_params).with('1234', {}).and_return(double(response: true))
10
-
11
- model.find('1234')
12
- end
13
-
14
- it 'should call response with specific arguments' do
15
- model.should_receive(:response).with(ThetvdbApi::Response::Banners)
16
-
17
- model.find('1234')
18
- end
19
- end
20
-
21
- describe '.find_url' do
22
- it 'should call find_get_with_params with specific arguments' do
23
- model.should_receive(:find_get_with_params).with('1234').and_return(double(url: true))
24
-
25
- model.find_url('1234')
26
- end
27
-
28
- it 'should call url' do
29
- model.should_receive(:url)
30
-
31
- model.find_url('1234')
32
- end
33
- end
34
-
35
- describe '.find_get_with_params' do
36
- it 'should call get with specific arguments' do
37
- model.stub(:find_path).and_return('PATH')
38
- model.should_receive(:get).with('PATH').and_return(double(params: true))
39
-
40
- model.find_get_with_params('1234')
41
- end
42
-
43
- it 'should call params with specific arguments' do
44
- model.should_receive(:params).with(series_id: '1234')
45
-
46
- model.find_get_with_params('1234')
47
- end
48
- end
49
- end
@@ -1,123 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- class ExampleClass < ThetvdbApi::Base
4
- end
5
-
6
- describe ThetvdbApi::Base do
7
- let(:klass) { ExampleClass }
8
- let(:model) { klass.new(ThetvdbApi::Client.new) }
9
-
10
- describe '.connection' do
11
- it 'should create instance of Faraday' do
12
- Faraday.should_receive(:new).with(url: 'http://thetvdb.com/api/')
13
-
14
- model.connection
15
- end
16
-
17
- it 'should use adapter from configuration' do
18
- ThetvdbApi::Configuration.stub(:adapter).and_return(:test)
19
- ThetvdbApi::Configuration.should_receive(:adapter)
20
-
21
- model.connection
22
- end
23
- end
24
-
25
- describe '.get' do
26
- it 'should set @uri_template' do
27
- model.get('http://example.com')
28
-
29
- model.instance_variable_get('@uri_template').class.should == URITemplate::RFC6570
30
- end
31
-
32
- it 'should return self' do
33
- model.get('http://example.com').should == model
34
- end
35
- end
36
-
37
- describe '.params' do
38
- it 'should set @params' do
39
- model.params(sample: 'test')
40
-
41
- model.instance_variable_get('@params').should == { language: 'en', sample: 'test' }
42
- end
43
-
44
- it 'should return self' do
45
- model.params(sample: 'test').should == model
46
- end
47
- end
48
-
49
- describe '.response' do
50
- it 'should raise error when @uri_template is not filled' do
51
- -> { model.response }.should raise_error
52
- end
53
-
54
- it 'should call get klass method' do
55
- model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
56
- model.stub(:connection).and_return(double(get: true))
57
- model.connection.should_receive(:get)
58
-
59
- model.response
60
- end
61
- end
62
-
63
- describe '.prepare_uri' do
64
- it 'should receive correct uri string' do
65
- model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
66
-
67
- model.prepare_uri.should == "#{model.api_key}/series/"
68
- end
69
- end
70
-
71
- describe '.url' do
72
- it 'should receive correct string' do
73
- model.stub(:base_url).and_return('BASE_URL/')
74
- model.stub(:uri).and_return('URI')
75
-
76
- model.url.should == 'BASE_URL/URI'
77
- end
78
- end
79
-
80
- describe '.uri' do
81
- it 'should receive correct uri string' do
82
- model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
83
- model.instance_variable_set('@params', id: '1234')
84
-
85
- model.uri.should == "#{model.api_key}/series/1234"
86
- end
87
- end
88
-
89
- describe '.restful_param_keys' do
90
- it 'should receive correct uri string' do
91
- uri_template = URITemplate.new('{api_key}/series/{id}')
92
- model.instance_variable_set('@uri_template', uri_template)
93
-
94
- model.restful_param_keys(uri_template.expand).sort.should == ['api_key', 'id'].sort
95
- end
96
- end
97
-
98
- describe '.series_uri' do
99
- it 'should use default api_key' do
100
- klass.new(ThetvdbApi::Client.new(api_key: 'API_KEY')).series_uri.should == '{api_key}/series/{series_id}'
101
- end
102
- end
103
-
104
- describe '.language' do
105
- it 'should use default language' do
106
- klass.new(ThetvdbApi::Client.new).language.should == 'en'
107
- end
108
-
109
- it 'should set language' do
110
- klass.new(ThetvdbApi::Client.new(language: 'LANGUAGE')).language.should == 'LANGUAGE'
111
- end
112
- end
113
-
114
- describe '.api_key' do
115
- it 'should use default api_key' do
116
- klass.new(ThetvdbApi::Client.new).api_key.should == ThetvdbApi::Configuration.api_key
117
- end
118
-
119
- it 'should set api_Key' do
120
- klass.new(ThetvdbApi::Client.new(api_key: 'API_KEY')).api_key.should == 'API_KEY'
121
- end
122
- end
123
- end
@@ -1,41 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Client do
4
- let(:klass) { ThetvdbApi::Client }
5
-
6
- describe '.search' do
7
- it 'should return search class' do
8
- klass.new.search.class.should == ThetvdbApi::Search
9
- end
10
- end
11
-
12
- describe '.series' do
13
- it 'should return series class' do
14
- klass.new.series.class.should == ThetvdbApi::Series
15
- end
16
- end
17
-
18
- describe '.actor' do
19
- it 'should return actor class' do
20
- klass.new.actor.class.should == ThetvdbApi::Actor
21
- end
22
- end
23
-
24
- describe '.banner' do
25
- it 'should return banner class' do
26
- klass.new.banner.class.should == ThetvdbApi::Banner
27
- end
28
- end
29
-
30
- describe '.episode' do
31
- it 'should return episode class' do
32
- klass.new.episode.class.should == ThetvdbApi::Episode
33
- end
34
- end
35
-
36
- describe '.update' do
37
- it 'should return update class' do
38
- klass.new.update.class.should == ThetvdbApi::Update
39
- end
40
- end
41
- end
@@ -1,167 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Episode do
4
- let(:klass) { ThetvdbApi::Episode }
5
- let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
-
7
- describe '.find_by_default_order' do
8
- it 'should call find_by_order with specific params' do
9
- model.should_receive(:find_by_order).with('default', '1234', '1', '1', {})
10
-
11
- model.find_by_default_order('1234', '1', '1')
12
- end
13
- end
14
-
15
- describe '.find_by_default_order_url' do
16
- it 'should call find_by_order with specific params' do
17
- model.should_receive(:find_by_order_url).with('default', '1234', '1', '1', {})
18
-
19
- model.find_by_default_order_url('1234', '1', '1')
20
- end
21
- end
22
-
23
- describe '.find_by_dvd_order' do
24
- it 'should call find_by_order with specific params' do
25
- model.should_receive(:find_by_order).with('dvd', '1234', '1', '1', {})
26
-
27
- model.find_by_dvd_order('1234', '1', '1')
28
- end
29
- end
30
-
31
- describe '.find_by_dvd_order_url' do
32
- it 'should call find_by_order with specific params' do
33
- model.should_receive(:find_by_order_url).with('dvd', '1234', '1', '1', {})
34
-
35
- model.find_by_dvd_order_url('1234', '1', '1')
36
- end
37
- end
38
-
39
- describe '.find_by_absolute_order' do
40
- it 'should call find_get_with_params with specific arguments' do
41
- model.should_receive(:find_by_absolute_order_get_with_params).with('1234', '1', {}).and_return(double(response: true))
42
-
43
- model.find_by_absolute_order('1234', '1')
44
- end
45
-
46
- it 'should call response with specific arguments' do
47
- model.should_receive(:response).with(ThetvdbApi::Response::Episode)
48
-
49
- model.find_by_absolute_order('1234', '1')
50
- end
51
- end
52
-
53
- describe '.find_by_absolute_order_url' do
54
- it 'should call find_get_with_params with specific arguments' do
55
- model.should_receive(:find_by_absolute_order_get_with_params).with('1234', '1', {}).and_return(double(url: true))
56
-
57
- model.find_by_absolute_order_url('1234', '1')
58
- end
59
-
60
- it 'should call url' do
61
- model.should_receive(:url)
62
-
63
- model.find_by_absolute_order_url('1234', '1')
64
- end
65
- end
66
-
67
- describe '.find_by_absolute_order_get_with_params' do
68
- it 'should call get with specific arguments' do
69
- model.stub(:find_by_absolute_order_path).and_return('PATH')
70
- model.should_receive(:get).with('PATH').and_return(double(params: true))
71
-
72
- model.find_by_absolute_order_get_with_params('1234', '1', {})
73
- end
74
-
75
- it 'should call params with specific arguments' do
76
- model.should_receive(:params).with(series_id: '1234', absolute: '1')
77
-
78
- model.find_by_absolute_order_get_with_params('1234', '1', {})
79
- end
80
- end
81
-
82
- describe '.find' do
83
- it 'should call find_get_with_params with specific arguments' do
84
- model.should_receive(:find_get_with_params).with('1234', {}).and_return(double(response: true))
85
-
86
- model.find('1234')
87
- end
88
-
89
- it 'should call response with specific arguments' do
90
- model.should_receive(:response).with(ThetvdbApi::Response::Episode)
91
-
92
- model.find('1234')
93
- end
94
- end
95
-
96
- describe '.find_url' do
97
- it 'should call find_get_with_params with specific arguments' do
98
- model.should_receive(:find_get_with_params).with('1234', {}).and_return(double(url: true))
99
-
100
- model.find_url('1234')
101
- end
102
-
103
- it 'should call url' do
104
- model.should_receive(:url)
105
-
106
- model.find_url('1234')
107
- end
108
- end
109
-
110
- describe '.find_get_with_params' do
111
- it 'should call get with specific arguments' do
112
- model.stub(:find_path).and_return('PATH')
113
- model.should_receive(:get).with('PATH').and_return(double(params: true))
114
-
115
- model.find_get_with_params('1234', {})
116
- end
117
-
118
- it 'should call params with specific arguments' do
119
- model.should_receive(:params).with(episode_id: '1234')
120
-
121
- model.find_get_with_params('1234', {})
122
- end
123
- end
124
-
125
- describe '.find_by_order' do
126
- it 'should call find_get_with_params with specific arguments' do
127
- model.should_receive(:find_by_order_get_with_params).with('default', '1234', '1', '1', {}).and_return(double(response: true))
128
-
129
- model.find_by_order('default', '1234', '1', '1', {})
130
- end
131
-
132
- it 'should call response with specific arguments' do
133
- model.should_receive(:response).with(ThetvdbApi::Response::Episode)
134
-
135
- model.find_by_order('default', '1234', '1', '1', {})
136
- end
137
- end
138
-
139
- describe '.find_by_order_url' do
140
- it 'should call find_get_with_params with specific arguments' do
141
- model.should_receive(:find_by_order_get_with_params).with('default', '1234', '1', '1', {}).and_return(double(url: true))
142
-
143
- model.find_by_order_url('default', '1234', '1', '1', {})
144
- end
145
-
146
- it 'should call url' do
147
- model.should_receive(:url)
148
-
149
- model.find_by_order_url('default', '1234', '1', '1', {})
150
- end
151
- end
152
-
153
- describe '.find_by_order_get_with_params' do
154
- it 'should call get with specific arguments' do
155
- model.stub(:find_by_order_path).and_return('PATH')
156
- model.should_receive(:get).with('PATH').and_return(double(params: true))
157
-
158
- model.find_by_order_get_with_params('default', '1234', '1', '1', {})
159
- end
160
-
161
- it 'should call params with specific arguments' do
162
- model.should_receive(:params).with(series_id: '1234', season: '1', episode: '1', order: 'default')
163
-
164
- model.find_by_order_get_with_params('default', '1234', '1', '1', {})
165
- end
166
- end
167
- end
@@ -1,15 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Response::Actors do
4
- let(:klass) { ThetvdbApi::Response::Actors }
5
- let(:model) { klass.new(faraday_response) }
6
- let(:faraday_response) { double(env: true, status: true, headers: true, body: 'TEST') }
7
-
8
- describe '.xml_parse' do
9
- it 'should return correct data' do
10
- model.stub(:multi_xml_parse).and_return({ 'Actors' => { 'Actor' => 'ACTOR DATA' } })
11
-
12
- model.xml_parse.should == 'ACTOR DATA'
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Response::Banners do
4
- let(:klass) { ThetvdbApi::Response::Banners }
5
- let(:model) { klass.new(faraday_response) }
6
- let(:faraday_response) { double(env: true, status: true, headers: true, body: 'TEST') }
7
-
8
- describe '.xml_parse' do
9
- it 'should return correct data' do
10
- model.stub(:multi_xml_parse).and_return({ 'Banners' => { 'Banner' => 'BANNER DATA' } })
11
-
12
- model.xml_parse.should == 'BANNER DATA'
13
- end
14
- end
15
- end
@@ -1,38 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- class ExampleResponseClass
4
- include ThetvdbApi::Response::Collection
5
- end
6
-
7
- describe ThetvdbApi::Response::Collection do
8
- let(:klass) { ExampleResponseClass }
9
- let(:model) { klass.new }
10
- let(:faraday_response) { double(env: true, status: true, headers: true, body: 'TEST') }
11
-
12
- describe '.body' do
13
- describe 'with mapping' do
14
- it 'should return array when parse return array' do
15
- model.instance_variable_set('@mapping', true)
16
- model.stub(:parse).and_return([])
17
-
18
- model.body.class.should == Array
19
- end
20
-
21
- it 'should return array when parse return hash' do
22
- model.instance_variable_set('@mapping', true)
23
- model.stub(:parse).and_return({})
24
-
25
- model.body.class.should == Array
26
- end
27
- end
28
-
29
- describe 'without mapping' do
30
- it 'should return faraday response' do
31
- model.instance_variable_set('@mapping', false)
32
- model.instance_variable_set('@faraday_response', faraday_response)
33
-
34
- model.body.should == 'TEST'
35
- end
36
- end
37
- end
38
- end
@@ -1,15 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Response::Episode do
4
- let(:klass) { ThetvdbApi::Response::Episode }
5
- let(:model) { klass.new(faraday_response) }
6
- let(:faraday_response) { double(env: true, status: true, headers: true, body: 'TEST') }
7
-
8
- describe '.xml_parse' do
9
- it 'should return correct data' do
10
- model.stub(:multi_xml_parse).and_return({ 'Data' => { 'Episode' => 'EPISODE DATA' } })
11
-
12
- model.xml_parse.should == 'EPISODE DATA'
13
- end
14
- end
15
- end
@@ -1,51 +0,0 @@
1
- require 'units/unit_spec_helper'
2
-
3
- describe ThetvdbApi::Response::FullSeries do
4
- let(:klass) { ThetvdbApi::Response::FullSeries }
5
- let(:model) { klass.new(faraday_response) }
6
- let(:faraday_response) { double(env: true, status: true, headers: true, body: 'TEST') }
7
-
8
- describe '.parse' do
9
- before do
10
- model.stub(:xml_parse).and_return({ 'Data' => { 'Series' => [], 'Episode' => [] } })
11
- end
12
-
13
- it 'should call xml_parse' do
14
- model.should_receive(:xml_parse)
15
-
16
- model.parse
17
- end
18
-
19
- it 'should call episode_normalize' do
20
- model.should_receive(:episode_normalize)
21
-
22
- model.parse
23
- end
24
- end
25
-
26
- describe '.xml_parse' do
27
- it 'should return correct data' do
28
- model.stub(:multi_xml_parse).and_return({ 'Data' => 'FULL SERIES DATA' })
29
-
30
- model.xml_parse.should == 'FULL SERIES DATA'
31
- end
32
- end
33
-
34
- describe '.episode_normalize' do
35
- it 'should call normalize with Episode argument' do
36
- model.should_receive(:normalize).with('Episode')
37
-
38
- model.episode_normalize
39
- end
40
- end
41
-
42
- describe '.normalize' do
43
- it 'should convert hash to array' do
44
- model.instance_variable_set('@parse', { 'Episode' => {} })
45
-
46
- model.normalize('Episode')
47
-
48
- model.parse['Episode'].should == [{}]
49
- end
50
- end
51
- end