thetvdb_api 0.2.1 → 0.2.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +36 -81
  4. data/lib/thetvdb_api/actor.rb +15 -1
  5. data/lib/thetvdb_api/banner.rb +15 -1
  6. data/lib/thetvdb_api/base.rb +4 -4
  7. data/lib/thetvdb_api/episode.rb +50 -5
  8. data/lib/thetvdb_api/response/actors.rb +7 -0
  9. data/lib/thetvdb_api/response/banners.rb +7 -0
  10. data/lib/thetvdb_api/response/collection.rb +9 -0
  11. data/lib/thetvdb_api/response/episode.rb +5 -0
  12. data/lib/thetvdb_api/response/full_series.rb +21 -0
  13. data/lib/thetvdb_api/response/search_multiple_episode.rb +7 -0
  14. data/lib/thetvdb_api/response/search_multiple_series.rb +7 -0
  15. data/lib/thetvdb_api/response/search_series.rb +5 -0
  16. data/lib/thetvdb_api/response/series.rb +5 -0
  17. data/lib/thetvdb_api/response/update.rb +31 -0
  18. data/lib/thetvdb_api/response.rb +30 -8
  19. data/lib/thetvdb_api/search.rb +50 -4
  20. data/lib/thetvdb_api/series.rb +28 -2
  21. data/lib/thetvdb_api/update.rb +24 -8
  22. data/lib/thetvdb_api/version.rb +1 -1
  23. data/lib/thetvdb_api.rb +11 -1
  24. data/spec/integrations/actor_spec.rb +1 -1
  25. data/spec/integrations/banner_spec.rb +1 -1
  26. data/spec/integrations/client_spec.rb +15 -15
  27. data/spec/integrations/episode_spec.rb +4 -4
  28. data/spec/integrations/search_spec.rb +4 -4
  29. data/spec/integrations/series_spec.rb +2 -2
  30. data/spec/integrations/update_spec.rb +4 -4
  31. data/spec/spec_helper.rb +0 -21
  32. data/spec/units/actor_spec.rb +49 -0
  33. data/spec/units/banner_spec.rb +49 -0
  34. data/spec/units/episode_spec.rb +167 -0
  35. data/spec/units/response/actors_spec.rb +15 -0
  36. data/spec/units/response/banners_spec.rb +15 -0
  37. data/spec/units/response/collection_spec.rb +38 -0
  38. data/spec/units/response/episode_spec.rb +15 -0
  39. data/spec/units/response/full_series_spec.rb +51 -0
  40. data/spec/units/response/search_multiple_episode_spec.rb +15 -0
  41. data/spec/units/response/search_multiple_series_spec.rb +15 -0
  42. data/spec/units/response/search_series_spec.rb +15 -0
  43. data/spec/units/response/series_spec.rb +15 -0
  44. data/spec/units/response/update_spec.rb +79 -0
  45. data/spec/units/response_spec.rb +100 -0
  46. data/spec/units/search_spec.rb +178 -0
  47. data/spec/units/series_spec.rb +92 -0
  48. data/spec/units/update_spec.rb +178 -0
  49. data/thetvdb_api.gemspec +1 -1
  50. metadata +53 -49
  51. data/lib/thetvdb_api/mappers/actor.rb +0 -17
  52. data/lib/thetvdb_api/mappers/actors.rb +0 -10
  53. data/lib/thetvdb_api/mappers/banner.rb +0 -32
  54. data/lib/thetvdb_api/mappers/banners.rb +0 -10
  55. data/lib/thetvdb_api/mappers/base_mapper.rb +0 -13
  56. data/lib/thetvdb_api/mappers/episode.rb +0 -35
  57. data/lib/thetvdb_api/mappers/full_series.rb +0 -12
  58. data/lib/thetvdb_api/mappers/search_episode.rb +0 -10
  59. data/lib/thetvdb_api/mappers/search_series/series.rb +0 -25
  60. data/lib/thetvdb_api/mappers/search_series.rb +0 -10
  61. data/lib/thetvdb_api/mappers/series.rb +0 -40
  62. data/lib/thetvdb_api/mappers/update/banner.rb +0 -19
  63. data/lib/thetvdb_api/mappers/update/element.rb +0 -10
  64. data/lib/thetvdb_api/mappers/update/episode.rb +0 -8
  65. data/lib/thetvdb_api/mappers/update/series.rb +0 -8
  66. data/lib/thetvdb_api/mappers/update.rb +0 -14
  67. data/spec/thetvdb_api/actor_spec.rb +0 -21
  68. data/spec/thetvdb_api/banner_spec.rb +0 -21
  69. data/spec/thetvdb_api/episode_spec.rb +0 -63
  70. data/spec/thetvdb_api/mappers/actor_spec.rb +0 -15
  71. data/spec/thetvdb_api/mappers/banner_spec.rb +0 -31
  72. data/spec/thetvdb_api/mappers/search_series/series_spec.rb +0 -15
  73. data/spec/thetvdb_api/mappers/series_spec.rb +0 -31
  74. data/spec/thetvdb_api/mappers/update/banner_spec.rb +0 -15
  75. data/spec/thetvdb_api/response_spec.rb +0 -60
  76. data/spec/thetvdb_api/search_spec.rb +0 -63
  77. data/spec/thetvdb_api/series_spec.rb +0 -35
  78. data/spec/thetvdb_api/update_spec.rb +0 -63
  79. /data/spec/{thetvdb_api → units}/base_spec.rb +0 -0
  80. /data/spec/{thetvdb_api → units}/client_spec.rb +0 -0
data/lib/thetvdb_api.rb CHANGED
@@ -1,10 +1,20 @@
1
1
  module ThetvdbApi
2
- module Mappers; end
2
+ module Mapper; end
3
3
  end
4
4
 
5
5
  require 'thetvdb_api/version'
6
6
  require 'thetvdb_api/configuration'
7
7
  require 'thetvdb_api/response'
8
+ require 'thetvdb_api/response/collection'
9
+ require 'thetvdb_api/response/search_multiple_episode'
10
+ require 'thetvdb_api/response/search_multiple_series'
11
+ require 'thetvdb_api/response/search_series'
12
+ require 'thetvdb_api/response/update'
13
+ require 'thetvdb_api/response/actors'
14
+ require 'thetvdb_api/response/banners'
15
+ require 'thetvdb_api/response/episode'
16
+ require 'thetvdb_api/response/series'
17
+ require 'thetvdb_api/response/full_series'
8
18
  require 'thetvdb_api/client'
9
19
  require 'thetvdb_api/base'
10
20
  require 'thetvdb_api/search'
@@ -6,7 +6,7 @@ describe ThetvdbApi::Actor do
6
6
  describe 'real request' do
7
7
  describe '.find' do
8
8
  it 'should return response class' do
9
- model.find('70327').class.should == ThetvdbApi::Response
9
+ model.find('70327').class.should == ThetvdbApi::Response::Actors
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ describe ThetvdbApi::Banner do
6
6
  describe 'real request' do
7
7
  describe '.find' do
8
8
  it 'should return response class' do
9
- model.find('72449').class.should == ThetvdbApi::Response
9
+ model.find('72449').class.should == ThetvdbApi::Response::Banners
10
10
  end
11
11
  end
12
12
  end
@@ -7,25 +7,25 @@ describe ThetvdbApi::Client do
7
7
  describe '.search' do
8
8
  describe '.get_series' do
9
9
  it 'should return response class' do
10
- client.search.get_series('buffy').class.should == ThetvdbApi::Response
10
+ client.search.get_series('buffy').class.should == ThetvdbApi::Response::SearchMultipleSeries
11
11
  end
12
12
  end
13
13
 
14
14
  describe '.get_series_by_imdb_id' do
15
15
  it 'should return response class' do
16
- client.search.get_series_by_imdb_id('tt0118276').class.should == ThetvdbApi::Response
16
+ client.search.get_series_by_imdb_id('tt0118276').class.should == ThetvdbApi::Response::SearchSeries
17
17
  end
18
18
  end
19
19
 
20
20
  describe '.get_series_by_zap2it_id' do
21
21
  it 'should return response class' do
22
- client.search.get_series_by_zap2it_id('EP00213110').class.should == ThetvdbApi::Response
22
+ client.search.get_series_by_zap2it_id('EP00213110').class.should == ThetvdbApi::Response::SearchSeries
23
23
  end
24
24
  end
25
25
 
26
26
  describe '.get_episode' do
27
27
  it 'should return response class' do
28
- client.search.get_episode('70327','1997-03-10').class.should == ThetvdbApi::Response
28
+ client.search.get_episode('70327','1997-03-10').class.should == ThetvdbApi::Response::SearchMultipleEpisode
29
29
  end
30
30
  end
31
31
  end
@@ -33,13 +33,13 @@ describe ThetvdbApi::Client do
33
33
  describe '.series' do
34
34
  describe '.find' do
35
35
  it 'should return response class' do
36
- client.series.find('70327').class.should == ThetvdbApi::Response
36
+ client.series.find('70327').class.should == ThetvdbApi::Response::Series
37
37
  end
38
38
  end
39
39
 
40
40
  describe '.find_full' do
41
41
  it 'should return response class' do
42
- client.series.find_full('70327').class.should == ThetvdbApi::Response
42
+ client.series.find_full('70327').class.should == ThetvdbApi::Response::FullSeries
43
43
  end
44
44
  end
45
45
  end
@@ -47,7 +47,7 @@ describe ThetvdbApi::Client do
47
47
  describe '.actor' do
48
48
  describe '.find' do
49
49
  it 'should return response class' do
50
- client.actor.find('70327').class.should == ThetvdbApi::Response
50
+ client.actor.find('70327').class.should == ThetvdbApi::Response::Actors
51
51
  end
52
52
  end
53
53
  end
@@ -55,7 +55,7 @@ describe ThetvdbApi::Client do
55
55
  describe '.banner' do
56
56
  describe '.find' do
57
57
  it 'should return response class' do
58
- client.banner.find('70327').class.should == ThetvdbApi::Response
58
+ client.banner.find('70327').class.should == ThetvdbApi::Response::Banners
59
59
  end
60
60
  end
61
61
  end
@@ -63,25 +63,25 @@ describe ThetvdbApi::Client do
63
63
  describe '.episode' do
64
64
  describe '.find_by_default_order' do
65
65
  it 'should return response class' do
66
- client.episode.find_by_default_order('70327', '1', '1').class.should == ThetvdbApi::Response
66
+ client.episode.find_by_default_order('70327', '1', '1').class.should == ThetvdbApi::Response::Episode
67
67
  end
68
68
  end
69
69
 
70
70
  describe '.find_by_dvd_order' do
71
71
  it 'should return response class' do
72
- client.episode.find_by_dvd_order('70327', '1', '1').class.should == ThetvdbApi::Response
72
+ client.episode.find_by_dvd_order('70327', '1', '1').class.should == ThetvdbApi::Response::Episode
73
73
  end
74
74
  end
75
75
 
76
76
  describe '.find_by_absolute_order' do
77
77
  it 'should return response class' do
78
- client.episode.find_by_absolute_order('70327', '1').class.should == ThetvdbApi::Response
78
+ client.episode.find_by_absolute_order('70327', '1').class.should == ThetvdbApi::Response::Episode
79
79
  end
80
80
  end
81
81
 
82
82
  describe '.find' do
83
83
  it 'should return response class' do
84
- client.episode.find('533011').class.should == ThetvdbApi::Response
84
+ client.episode.find('533011').class.should == ThetvdbApi::Response::Episode
85
85
  end
86
86
  end
87
87
  end
@@ -89,19 +89,19 @@ describe ThetvdbApi::Client do
89
89
  describe '.update' do
90
90
  describe '.day' do
91
91
  it 'should return response class' do
92
- client.update.day.class.should == ThetvdbApi::Response
92
+ client.update.day.class.should == ThetvdbApi::Response::Update
93
93
  end
94
94
  end
95
95
 
96
96
  describe '.week' do
97
97
  it 'should return response class' do
98
- client.update.week.class.should == ThetvdbApi::Response
98
+ client.update.week.class.should == ThetvdbApi::Response::Update
99
99
  end
100
100
  end
101
101
 
102
102
  describe '.month' do
103
103
  it 'should return response class' do
104
- client.update.month.class.should == ThetvdbApi::Response
104
+ client.update.month.class.should == ThetvdbApi::Response::Update
105
105
  end
106
106
  end
107
107
  end
@@ -6,25 +6,25 @@ describe ThetvdbApi::Episode do
6
6
  describe 'real request' do
7
7
  describe '.find_by_default_order' do
8
8
  it 'should return response class' do
9
- model.find_by_default_order('70327', '1', '1').class.should == ThetvdbApi::Response
9
+ model.find_by_default_order('70327', '1', '1').class.should == ThetvdbApi::Response::Episode
10
10
  end
11
11
  end
12
12
 
13
13
  describe '.find_by_dvd_order' do
14
14
  it 'should return response class' do
15
- model.find_by_dvd_order('70327', '1', '1').class.should == ThetvdbApi::Response
15
+ model.find_by_dvd_order('70327', '1', '1').class.should == ThetvdbApi::Response::Episode
16
16
  end
17
17
  end
18
18
 
19
19
  describe '.find_by_absolute_order' do
20
20
  it 'should return response class' do
21
- model.find_by_absolute_order('70327', '1').class.should == ThetvdbApi::Response
21
+ model.find_by_absolute_order('70327', '1').class.should == ThetvdbApi::Response::Episode
22
22
  end
23
23
  end
24
24
 
25
25
  describe '.find' do
26
26
  it 'should return response class' do
27
- model.find('533011').class.should == ThetvdbApi::Response
27
+ model.find('533011').class.should == ThetvdbApi::Response::Episode
28
28
  end
29
29
  end
30
30
  end
@@ -6,25 +6,25 @@ describe ThetvdbApi::Search do
6
6
  describe 'real request' do
7
7
  describe '.get_series' do
8
8
  it 'should return response class' do
9
- model.get_series('buffy').class.should == ThetvdbApi::Response
9
+ model.get_series('buffy').class.should == ThetvdbApi::Response::SearchMultipleSeries
10
10
  end
11
11
  end
12
12
 
13
13
  describe '.get_series_by_imdb_id' do
14
14
  it 'should return response class' do
15
- model.get_series_by_imdb_id('tt0118276').class.should == ThetvdbApi::Response
15
+ model.get_series_by_imdb_id('tt0118276').class.should == ThetvdbApi::Response::SearchSeries
16
16
  end
17
17
  end
18
18
 
19
19
  describe '.get_series_by_zap2it_id' do
20
20
  it 'should return response class' do
21
- model.get_series_by_zap2it_id('EP00213110').class.should == ThetvdbApi::Response
21
+ model.get_series_by_zap2it_id('EP00213110').class.should == ThetvdbApi::Response::SearchSeries
22
22
  end
23
23
  end
24
24
 
25
25
  describe '.get_episode' do
26
26
  it 'should return response class' do
27
- model.get_episode('70327', '1997-03-10').class.should == ThetvdbApi::Response
27
+ model.get_episode('70327', '1997-03-10').class.should == ThetvdbApi::Response::SearchMultipleEpisode
28
28
  end
29
29
  end
30
30
  end
@@ -6,13 +6,13 @@ describe ThetvdbApi::Series do
6
6
  describe 'real request' do
7
7
  describe '.find' do
8
8
  it 'should return response class' do
9
- model.find('70327').class.should == ThetvdbApi::Response
9
+ model.find('70327').class.should == ThetvdbApi::Response::Series
10
10
  end
11
11
  end
12
12
 
13
13
  describe '.find_full' do
14
14
  it 'should return response class' do
15
- model.find_full('70327').class.should == ThetvdbApi::Response
15
+ model.find_full('70327').class.should == ThetvdbApi::Response::FullSeries
16
16
  end
17
17
  end
18
18
  end
@@ -6,25 +6,25 @@ describe ThetvdbApi::Update do
6
6
  describe 'real request' do
7
7
  describe '.day' do
8
8
  it 'should return response class' do
9
- model.day.class.should == ThetvdbApi::Response
9
+ model.day.class.should == ThetvdbApi::Response::Update
10
10
  end
11
11
  end
12
12
 
13
13
  describe '.week' do
14
14
  it 'should return response class' do
15
- model.week.class.should == ThetvdbApi::Response
15
+ model.week.class.should == ThetvdbApi::Response::Update
16
16
  end
17
17
  end
18
18
 
19
19
  describe '.month' do
20
20
  it 'should return response class' do
21
- model.month.class.should == ThetvdbApi::Response
21
+ model.month.class.should == ThetvdbApi::Response::Update
22
22
  end
23
23
  end
24
24
 
25
25
  describe '.all' do
26
26
  it 'should return response class' do
27
- model.all.class.should == ThetvdbApi::Response
27
+ model.all.class.should == ThetvdbApi::Response::Update
28
28
  end
29
29
  end
30
30
  end
data/spec/spec_helper.rb CHANGED
@@ -8,26 +8,5 @@ require File.join(File.dirname(__FILE__), 'support/thetvdb_api.rb')
8
8
 
9
9
  raise 'api_key missing, use ThetvdbApi::Configuration' if ThetvdbApi::Configuration.api_key.empty?
10
10
 
11
- class SampleModel
12
- def auth
13
- self
14
- end
15
-
16
- def get(uri)
17
- self
18
- end
19
-
20
- def mapper(mapper)
21
- self
22
- end
23
-
24
- def params(options = {})
25
- self
26
- end
27
-
28
- def response
29
- end
30
- end
31
-
32
11
  RSpec.configure do |config|
33
12
  end
@@ -0,0 +1,49 @@
1
+ require '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
@@ -0,0 +1,49 @@
1
+ require '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
@@ -0,0 +1,167 @@
1
+ require '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
@@ -0,0 +1,15 @@
1
+ require '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
@@ -0,0 +1,15 @@
1
+ require '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
@@ -0,0 +1,38 @@
1
+ require '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
@@ -0,0 +1,15 @@
1
+ require '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({ 'Episode' => 'EPISODE DATA' })
11
+
12
+ model.xml_parse.should == 'EPISODE DATA'
13
+ end
14
+ end
15
+ end