thetvdb_api 0.2.2 → 0.2.3

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +3 -1
  4. data/lib/thetvdb_api/base.rb +3 -1
  5. data/lib/thetvdb_api/configuration.rb +4 -2
  6. data/lib/thetvdb_api/response/episode.rb +1 -1
  7. data/lib/thetvdb_api/response/series.rb +1 -1
  8. data/lib/thetvdb_api/version.rb +1 -1
  9. data/spec/fixtures/actors.xml +17 -0
  10. data/spec/fixtures/banners.xml +54 -0
  11. data/spec/fixtures/episode.xml +34 -0
  12. data/spec/fixtures/full_series.xml +98 -0
  13. data/spec/fixtures/series.xml +30 -0
  14. data/spec/functionals/classes/actor_spec.rb +41 -0
  15. data/spec/functionals/classes/banner_spec.rb +42 -0
  16. data/spec/functionals/classes/episode_spec.rb +93 -0
  17. data/spec/functionals/classes/series_spec.rb +91 -0
  18. data/spec/functionals/functional_spec_helper.rb +7 -0
  19. data/spec/functionals/support/stub_faraday.rb +5 -0
  20. data/spec/integrations/{actor_spec.rb → classes/actor_spec.rb} +1 -1
  21. data/spec/integrations/{banner_spec.rb → classes/banner_spec.rb} +0 -0
  22. data/spec/integrations/{client_spec.rb → classes/client_spec.rb} +0 -0
  23. data/spec/integrations/{episode_spec.rb → classes/episode_spec.rb} +0 -0
  24. data/spec/integrations/{search_spec.rb → classes/search_spec.rb} +0 -0
  25. data/spec/integrations/{series_spec.rb → classes/series_spec.rb} +0 -0
  26. data/spec/integrations/{update_spec.rb → classes/update_spec.rb} +0 -0
  27. data/spec/integrations/integration_spec_helper.rb +2 -0
  28. data/spec/integrations/support/.keep +0 -0
  29. data/spec/spec_helper.rb +0 -3
  30. data/spec/units/{actor_spec.rb → classes/actor_spec.rb} +1 -1
  31. data/spec/units/{banner_spec.rb → classes/banner_spec.rb} +1 -1
  32. data/spec/units/{base_spec.rb → classes/base_spec.rb} +8 -1
  33. data/spec/units/{client_spec.rb → classes/client_spec.rb} +1 -1
  34. data/spec/units/{episode_spec.rb → classes/episode_spec.rb} +1 -1
  35. data/spec/units/{response → classes/response}/actors_spec.rb +1 -1
  36. data/spec/units/{response → classes/response}/banners_spec.rb +1 -1
  37. data/spec/units/{response → classes/response}/collection_spec.rb +1 -1
  38. data/spec/units/{response → classes/response}/episode_spec.rb +2 -2
  39. data/spec/units/{response → classes/response}/full_series_spec.rb +1 -1
  40. data/spec/units/{response → classes/response}/search_multiple_episode_spec.rb +1 -1
  41. data/spec/units/{response → classes/response}/search_multiple_series_spec.rb +1 -1
  42. data/spec/units/{response → classes/response}/search_series_spec.rb +1 -1
  43. data/spec/units/{response → classes/response}/series_spec.rb +2 -2
  44. data/spec/units/{response → classes/response}/update_spec.rb +1 -1
  45. data/spec/units/{response_spec.rb → classes/response_spec.rb} +1 -1
  46. data/spec/units/{search_spec.rb → classes/search_spec.rb} +1 -1
  47. data/spec/units/{series_spec.rb → classes/series_spec.rb} +1 -1
  48. data/spec/units/{update_spec.rb → classes/update_spec.rb} +1 -1
  49. data/spec/units/unit_spec_helper.rb +5 -0
  50. metadata +82 -56
  51. data/spec/support/thetvdb_api.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dcc91a8222745749a555d5d963c6eaad2d2acad
4
- data.tar.gz: 5eec6981bd50bac65fa2c0e2e6d051b4e0187249
3
+ metadata.gz: d8722250d12444c7d48c5f40c29399cd9648aee1
4
+ data.tar.gz: db741d65425c5fe1ab7e84ac5f359dabfaafbcfc
5
5
  SHA512:
6
- metadata.gz: a3916560f299474f0964c79bde37783883793db4c7f8476510ef31e1515f00d1fd232e67b33ef807c6c4d337b6634d6a869b708f45b5a3d63c0f4596c49b9e08
7
- data.tar.gz: 6594ba567f59510b6cb138fa7db45549c5261c5c892134aa10206730aa997c2e450faae0bddcdd0c85749d8a54176f11c14e2f41e05319ad7cbf7c5832bb62a9
6
+ metadata.gz: 5db2252964e7fcb09fc14da642eaf3963682a4895d4bcb0b56ff660b567a4dfa77da9ebf4571c8510e84a50d74af8b299042ce9214af93a5fb2d862324b5398e
7
+ data.tar.gz: 6a01328792eeecc43cf65eae647c282a5d223df91490172f5ef745d95f685feb02eecf30084e4de616423b491a1d88ead1c021d09e56e1be24e86abc80544eee
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+
19
+ spec/integrations/support/configuration.rb
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
- script: 'bundle exec rspec spec/units'
2
+ script: 'bundle exec rspec spec/units && bundle exec rspec spec/functionals && bundle exec rspec spec/units'
3
3
  rvm:
4
+ - 1.9.3
4
5
  - 2.0.0
6
+ - 2.1.0
@@ -9,7 +9,9 @@ class ThetvdbApi::Base
9
9
  end
10
10
 
11
11
  def connection
12
- @connection ||= Faraday.new(url: base_url)
12
+ @connection ||= Faraday.new(url: base_url) do |builder|
13
+ builder.adapter ThetvdbApi::Configuration.adapter
14
+ end
13
15
  end
14
16
 
15
17
  def get(uri)
@@ -3,6 +3,8 @@ require 'confiture'
3
3
  class ThetvdbApi::Configuration
4
4
  include Confiture::Configuration
5
5
 
6
- confiture_allowed_keys(:api_key, :language)
7
- confiture_defaults(language: 'en')
6
+ confiture_allowed_keys(:api_key, :language, :adapter)
7
+ confiture_defaults(language: 'en', adapter: :net_http)
8
8
  end
9
+
10
+ ThetvdbApi::Configuration.configure
@@ -1,5 +1,5 @@
1
1
  class ThetvdbApi::Response::Episode < ThetvdbApi::Response
2
2
  def xml_parse
3
- multi_xml_parse.fetch('Episode', {})
3
+ multi_xml_parse.fetch('Data', {}).fetch('Episode', {})
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class ThetvdbApi::Response::Series < ThetvdbApi::Response
2
2
  def xml_parse
3
- multi_xml_parse.fetch('Series', {})
3
+ multi_xml_parse.fetch('Data', {}).fetch('Series', {})
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module ThetvdbApi
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Actors>
3
+ <Actor>
4
+ <id>22017</id>
5
+ <Image>actors/22017.jpg</Image>
6
+ <Name>Zachary Levi</Name>
7
+ <Role>Charles &quot;Chuck&quot; Bartowski</Role>
8
+ <SortOrder>0</SortOrder>
9
+ </Actor>
10
+ <Actor>
11
+ <id>22019</id>
12
+ <Image>actors/22019.jpg</Image>
13
+ <Name>Yvonne Strahovski</Name>
14
+ <Role>Sarah Walker</Role>
15
+ <SortOrder>1</SortOrder>
16
+ </Actor>
17
+ </Actors>
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Banners>
3
+ <Banner>
4
+ <id>899538</id>
5
+ <BannerPath>fanart/original/80348-55.jpg</BannerPath>
6
+ <BannerType>fanart</BannerType>
7
+ <BannerType2>1280x720</BannerType2>
8
+ <Colors>|172,157,124|184,131,113|53,53,51|</Colors>
9
+ <Language>en</Language>
10
+ <Rating>8.5000</Rating>
11
+ <RatingCount>2</RatingCount>
12
+ <SeriesName>true</SeriesName>
13
+ <ThumbnailPath>_cache/fanart/original/80348-55.jpg</ThumbnailPath>
14
+ <VignettePath>fanart/vignette/80348-55.jpg</VignettePath>
15
+ </Banner>
16
+ <Banner>
17
+ <id>877696</id>
18
+ <BannerPath>posters/80348-16.jpg</BannerPath>
19
+ <BannerType>poster</BannerType>
20
+ <BannerType2>680x1000</BannerType2>
21
+ <Language>en</Language>
22
+ <Rating>8.5556</Rating>
23
+ <RatingCount>9</RatingCount>
24
+ </Banner>
25
+ <Banner>
26
+ <id>896898</id>
27
+ <BannerPath>seasons/80348-0-2.jpg</BannerPath>
28
+ <BannerType>season</BannerType>
29
+ <BannerType2>season</BannerType2>
30
+ <Language>en</Language>
31
+ <Rating>10.0000</Rating>
32
+ <RatingCount>1</RatingCount>
33
+ <Season>0</Season>
34
+ </Banner>
35
+ <Banner>
36
+ <id>642871</id>
37
+ <BannerPath>seasonswide/80348-4.jpg</BannerPath>
38
+ <BannerType>season</BannerType>
39
+ <BannerType2>seasonwide</BannerType2>
40
+ <Language>en</Language>
41
+ <Rating>10.0000</Rating>
42
+ <RatingCount>1</RatingCount>
43
+ <Season>4</Season>
44
+ </Banner>
45
+ <Banner>
46
+ <id>893988</id>
47
+ <BannerPath>graphical/80348-g29.jpg</BannerPath>
48
+ <BannerType>series</BannerType>
49
+ <BannerType2>graphical</BannerType2>
50
+ <Language>en</Language>
51
+ <Rating>7.6667</Rating>
52
+ <RatingCount>6</RatingCount>
53
+ </Banner>
54
+ </Banners>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Data>
3
+ <Episode>
4
+ <id>332179</id>
5
+ <seasonid>27985</seasonid>
6
+ <EpisodeNumber>1</EpisodeNumber>
7
+ <EpisodeName>Chuck Versus the Intersect</EpisodeName>
8
+ <FirstAired>2007-09-24</FirstAired>
9
+ <GuestStars>Mieko Hillman|Kristine Blackport|Jim Pirri|Diana Gitelman|Mel Fair|Lynn A. Henderson|Odessa Rae|Jordan Potter|Tasha Campbell|Dale Dye|Matthew Bomer|Bruno Amato|Nicolas Pajon|Wendy Makkena</GuestStars>
10
+ <Director>McG</Director>
11
+ <Writer>Josh Schwartz|Chris Fedak</Writer>
12
+ <Overview>Chuck Bartowski is an average computer geek until files of government secrets are downloaded into his brain. He is soon scouted by the CIA and NSA to act in place of their computer.</Overview>
13
+ <ProductionCode>276025</ProductionCode>
14
+ <lastupdated>1286047470</lastupdated>
15
+ <flagged>0</flagged>
16
+ <DVD_discid></DVD_discid>
17
+ <DVD_season>1</DVD_season>
18
+ <DVD_episodenumber>1.0</DVD_episodenumber>
19
+ <DVD_chapter></DVD_chapter>
20
+ <absolute_number>1</absolute_number>
21
+ <filename>episodes/80348/332179.jpg</filename>
22
+ <seriesid>80348</seriesid>
23
+ <thumb_added></thumb_added>
24
+ <thumb_width>400</thumb_width>
25
+ <thumb_height>225</thumb_height>
26
+ <tms_export>1</tms_export>
27
+ <mirrorupdate>2013-10-08 13:25:36</mirrorupdate>
28
+ <IMDB_ID>tt1035912</IMDB_ID>
29
+ <EpImgFlag></EpImgFlag>
30
+ <Rating>7.7</Rating>
31
+ <SeasonNumber>1</SeasonNumber>
32
+ <Language>en</Language>
33
+ </Episode>
34
+ </Data>
@@ -0,0 +1,98 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Data>
3
+ <Series>
4
+ <id>80348</id>
5
+ <Actors>|Zachary Levi|Yvonne Strahovski|Joshua Gomez|Adam Baldwin|Bonita Friedericy|Julia Ling|Vik Sahay|Ryan McPartlin|Scott Krinsky|Mark Christopher Lawrence|Sarah Lancaster|Mekenna Melvin|Linda Hamilton|Brandon Routh|Matthew Bomer|</Actors>
6
+ <Airs_DayOfWeek>Friday</Airs_DayOfWeek>
7
+ <Airs_Time>8:00 PM</Airs_Time>
8
+ <ContentRating>TV-PG</ContentRating>
9
+ <FirstAired>2007-09-24</FirstAired>
10
+ <Genre>|Action|Adventure|Comedy|Drama|</Genre>
11
+ <IMDB_ID>tt0934814</IMDB_ID>
12
+ <Language>en</Language>
13
+ <Network>NBC</Network>
14
+ <NetworkID></NetworkID>
15
+ <Overview>Chuck Bartowski, ace computer geek at Buy More, is not in his right mind. That's a good thing. Ever since he unwittingly downloaded stolen government secrets into his brain, action, excitement and a cool secret-agent girlfriend have entered his life. It's a bad thing, too. Because now Chuck is in danger 24/7.</Overview>
16
+ <Rating>8.7</Rating>
17
+ <RatingCount>855</RatingCount>
18
+ <Runtime>60</Runtime>
19
+ <SeriesID>68724</SeriesID>
20
+ <SeriesName>Chuck</SeriesName>
21
+ <Status>Ended</Status>
22
+ <added></added>
23
+ <addedBy></addedBy>
24
+ <banner>graphical/80348-g26.jpg</banner>
25
+ <fanart>fanart/original/80348-32.jpg</fanart>
26
+ <lastupdated>1388829637</lastupdated>
27
+ <poster>posters/80348-16.jpg</poster>
28
+ <zap2it_id>EP00930779</zap2it_id>
29
+ </Series>
30
+ <Episode>
31
+ <id>935481</id>
32
+ <Combined_episodenumber>1</Combined_episodenumber>
33
+ <Combined_season>0</Combined_season>
34
+ <DVD_chapter></DVD_chapter>
35
+ <DVD_discid></DVD_discid>
36
+ <DVD_episodenumber></DVD_episodenumber>
37
+ <DVD_season></DVD_season>
38
+ <Director>Robert Duncan McNeill</Director>
39
+ <EpImgFlag>2</EpImgFlag>
40
+ <EpisodeName>Chuck Versus the Third Dimension (2D)</EpisodeName>
41
+ <EpisodeNumber>1</EpisodeNumber>
42
+ <FirstAired>2009-02-03</FirstAired>
43
+ <GuestStars>|Dominic Monaghan|Jerome Bettis|</GuestStars>
44
+ <IMDB_ID></IMDB_ID>
45
+ <Language>en</Language>
46
+ <Overview>Chuck foils a plan to kill Tyler Martin, an international rock star. Chuck's night out with Tyler leads to trouble. Morgan holds a contest among his fellow employees. 2D version of the Episode originally aired in 3D</Overview>
47
+ <ProductionCode></ProductionCode>
48
+ <Rating>8.0</Rating>
49
+ <RatingCount>3</RatingCount>
50
+ <SeasonNumber>0</SeasonNumber>
51
+ <Writer>Chris Fedak|Josh Schwartz</Writer>
52
+ <absolute_number></absolute_number>
53
+ <airsafter_season></airsafter_season>
54
+ <airsbefore_episode>13</airsbefore_episode>
55
+ <airsbefore_season>2</airsbefore_season>
56
+ <filename>episodes/80348/935481.jpg</filename>
57
+ <lastupdated>1317585069</lastupdated>
58
+ <seasonid>27984</seasonid>
59
+ <seriesid>80348</seriesid>
60
+ <thumb_added></thumb_added>
61
+ <thumb_height>225</thumb_height>
62
+ <thumb_width>400</thumb_width>
63
+ </Episode>
64
+ <Episode>
65
+ <id>1534641</id>
66
+ <Combined_episodenumber>2</Combined_episodenumber>
67
+ <Combined_season>0</Combined_season>
68
+ <DVD_chapter></DVD_chapter>
69
+ <DVD_discid></DVD_discid>
70
+ <DVD_episodenumber></DVD_episodenumber>
71
+ <DVD_season></DVD_season>
72
+ <Director></Director>
73
+ <EpImgFlag>2</EpImgFlag>
74
+ <EpisodeName>Buy More #15: Employee Health</EpisodeName>
75
+ <EpisodeNumber>2</EpisodeNumber>
76
+ <FirstAired>2008-10-06</FirstAired>
77
+ <GuestStars></GuestStars>
78
+ <IMDB_ID></IMDB_ID>
79
+ <Language>en</Language>
80
+ <Overview>John Casey explains how to rid the Buy More of unwanted pests.</Overview>
81
+ <ProductionCode></ProductionCode>
82
+ <Rating>7.0</Rating>
83
+ <RatingCount>3</RatingCount>
84
+ <SeasonNumber>0</SeasonNumber>
85
+ <Writer></Writer>
86
+ <absolute_number></absolute_number>
87
+ <airsafter_season></airsafter_season>
88
+ <airsbefore_episode></airsbefore_episode>
89
+ <airsbefore_season></airsbefore_season>
90
+ <filename>episodes/80348/1534641.jpg</filename>
91
+ <lastupdated>1282959580</lastupdated>
92
+ <seasonid>27984</seasonid>
93
+ <seriesid>80348</seriesid>
94
+ <thumb_added></thumb_added>
95
+ <thumb_height>225</thumb_height>
96
+ <thumb_width>400</thumb_width>
97
+ </Episode>
98
+ </Data>
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Data>
3
+ <Series>
4
+ <id>80348</id>
5
+ <Actors>|Zachary Levi|Yvonne Strahovski|Joshua Gomez|Adam Baldwin|Bonita Friedericy|Julia Ling|Vik Sahay|Ryan McPartlin|Scott Krinsky|Mark Christopher Lawrence|Sarah Lancaster|Mekenna Melvin|Linda Hamilton|Brandon Routh|Matthew Bomer|</Actors>
6
+ <Airs_DayOfWeek>Friday</Airs_DayOfWeek>
7
+ <Airs_Time>8:00 PM</Airs_Time>
8
+ <ContentRating>TV-PG</ContentRating>
9
+ <FirstAired>2007-09-24</FirstAired>
10
+ <Genre>|Action|Adventure|Comedy|Drama|</Genre>
11
+ <IMDB_ID>tt0934814</IMDB_ID>
12
+ <Language>en</Language>
13
+ <Network>NBC</Network>
14
+ <NetworkID></NetworkID>
15
+ <Overview>Chuck Bartowski, ace computer geek at Buy More, is not in his right mind. That's a good thing. Ever since he unwittingly downloaded stolen government secrets into his brain, action, excitement and a cool secret-agent girlfriend have entered his life. It's a bad thing, too. Because now Chuck is in danger 24/7.</Overview>
16
+ <Rating>8.7</Rating>
17
+ <RatingCount>855</RatingCount>
18
+ <Runtime>60</Runtime>
19
+ <SeriesID>68724</SeriesID>
20
+ <SeriesName>Chuck</SeriesName>
21
+ <Status>Ended</Status>
22
+ <added></added>
23
+ <addedBy></addedBy>
24
+ <banner>graphical/80348-g26.jpg</banner>
25
+ <fanart>fanart/original/80348-32.jpg</fanart>
26
+ <lastupdated>1388829637</lastupdated>
27
+ <poster>posters/80348-16.jpg</poster>
28
+ <zap2it_id>EP00930779</zap2it_id>
29
+ </Series>
30
+ </Data>
@@ -0,0 +1,41 @@
1
+ require 'functionals/functional_spec_helper'
2
+
3
+ describe ThetvdbApi::Actor do
4
+ include StubFaraday
5
+
6
+ let(:model) { ThetvdbApi::Actor.new(ThetvdbApi::Client.new) }
7
+
8
+ let(:faraday_stubs) do
9
+ Faraday::Adapter::Test::Stubs.new do |stub|
10
+ stub.get('/api/123456789/series/1234/actors.xml') { [200, {}, File.read('spec/fixtures/actors.xml')] }
11
+ end
12
+ end
13
+
14
+ def actor_keys
15
+ ['id', 'Image', 'Name', 'Role', 'SortOrder'].sort
16
+ end
17
+
18
+ before do
19
+ stub_request(model, faraday_stubs)
20
+ end
21
+
22
+ describe '.find' do
23
+ it 'should return string without mapping' do
24
+ model.find(1234).body.class.should == String
25
+ end
26
+
27
+ describe 'with mapping' do
28
+ it 'should return Array' do
29
+ model.find(1234, mapping: true).body.class.should == Array
30
+ end
31
+
32
+ it 'should return not empty Array' do
33
+ model.find(1234, mapping: true).body.should_not be_empty
34
+ end
35
+
36
+ it 'should return specific keys for first element' do
37
+ model.find(1234, mapping: true).body.first.keys.sort.should == actor_keys
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,42 @@
1
+ require 'functionals/functional_spec_helper'
2
+
3
+ describe ThetvdbApi::Banner do
4
+ include StubFaraday
5
+
6
+ let(:model) { ThetvdbApi::Banner.new(ThetvdbApi::Client.new) }
7
+
8
+ let(:faraday_stubs) do
9
+ Faraday::Adapter::Test::Stubs.new do |stub|
10
+ stub.get('/api/123456789/series/1234/banners.xml') { [200, {}, File.read('spec/fixtures/banners.xml')] }
11
+ end
12
+ end
13
+
14
+ def banner_keys
15
+ ['id', 'BannerPath', 'BannerType', 'BannerType2', 'Colors', 'Language', 'Rating', 'RatingCount', 'SeriesName',
16
+ 'ThumbnailPath', 'VignettePath'].sort
17
+ end
18
+
19
+ before do
20
+ stub_request(model, faraday_stubs)
21
+ end
22
+
23
+ describe '.find' do
24
+ it 'should return string without mapping' do
25
+ model.find(1234).body.class.should == String
26
+ end
27
+
28
+ describe 'with mapping' do
29
+ it 'should return Array' do
30
+ model.find(1234, mapping: true).body.class.should == Array
31
+ end
32
+
33
+ it 'should return not empty Array' do
34
+ model.find(1234, mapping: true).body.should_not be_empty
35
+ end
36
+
37
+ it 'should return specific keys for first element' do
38
+ model.find(1234, mapping: true).body.first.keys.sort.should == banner_keys
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,93 @@
1
+ require 'functionals/functional_spec_helper'
2
+
3
+ describe ThetvdbApi::Episode do
4
+ include StubFaraday
5
+
6
+ let(:model) { ThetvdbApi::Episode.new(ThetvdbApi::Client.new) }
7
+
8
+ let(:episode_data) { File.read('spec/fixtures/episode.xml') }
9
+
10
+ let(:faraday_stubs) do
11
+ Faraday::Adapter::Test::Stubs.new do |stub|
12
+ stub.get('/api/123456789/series/1234/default/1/1/en.xml') { [200, {}, episode_data] }
13
+ stub.get('/api/123456789/series/1234/dvd/1/1/en.xml') { [200, {}, episode_data] }
14
+ stub.get('/api/123456789/series/1234/absolute/1/en.xml') { [200, {}, episode_data] }
15
+ stub.get('/api/123456789/episodes/1234/en.xml') { [200, {}, episode_data] }
16
+ end
17
+ end
18
+
19
+ def episode_keys
20
+ ['id', 'seasonid', 'EpisodeNumber', 'EpisodeName', 'FirstAired', 'GuestStars', 'Director', 'Writer', 'Overview',
21
+ 'ProductionCode', 'lastupdated', 'flagged', 'DVD_discid', 'DVD_season', 'DVD_episodenumber', 'DVD_chapter',
22
+ 'absolute_number', 'filename', 'seriesid', 'thumb_added', 'thumb_width', 'thumb_height', 'tms_export',
23
+ 'mirrorupdate', 'IMDB_ID', 'EpImgFlag', 'Rating', 'SeasonNumber', 'Language'].sort
24
+ end
25
+
26
+ before do
27
+ stub_request(model, faraday_stubs)
28
+ end
29
+
30
+ describe '.find_by_default_order' do
31
+ it 'should return string without mapping' do
32
+ model.find_by_default_order(1234, 1, 1).body.class.should == String
33
+ end
34
+
35
+ describe 'with mapping' do
36
+ it 'should return Hash' do
37
+ model.find_by_default_order(1234, 1, 1, mapping: true).body.class.should == Hash
38
+ end
39
+
40
+ it 'should return specific keys' do
41
+ model.find_by_default_order(1234, 1, 1, mapping: true).body.keys.sort.should == episode_keys
42
+ end
43
+ end
44
+ end
45
+
46
+ describe '.find_by_dvd_order' do
47
+ it 'should return string without mapping' do
48
+ model.find_by_dvd_order(1234, 1, 1).body.class.should == String
49
+ end
50
+
51
+ describe 'with mapping' do
52
+ it 'should return Hash' do
53
+ model.find_by_dvd_order(1234, 1, 1, mapping: true).body.class.should == Hash
54
+ end
55
+
56
+ it 'should return specific keys' do
57
+ model.find_by_dvd_order(1234, 1, 1, mapping: true).body.keys.sort.should == episode_keys
58
+ end
59
+ end
60
+ end
61
+
62
+ describe '.find_by_absolute_order' do
63
+ it 'should return string without mapping' do
64
+ model.find_by_absolute_order(1234, 1).body.class.should == String
65
+ end
66
+
67
+ describe 'with mapping' do
68
+ it 'should return Hash' do
69
+ model.find_by_absolute_order(1234, 1, mapping: true).body.class.should == Hash
70
+ end
71
+
72
+ it 'should return specific keys' do
73
+ model.find_by_absolute_order(1234, 1, mapping: true).body.keys.sort.should == episode_keys
74
+ end
75
+ end
76
+ end
77
+
78
+ describe '.find' do
79
+ it 'should return string without mapping' do
80
+ model.find(1234).body.class.should == String
81
+ end
82
+
83
+ describe 'with mapping' do
84
+ it 'should return Hash' do
85
+ model.find(1234, mapping: true).body.class.should == Hash
86
+ end
87
+
88
+ it 'should return specific keys' do
89
+ model.find(1234, mapping: true).body.keys.sort.should == episode_keys
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,91 @@
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
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,5 @@
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
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'integrations/integration_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Actor do
4
4
  let(:model) { ThetvdbApi::Actor.new(ThetvdbApi::Client.new) }
@@ -0,0 +1,2 @@
1
+ require 'spec_helper'
2
+ require 'integrations/support/configuration'
File without changes
data/spec/spec_helper.rb CHANGED
@@ -4,9 +4,6 @@ require 'coveralls'
4
4
  Coveralls.wear!
5
5
 
6
6
  require 'thetvdb_api'
7
- require File.join(File.dirname(__FILE__), 'support/thetvdb_api.rb')
8
-
9
- raise 'api_key missing, use ThetvdbApi::Configuration' if ThetvdbApi::Configuration.api_key.empty?
10
7
 
11
8
  RSpec.configure do |config|
12
9
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Actor do
4
4
  let(:klass) { ThetvdbApi::Actor }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Banner do
4
4
  let(:klass) { ThetvdbApi::Banner }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  class ExampleClass < ThetvdbApi::Base
4
4
  end
@@ -13,6 +13,13 @@ describe ThetvdbApi::Base do
13
13
 
14
14
  model.connection
15
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
16
23
  end
17
24
 
18
25
  describe '.get' do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Client do
4
4
  let(:klass) { ThetvdbApi::Client }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Episode do
4
4
  let(:klass) { ThetvdbApi::Episode }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::Actors do
4
4
  let(:klass) { ThetvdbApi::Response::Actors }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::Banners do
4
4
  let(:klass) { ThetvdbApi::Response::Banners }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  class ExampleResponseClass
4
4
  include ThetvdbApi::Response::Collection
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::Episode do
4
4
  let(:klass) { ThetvdbApi::Response::Episode }
@@ -7,7 +7,7 @@ describe ThetvdbApi::Response::Episode do
7
7
 
8
8
  describe '.xml_parse' do
9
9
  it 'should return correct data' do
10
- model.stub(:multi_xml_parse).and_return({ 'Episode' => 'EPISODE DATA' })
10
+ model.stub(:multi_xml_parse).and_return({ 'Data' => { 'Episode' => 'EPISODE DATA' } })
11
11
 
12
12
  model.xml_parse.should == 'EPISODE DATA'
13
13
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::FullSeries do
4
4
  let(:klass) { ThetvdbApi::Response::FullSeries }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::SearchMultipleEpisode do
4
4
  let(:klass) { ThetvdbApi::Response::SearchMultipleEpisode }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::SearchMultipleSeries do
4
4
  let(:klass) { ThetvdbApi::Response::SearchMultipleSeries }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::SearchSeries do
4
4
  let(:klass) { ThetvdbApi::Response::SearchSeries }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::Series do
4
4
  let(:klass) { ThetvdbApi::Response::Series }
@@ -7,7 +7,7 @@ describe ThetvdbApi::Response::Series do
7
7
 
8
8
  describe '.xml_parse' do
9
9
  it 'should return correct data' do
10
- model.stub(:multi_xml_parse).and_return({ 'Series' => 'SERIES DATA' })
10
+ model.stub(:multi_xml_parse).and_return({ 'Data' => { 'Series' => 'SERIES DATA' } })
11
11
 
12
12
  model.xml_parse.should == 'SERIES DATA'
13
13
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Response::Update do
4
4
  let(:klass) { ThetvdbApi::Response::Update }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Search do
4
4
  let(:klass) { ThetvdbApi::Response }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Search do
4
4
  let(:klass) { ThetvdbApi::Search }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Series do
4
4
  let(:klass) { ThetvdbApi::Series }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'units/unit_spec_helper'
2
2
 
3
3
  describe ThetvdbApi::Update do
4
4
  let(:klass) { ThetvdbApi::Update }
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ ThetvdbApi::Configuration.configure do |config|
4
+ config.adapter = :test
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thetvdb_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Wawer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-26 00:00:00.000000000 Z
11
+ date: 2014-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: confiture
@@ -159,34 +159,47 @@ files:
159
159
  - lib/thetvdb_api/series.rb
160
160
  - lib/thetvdb_api/update.rb
161
161
  - lib/thetvdb_api/version.rb
162
- - spec/integrations/actor_spec.rb
163
- - spec/integrations/banner_spec.rb
164
- - spec/integrations/client_spec.rb
165
- - spec/integrations/episode_spec.rb
166
- - spec/integrations/search_spec.rb
167
- - spec/integrations/series_spec.rb
168
- - spec/integrations/update_spec.rb
162
+ - spec/fixtures/actors.xml
163
+ - spec/fixtures/banners.xml
164
+ - spec/fixtures/episode.xml
165
+ - spec/fixtures/full_series.xml
166
+ - spec/fixtures/series.xml
167
+ - spec/functionals/classes/actor_spec.rb
168
+ - spec/functionals/classes/banner_spec.rb
169
+ - spec/functionals/classes/episode_spec.rb
170
+ - spec/functionals/classes/series_spec.rb
171
+ - spec/functionals/functional_spec_helper.rb
172
+ - spec/functionals/support/stub_faraday.rb
173
+ - spec/integrations/classes/actor_spec.rb
174
+ - spec/integrations/classes/banner_spec.rb
175
+ - spec/integrations/classes/client_spec.rb
176
+ - spec/integrations/classes/episode_spec.rb
177
+ - spec/integrations/classes/search_spec.rb
178
+ - spec/integrations/classes/series_spec.rb
179
+ - spec/integrations/classes/update_spec.rb
180
+ - spec/integrations/integration_spec_helper.rb
181
+ - spec/integrations/support/.keep
169
182
  - spec/spec_helper.rb
170
- - spec/support/thetvdb_api.rb
171
- - spec/units/actor_spec.rb
172
- - spec/units/banner_spec.rb
173
- - spec/units/base_spec.rb
174
- - spec/units/client_spec.rb
175
- - spec/units/episode_spec.rb
176
- - spec/units/response/actors_spec.rb
177
- - spec/units/response/banners_spec.rb
178
- - spec/units/response/collection_spec.rb
179
- - spec/units/response/episode_spec.rb
180
- - spec/units/response/full_series_spec.rb
181
- - spec/units/response/search_multiple_episode_spec.rb
182
- - spec/units/response/search_multiple_series_spec.rb
183
- - spec/units/response/search_series_spec.rb
184
- - spec/units/response/series_spec.rb
185
- - spec/units/response/update_spec.rb
186
- - spec/units/response_spec.rb
187
- - spec/units/search_spec.rb
188
- - spec/units/series_spec.rb
189
- - spec/units/update_spec.rb
183
+ - spec/units/classes/actor_spec.rb
184
+ - spec/units/classes/banner_spec.rb
185
+ - spec/units/classes/base_spec.rb
186
+ - spec/units/classes/client_spec.rb
187
+ - spec/units/classes/episode_spec.rb
188
+ - spec/units/classes/response/actors_spec.rb
189
+ - spec/units/classes/response/banners_spec.rb
190
+ - spec/units/classes/response/collection_spec.rb
191
+ - spec/units/classes/response/episode_spec.rb
192
+ - spec/units/classes/response/full_series_spec.rb
193
+ - spec/units/classes/response/search_multiple_episode_spec.rb
194
+ - spec/units/classes/response/search_multiple_series_spec.rb
195
+ - spec/units/classes/response/search_series_spec.rb
196
+ - spec/units/classes/response/series_spec.rb
197
+ - spec/units/classes/response/update_spec.rb
198
+ - spec/units/classes/response_spec.rb
199
+ - spec/units/classes/search_spec.rb
200
+ - spec/units/classes/series_spec.rb
201
+ - spec/units/classes/update_spec.rb
202
+ - spec/units/unit_spec_helper.rb
190
203
  - thetvdb_api.gemspec
191
204
  homepage: http://github.com/wafcio/thetvdb_api
192
205
  licenses:
@@ -213,31 +226,44 @@ signing_key:
213
226
  specification_version: 4
214
227
  summary: Ruby client for thetvdb.com API
215
228
  test_files:
216
- - spec/integrations/actor_spec.rb
217
- - spec/integrations/banner_spec.rb
218
- - spec/integrations/client_spec.rb
219
- - spec/integrations/episode_spec.rb
220
- - spec/integrations/search_spec.rb
221
- - spec/integrations/series_spec.rb
222
- - spec/integrations/update_spec.rb
229
+ - spec/fixtures/actors.xml
230
+ - spec/fixtures/banners.xml
231
+ - spec/fixtures/episode.xml
232
+ - spec/fixtures/full_series.xml
233
+ - spec/fixtures/series.xml
234
+ - spec/functionals/classes/actor_spec.rb
235
+ - spec/functionals/classes/banner_spec.rb
236
+ - spec/functionals/classes/episode_spec.rb
237
+ - spec/functionals/classes/series_spec.rb
238
+ - spec/functionals/functional_spec_helper.rb
239
+ - spec/functionals/support/stub_faraday.rb
240
+ - spec/integrations/classes/actor_spec.rb
241
+ - spec/integrations/classes/banner_spec.rb
242
+ - spec/integrations/classes/client_spec.rb
243
+ - spec/integrations/classes/episode_spec.rb
244
+ - spec/integrations/classes/search_spec.rb
245
+ - spec/integrations/classes/series_spec.rb
246
+ - spec/integrations/classes/update_spec.rb
247
+ - spec/integrations/integration_spec_helper.rb
248
+ - spec/integrations/support/.keep
223
249
  - spec/spec_helper.rb
224
- - spec/support/thetvdb_api.rb
225
- - spec/units/actor_spec.rb
226
- - spec/units/banner_spec.rb
227
- - spec/units/base_spec.rb
228
- - spec/units/client_spec.rb
229
- - spec/units/episode_spec.rb
230
- - spec/units/response/actors_spec.rb
231
- - spec/units/response/banners_spec.rb
232
- - spec/units/response/collection_spec.rb
233
- - spec/units/response/episode_spec.rb
234
- - spec/units/response/full_series_spec.rb
235
- - spec/units/response/search_multiple_episode_spec.rb
236
- - spec/units/response/search_multiple_series_spec.rb
237
- - spec/units/response/search_series_spec.rb
238
- - spec/units/response/series_spec.rb
239
- - spec/units/response/update_spec.rb
240
- - spec/units/response_spec.rb
241
- - spec/units/search_spec.rb
242
- - spec/units/series_spec.rb
243
- - spec/units/update_spec.rb
250
+ - spec/units/classes/actor_spec.rb
251
+ - spec/units/classes/banner_spec.rb
252
+ - spec/units/classes/base_spec.rb
253
+ - spec/units/classes/client_spec.rb
254
+ - spec/units/classes/episode_spec.rb
255
+ - spec/units/classes/response/actors_spec.rb
256
+ - spec/units/classes/response/banners_spec.rb
257
+ - spec/units/classes/response/collection_spec.rb
258
+ - spec/units/classes/response/episode_spec.rb
259
+ - spec/units/classes/response/full_series_spec.rb
260
+ - spec/units/classes/response/search_multiple_episode_spec.rb
261
+ - spec/units/classes/response/search_multiple_series_spec.rb
262
+ - spec/units/classes/response/search_series_spec.rb
263
+ - spec/units/classes/response/series_spec.rb
264
+ - spec/units/classes/response/update_spec.rb
265
+ - spec/units/classes/response_spec.rb
266
+ - spec/units/classes/search_spec.rb
267
+ - spec/units/classes/series_spec.rb
268
+ - spec/units/classes/update_spec.rb
269
+ - spec/units/unit_spec_helper.rb
@@ -1,3 +0,0 @@
1
- ThetvdbApi::Configuration.configure do |config|
2
- config.api_key = '62BFCD98715E0CFC' # Your API key here, get one at http://thetvdb.com/?tab=apiregister
3
- end