thetvdb_api 0.1.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28b113c3356a7bcc604a2a0127d293423eb5f593
4
- data.tar.gz: d2aeb649ef996866b9660c6950898a44f32537f2
3
+ metadata.gz: 35bc99ae409ce0fdba0ddbdd73f4ac36efbd54a2
4
+ data.tar.gz: 26f99748d70ae7a86306f5f795013fe14c90c11e
5
5
  SHA512:
6
- metadata.gz: 6068cbb96817dfe5c64ab60661f365ac4fdf40d57213fc7d4971ec8452b4b79199972ea516b3f0a5f620c546e8679ccae2aa6efe6dbf664fe769899a5292f402
7
- data.tar.gz: d35ed5beebcd67dce88b7a70433bf44920b36829c2ae324100a823e17f1ac5903d2360fb5f719695c5aebd07eae8e5034af47bdde3fc5b3e4e1d53b23ddebaa9
6
+ metadata.gz: 159ee305365dc047e9312107e81168ccb9001492cfa2097b6efb25d5b34a45359d8ea4a042197dbf54e887c75e3a731715b75e6a12df547011205e355cb223c1
7
+ data.tar.gz: 4a2d708ed8cc0e28f70938cf948dd1fa17481dfc7a82bf41fbd9d90f52f893e85ed49a3e87b146bcfe348c6b71b621c5219659aefea9bbb8f50298ba2d004806
data/README.md CHANGED
@@ -24,14 +24,14 @@ After you install ThetvdbApi and add it to your Gemfile, you need to run the gen
24
24
  rails generate thetvdb_api:install
25
25
  ```
26
26
 
27
- The generator will install an initializer where you must past your api_key, and can past: language (2 letters abbrevation), api_url (base url).
27
+ The generator will install an initializer where you must past your api_key, and can past: language (2 letters abbrevation).
28
28
 
29
29
  ## How to use
30
30
 
31
- There is one entry point, in initialize you can past hash with api_key, language and api_url values, or leave empty:
31
+ There is one entry point, in initialize you can past hash with api_key and language values, or leave empty:
32
32
 
33
33
  ```ruby
34
- client = ThetvdbApi::Client.new(api_url: '...', api_key: '...', language: 'en')
34
+ client = ThetvdbApi::Client.new(api_key: '...', language: 'en')
35
35
  ```
36
36
 
37
37
  Search series by name
@@ -1,5 +1,5 @@
1
1
  class ThetvdbApi::Actor < ThetvdbApi::Base
2
2
  def find(series_id)
3
- get("#{series_uri(series_id)}actors.xml").response
3
+ get("#{series_uri}/actors.xml").params(series_id: series_id).response
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class ThetvdbApi::Banner < ThetvdbApi::Base
2
2
  def find(series_id)
3
- get("#{series_uri(series_id)}banners.xml").response
3
+ get("#{series_uri}/banners.xml").params(series_id: series_id).response
4
4
  end
5
5
  end
@@ -1,35 +1,52 @@
1
1
  require 'httparty'
2
+ require 'uri_template'
2
3
 
3
4
  class ThetvdbApi::Base
4
5
  include HTTParty
5
6
  base_uri 'http://thetvdb.com/api/'
6
7
 
7
- attr_reader :client, :uri, :options
8
-
9
8
  def initialize(client)
10
9
  @client = client
10
+ @params = {}
11
+ end
12
+
13
+ def get(uri)
14
+ @uri_template = URITemplate.new(uri)
15
+
16
+ self
11
17
  end
12
18
 
13
- def get(uri, options = {})
14
- @uri = uri
15
- @options = options
19
+ def params(options)
20
+ @params = options
16
21
 
17
22
  self
18
23
  end
19
24
 
20
25
  def response
21
- self.class.get(uri, query: options)
26
+ @uri_template ? self.class.get(uri, body: @options) : nil
22
27
  end
23
28
 
24
- def series_uri(series_id)
25
- "#{api_key}/series/#{series_id}/"
29
+ def prepare_uri
30
+ @uri_template ? @uri_template.expand(@params.merge(api_key: @client.api_key)) : nil
26
31
  end
27
32
 
28
- def api_key
29
- client.api_key
33
+ def uri
34
+ uri = prepare_uri
35
+ @params.reject!{ |param| restful_param_keys(uri).include?(param.to_s) }
36
+
37
+ uri
38
+ end
39
+
40
+ def restful_param_keys(uri_expanded)
41
+ @uri_template.extract(uri_expanded).keys
42
+ end
43
+
44
+
45
+ def series_uri
46
+ '{api_key}/series/{series_id}'
30
47
  end
31
48
 
32
49
  def language
33
- client.language
50
+ @client.language
34
51
  end
35
52
  end
@@ -2,7 +2,6 @@ class ThetvdbApi::Client
2
2
  attr_reader :api_key, :language
3
3
 
4
4
  def initialize(options = {})
5
-
6
5
  @api_key = options[:api_key] ? options[:api_key] : ThetvdbApi::Configuration.api_key
7
6
  @language = options[:language] ? options[:language] : ThetvdbApi::Configuration.language
8
7
  end
@@ -1,21 +1,23 @@
1
1
  class ThetvdbApi::Episode < ThetvdbApi::Base
2
2
  def find_by_default_order(series_id, season, episode, language = self.language)
3
- get("#{series_uri(series_id)}default#{shared_uri_suffix(season, episode, language)}").response
3
+ find_by_order('default', series_id, season, episode, language)
4
4
  end
5
5
 
6
6
  def find_by_dvd_order(series_id, season, episode, language = self.language)
7
- get("#{series_uri(series_id)}dvd#{shared_uri_suffix(season, episode, language)}").response
7
+ find_by_order('dvd', series_id, season, episode, language)
8
8
  end
9
9
 
10
10
  def find_by_absolute_order(series_id, absolute, language = self.language)
11
- get("#{series_uri(series_id)}absolute/#{absolute}/#{language}.xml").response
11
+ get("#{series_uri}/absolute/{absolute}/{language}.xml").
12
+ params(series_id: series_id, absolute: absolute, language: language).response
12
13
  end
13
14
 
14
15
  def find(episode_id, language = self.language)
15
- get("#{api_key}/episodes/#{episode_id}/#{language}.xml").response
16
+ get("{api_key}/episodes/{episode_id}/{language}.xml").params(episode_id: episode_id, language: language).response
16
17
  end
17
18
 
18
- def shared_uri_suffix(season, episode, language)
19
- "/#{season}/#{episode}/#{language}.xml"
19
+ def find_by_order(order, series_id, season, episode, language)
20
+ get("#{series_uri}/{order}/{season}/{episode}/{language}.xml").
21
+ params(series_id: series_id, season: season, episode: episode, language: language, order: order).response
20
22
  end
21
23
  end
@@ -1,18 +1,17 @@
1
1
  class ThetvdbApi::Search < ThetvdbApi::Base
2
2
  def get_series(name, language = self.language)
3
- get('GetSeries.php', seriesname: name, language: language).response
3
+ get('GetSeries.php').params(seriesname: name, language: language).response
4
4
  end
5
5
 
6
6
  def get_series_by_imdb_id(id, language = self.language)
7
- get('GetSeriesByRemoteID.php', imdbid: id, language: language).response
7
+ get('GetSeriesByRemoteID.php').params(imdbid: id, language: language).response
8
8
  end
9
9
 
10
10
  def get_series_by_zap2it_id(id, language = self.language)
11
- get('GetSeriesByRemoteID.php', zap2it: id, language: language).response
11
+ get('GetSeriesByRemoteID.php').params(zap2it: id, language: language).response
12
12
  end
13
13
 
14
14
  def get_episode_by_air_date(series_id, air_date, language = self.language)
15
- get('GetEpisodeByAirDate.php', apikey: self.api_key, seriesid: series_id, airdate: air_date, language: language).
16
- response
15
+ get('GetEpisodeByAirDate.php').params(seriesid: series_id, airdate: air_date, language: language).response
17
16
  end
18
17
  end
@@ -1,9 +1,9 @@
1
1
  class ThetvdbApi::Series < ThetvdbApi::Base
2
2
  def find(series_id, language = self.language)
3
- get("#{series_uri(series_id)}#{language}.xml").response
3
+ get("#{series_uri}/{language}.xml").params(series_id: series_id, language: language).response
4
4
  end
5
5
 
6
6
  def find_full(series_id, language = self.language)
7
- get("#{series_uri(series_id)}all/#{language}.xml").response
7
+ get("#{series_uri}/all/{language}.xml").params(series_id: series_id, language: language).response
8
8
  end
9
9
  end
@@ -1,17 +1,17 @@
1
1
  class ThetvdbApi::Update < ThetvdbApi::Base
2
2
  def day
3
- get("#{api_key}/updates/updates_day.xml").response
3
+ get('{api_key}/updates/updates_day.xml').response
4
4
  end
5
5
 
6
6
  def week
7
- get("#{api_key}/updates/updates_week.xml").response
7
+ get('{api_key}/updates/updates_week.xml').response
8
8
  end
9
9
 
10
10
  def month
11
- get("#{api_key}/updates/updates_month.xml").response
11
+ get('{api_key}/updates/updates_month.xml').response
12
12
  end
13
13
 
14
14
  def all
15
- get("#{api_key}/updates/updates_all.xml").response
15
+ get('{api_key}/updates/updates_all.xml').response
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module ThetvdbApi
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -8,5 +8,22 @@ 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 params(options = {})
21
+ self
22
+ end
23
+
24
+ def response
25
+ end
26
+ end
27
+
11
28
  RSpec.configure do |config|
12
29
  end
@@ -3,10 +3,17 @@ require 'spec_helper'
3
3
  describe ThetvdbApi::Actor do
4
4
  let(:klass) { ThetvdbApi::Actor }
5
5
  let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
+ let(:mock_model) { SampleModel.new }
6
7
 
7
8
  describe '.find' do
8
- it 'should call new with specific params' do
9
- model.should_receive(:get).with('123456789/series/1234/actors.xml').and_return(double(response: true))
9
+ it 'should call get with specific params' do
10
+ model.should_receive(:get).with('{api_key}/series/{series_id}/actors.xml').and_return(mock_model)
11
+
12
+ model.find('1234')
13
+ end
14
+
15
+ it 'should call params with specific params' do
16
+ model.should_receive(:params).with(series_id: '1234').and_return(mock_model)
10
17
 
11
18
  model.find('1234')
12
19
  end
@@ -3,10 +3,17 @@ require 'spec_helper'
3
3
  describe ThetvdbApi::Banner do
4
4
  let(:klass) { ThetvdbApi::Banner }
5
5
  let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
+ let(:mock_model) { SampleModel.new }
6
7
 
7
8
  describe '.find' do
8
- it 'should call new with specific params' do
9
- model.should_receive(:get).with('123456789/series/1234/banners.xml').and_return(double(response: true))
9
+ it 'should call get with specific params' do
10
+ model.should_receive(:get).with('{api_key}/series/{series_id}/banners.xml').and_return(mock_model)
11
+
12
+ model.find('1234')
13
+ end
14
+
15
+ it 'should call params with specific params' do
16
+ model.should_receive(:params).with(series_id: '1234').and_return(mock_model)
10
17
 
11
18
  model.find('1234')
12
19
  end
@@ -8,44 +8,67 @@ describe ThetvdbApi::Base do
8
8
  let(:model) { klass.new(ThetvdbApi::Client.new) }
9
9
 
10
10
  describe '.get' do
11
- it 'should set uri' do
11
+ it 'should set @uri_template' do
12
12
  model.get('http://example.com')
13
13
 
14
- model.uri.should == 'http://example.com'
14
+ model.instance_variable_get('@uri_template').class.should == URITemplate::RFC6570
15
15
  end
16
16
 
17
- it 'should set options' do
18
- model.get('http://example.com', sample_options: true)
17
+ it 'should return self' do
18
+ model.get('http://example.com').should == model
19
+ end
20
+ end
21
+
22
+ describe '.params' do
23
+ it 'should set @params' do
24
+ model.params(sample: 'test')
19
25
 
20
- model.options.should == { sample_options: true }
26
+ model.instance_variable_get('@params').should == { sample: 'test' }
21
27
  end
22
28
 
23
29
  it 'should return self' do
24
- model.get('http://example.com').should == model
30
+ model.params(sample: 'test').should == model
25
31
  end
26
32
  end
27
33
 
28
34
  describe '.response' do
29
35
  it 'should call get klass method' do
36
+ model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
30
37
  klass.should_receive(:get)
31
38
 
32
39
  model.response
33
40
  end
34
41
  end
35
42
 
36
- describe '.series_uri' do
37
- it 'should use default api_key' do
38
- klass.new(ThetvdbApi::Client.new(api_key: 'API_KEY')).series_uri('1234').should == 'API_KEY/series/1234/'
43
+ describe '.prepare_uri' do
44
+ it 'should receive correct uri string' do
45
+ model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
46
+
47
+ model.prepare_uri.should == "#{ThetvdbApi::Configuration.api_key}/series/"
39
48
  end
40
49
  end
41
50
 
42
- describe '.api_key' do
43
- it 'should use default api_key' do
44
- klass.new(ThetvdbApi::Client.new).api_key.should == ThetvdbApi::Configuration.api_key
51
+ describe '.uri' do
52
+ it 'should receive correct uri string' do
53
+ model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
54
+ model.instance_variable_set('@params', id: '1234')
55
+
56
+ model.uri.should == "#{ThetvdbApi::Configuration.api_key}/series/1234"
45
57
  end
58
+ end
46
59
 
47
- it 'should set api_key' do
48
- klass.new(ThetvdbApi::Client.new(api_key: 'API_KEY')).api_key.should == 'API_KEY'
60
+ describe '.restful_param_keys' do
61
+ it 'should receive correct uri string' do
62
+ uri_template = URITemplate.new('{api_key}/series/{id}')
63
+ model.instance_variable_set('@uri_template', uri_template)
64
+
65
+ model.restful_param_keys(uri_template.expand).sort.should == ['api_key', 'id'].sort
66
+ end
67
+ end
68
+
69
+ describe '.series_uri' do
70
+ it 'should use default api_key' do
71
+ klass.new(ThetvdbApi::Client.new(api_key: 'API_KEY')).series_uri.should == '{api_key}/series/{series_id}'
49
72
  end
50
73
  end
51
74
 
@@ -3,42 +3,61 @@ require 'spec_helper'
3
3
  describe ThetvdbApi::Episode do
4
4
  let(:klass) { ThetvdbApi::Episode }
5
5
  let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
+ let(:mock_model) { SampleModel.new }
6
7
 
7
8
  describe '.find_by_default_order' do
8
- it 'should call new with specific params' do
9
- model.should_receive(:get).with('123456789/series/1234/default/1/1/en.xml').and_return(double(response: true))
9
+ it 'should call get with specific params' do
10
+ model.should_receive(:get).with('{api_key}/series/{series_id}/{order}/{season}/{episode}/{language}.xml').and_return(mock_model)
11
+
12
+ model.find_by_default_order('1234', '1', '1')
13
+ end
14
+
15
+ it 'should call params with specific params' do
16
+ model.should_receive(:params).with(series_id: '1234', season: '1', episode: '1', language: 'en', order: 'default').and_return(mock_model)
10
17
 
11
18
  model.find_by_default_order('1234', '1', '1')
12
19
  end
13
20
  end
14
21
 
15
22
  describe '.find_by_dvd_order' do
16
- it 'should call new with specific params' do
17
- model.should_receive(:get).with('123456789/series/1234/dvd/1/1/en.xml').and_return(double(response: true))
23
+ it 'should call get with specific params' do
24
+ model.should_receive(:get).with('{api_key}/series/{series_id}/{order}/{season}/{episode}/{language}.xml').and_return(mock_model)
25
+
26
+ model.find_by_dvd_order('1234', '1', '1')
27
+ end
28
+
29
+ it 'should call params with specific params' do
30
+ model.should_receive(:params).with(series_id: '1234', season: '1', episode: '1', language: 'en', order: 'dvd').and_return(mock_model)
18
31
 
19
32
  model.find_by_dvd_order('1234', '1', '1')
20
33
  end
21
34
  end
22
35
 
23
36
  describe '.find_by_absolute_order' do
24
- it 'should call new with specific params' do
25
- model.should_receive(:get).with('123456789/series/1234/absolute/1/en.xml').and_return(double(response: true))
37
+ it 'should call get with specific params' do
38
+ model.should_receive(:get).with('{api_key}/series/{series_id}/absolute/{absolute}/{language}.xml').and_return(mock_model)
39
+
40
+ model.find_by_absolute_order('1234', '1')
41
+ end
42
+
43
+ it 'should call params with specific params' do
44
+ model.should_receive(:params).with(series_id: '1234', absolute: '1', language: 'en').and_return(mock_model)
26
45
 
27
46
  model.find_by_absolute_order('1234', '1')
28
47
  end
29
48
  end
30
49
 
31
50
  describe '.find' do
32
- it 'should call new with specific params' do
33
- model.should_receive(:get).with('123456789/episodes/1234/en.xml').and_return(double(response: true))
51
+ it 'should call get with specific params' do
52
+ model.should_receive(:get).with('{api_key}/episodes/{episode_id}/{language}.xml').and_return(mock_model)
34
53
 
35
54
  model.find('1234')
36
55
  end
37
- end
38
56
 
39
- describe '.shared_uri_suffix' do
40
- it 'should return correct staring' do
41
- model.shared_uri_suffix(1, 2, 'en').should == '/1/2/en.xml'
57
+ it 'should call params with specific params' do
58
+ model.should_receive(:params).with(episode_id: '1234', language: 'en').and_return(mock_model)
59
+
60
+ model.find('1234')
42
61
  end
43
62
  end
44
63
  end
@@ -3,11 +3,17 @@ require 'spec_helper'
3
3
  describe ThetvdbApi::Search do
4
4
  let(:klass) { ThetvdbApi::Search }
5
5
  let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
+ let(:mock_model) { SampleModel.new }
6
7
 
7
8
  describe '.get_series' do
8
9
  it 'should call get with specific params' do
9
- model.should_receive(:get).with('GetSeries.php', seriesname: 'buffy', language: 'en').
10
- and_return(double(response: true))
10
+ model.should_receive(:get).with('GetSeries.php').and_return(mock_model)
11
+
12
+ model.get_series('buffy', 'en')
13
+ end
14
+
15
+ it 'should call params with specific params' do
16
+ model.should_receive(:params).with(seriesname: 'buffy', language: 'en').and_return(mock_model)
11
17
 
12
18
  model.get_series('buffy', 'en')
13
19
  end
@@ -15,8 +21,13 @@ describe ThetvdbApi::Search do
15
21
 
16
22
  describe '.get_series_by_imdb_id' do
17
23
  it 'should call get with specific params' do
18
- model.should_receive(:get).with('GetSeriesByRemoteID.php', imdbid: '1234', language: 'en').
19
- and_return(double(response: true))
24
+ model.should_receive(:get).with('GetSeriesByRemoteID.php').and_return(mock_model)
25
+
26
+ model.get_series_by_imdb_id('1234', 'en')
27
+ end
28
+
29
+ it 'should call params with specific params' do
30
+ model.should_receive(:params).with(imdbid: '1234', language: 'en').and_return(mock_model)
20
31
 
21
32
  model.get_series_by_imdb_id('1234', 'en')
22
33
  end
@@ -24,8 +35,13 @@ describe ThetvdbApi::Search do
24
35
 
25
36
  describe '.get_series_by_zap2it_id' do
26
37
  it 'should call get with specific params' do
27
- model.should_receive(:get).with('GetSeriesByRemoteID.php', zap2it: '1234', language: 'en').
28
- and_return(double(response: true))
38
+ model.should_receive(:get).with('GetSeriesByRemoteID.php').and_return(mock_model)
39
+
40
+ model.get_series_by_zap2it_id('1234', 'en')
41
+ end
42
+
43
+ it 'should call params with specific params' do
44
+ model.should_receive(:params).with(zap2it: '1234', language: 'en').and_return(mock_model)
29
45
 
30
46
  model.get_series_by_zap2it_id('1234', 'en')
31
47
  end
@@ -33,8 +49,13 @@ describe ThetvdbApi::Search do
33
49
 
34
50
  describe '#get_episode_by_air_date' do
35
51
  it 'should call get with specific params' do
36
- model.should_receive(:get).with('GetEpisodeByAirDate.php', apikey: '123456789', seriesid: '1234',
37
- airdate: '2000-01-01', language: 'en').and_return(double(response: true))
52
+ model.should_receive(:get).with('GetEpisodeByAirDate.php').and_return(mock_model)
53
+
54
+ model.get_episode_by_air_date('1234', '2000-01-01', 'en')
55
+ end
56
+
57
+ it 'should call params with specific params' do
58
+ model.should_receive(:params).with(seriesid: '1234', airdate: '2000-01-01', language: 'en').and_return(mock_model)
38
59
 
39
60
  model.get_episode_by_air_date('1234', '2000-01-01', 'en')
40
61
  end
@@ -3,10 +3,17 @@ require 'spec_helper'
3
3
  describe ThetvdbApi::Series do
4
4
  let(:klass) { ThetvdbApi::Series }
5
5
  let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
+ let(:mock_model) { SampleModel.new }
6
7
 
7
8
  describe '.find' do
8
9
  it 'should call get with specific params' do
9
- model.should_receive(:get).with('123456789/series/1234/en.xml').and_return(double(response: true))
10
+ model.should_receive(:get).with('{api_key}/series/{series_id}/{language}.xml').and_return(mock_model)
11
+
12
+ model.find('1234', 'en')
13
+ end
14
+
15
+ it 'should call params with specific params' do
16
+ model.should_receive(:params).with(series_id: '1234', language: 'en').and_return(mock_model)
10
17
 
11
18
  model.find('1234', 'en')
12
19
  end
@@ -14,7 +21,13 @@ describe ThetvdbApi::Series do
14
21
 
15
22
  describe '.find_full' do
16
23
  it 'should call get with specific params' do
17
- model.should_receive(:get).with('123456789/series/1234/all/en.xml').and_return(double(response: true))
24
+ model.should_receive(:get).with('{api_key}/series/{series_id}/all/{language}.xml').and_return(mock_model)
25
+
26
+ model.find_full('1234', 'en')
27
+ end
28
+
29
+ it 'should call params with specific params' do
30
+ model.should_receive(:params).with(series_id: '1234', language: 'en').and_return(mock_model)
18
31
 
19
32
  model.find_full('1234', 'en')
20
33
  end
@@ -3,10 +3,11 @@ require 'spec_helper'
3
3
  describe ThetvdbApi::Update do
4
4
  let(:klass) { ThetvdbApi::Update }
5
5
  let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
6
+ let(:mock_model) { SampleModel.new }
6
7
 
7
8
  describe '.day' do
8
9
  it 'should call get with specific params' do
9
- model.should_receive(:get).with('123456789/updates/updates_day.xml').and_return(double(response: true))
10
+ model.should_receive(:get).with('{api_key}/updates/updates_day.xml').and_return(mock_model)
10
11
 
11
12
  model.day
12
13
  end
@@ -14,7 +15,7 @@ describe ThetvdbApi::Update do
14
15
 
15
16
  describe '.week' do
16
17
  it 'should call get with specific params' do
17
- model.should_receive(:get).with('123456789/updates/updates_week.xml').and_return(double(response: true))
18
+ model.should_receive(:get).with('{api_key}/updates/updates_week.xml').and_return(mock_model)
18
19
 
19
20
  model.week
20
21
  end
@@ -22,7 +23,7 @@ describe ThetvdbApi::Update do
22
23
 
23
24
  describe '.month' do
24
25
  it 'should call get with specific params' do
25
- model.should_receive(:get).with('123456789/updates/updates_month.xml').and_return(double(response: true))
26
+ model.should_receive(:get).with('{api_key}/updates/updates_month.xml').and_return(mock_model)
26
27
 
27
28
  model.month
28
29
  end
@@ -30,7 +31,7 @@ describe ThetvdbApi::Update do
30
31
 
31
32
  describe '.all' do
32
33
  it 'should call get with specific params' do
33
- model.should_receive(:get).with('123456789/updates/updates_all.xml').and_return(double(response: true))
34
+ model.should_receive(:get).with('{api_key}/updates/updates_all.xml').and_return(mock_model)
34
35
 
35
36
  model.all
36
37
  end
data/thetvdb_api.gemspec CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'confiture', '~> 0.1.4'
22
- spec.add_dependency 'httparty', '~> 0.12.0'
22
+ spec.add_runtime_dependency 'httparty', '~> 0.12.0'
23
+ spec.add_runtime_dependency 'uri_template', '~> 0.6.0'
23
24
 
24
25
  spec.add_development_dependency 'bundler', '~> 1.3'
25
26
  spec.add_development_dependency 'rake'
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.1.1
4
+ version: 0.1.2
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-14 00:00:00.000000000 Z
11
+ date: 2013-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: confiture
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.12.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: uri_template
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement