tvrage_api 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -13
- data/lib/tvrage_api/base.rb +25 -6
- data/lib/tvrage_api/client.rb +13 -0
- data/lib/tvrage_api/search.rb +9 -0
- data/lib/tvrage_api/show.rb +14 -19
- data/lib/tvrage_api/update.rb +5 -0
- data/lib/tvrage_api/version.rb +1 -1
- data/lib/tvrage_api.rb +3 -7
- data/spec/integrations/client_spec.rb +55 -0
- data/spec/integrations/search_spec.rb +7 -7
- data/spec/integrations/show_spec.rb +12 -12
- data/spec/integrations/update_spec.rb +5 -6
- data/spec/tvrage_api/base_spec.rb +56 -0
- data/spec/tvrage_api/client_spec.rb +23 -0
- data/spec/tvrage_api/search_spec.rb +22 -0
- data/spec/tvrage_api/show_spec.rb +18 -59
- data/spec/tvrage_api/update_spec.rb +14 -0
- data/tvrage_api.gemspec +1 -2
- metadata +15 -53
- data/lib/tvrage_api/element.rb +0 -3
- data/lib/tvrage_api/episode.rb +0 -9
- data/lib/tvrage_api/request/base.rb +0 -57
- data/lib/tvrage_api/request/search.rb +0 -13
- data/lib/tvrage_api/request/show.rb +0 -37
- data/lib/tvrage_api/request/update.rb +0 -13
- data/lib/tvrage_api/utility/aka_array.rb +0 -9
- data/lib/tvrage_api/utility/date.rb +0 -9
- data/lib/tvrage_api/utility/date_or_integer.rb +0 -11
- data/lib/tvrage_api/utility/episode_array.rb +0 -15
- data/lib/tvrage_api/utility/genre_array.rb +0 -9
- data/lib/tvrage_api/utility/hashie/extensions/key_replace.rb +0 -42
- data/lib/tvrage_api/utility/integer.rb +0 -5
- data/lib/tvrage_api/utility/string.rb +0 -11
- data/lib/tvrage_api/utility.rb +0 -8
- data/spec/tvrage_api/episode_spec.rb +0 -51
- data/spec/tvrage_api/request/base_spec.rb +0 -113
- data/spec/tvrage_api/request/search_spec.rb +0 -30
- data/spec/tvrage_api/request/show_spec.rb +0 -71
- data/spec/tvrage_api/request/update_spec.rb +0 -28
- data/spec/tvrage_api/utility/aka_array_spec.rb +0 -17
- data/spec/tvrage_api/utility/date_or_integer_spec.rb +0 -13
- data/spec/tvrage_api/utility/date_spec.rb +0 -13
- data/spec/tvrage_api/utility/genre_array_spec.rb +0 -17
- data/spec/tvrage_api/utility/integer_spec.rb +0 -9
- data/spec/tvrage_api/utility/string_spec.rb +0 -9
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tvrage_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.12.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: hashie
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0.5
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 2.0.5
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,39 +95,21 @@ files:
|
|
109
95
|
- Rakefile
|
110
96
|
- lib/tvrage_api.rb
|
111
97
|
- lib/tvrage_api/base.rb
|
112
|
-
- lib/tvrage_api/
|
113
|
-
- lib/tvrage_api/
|
114
|
-
- lib/tvrage_api/request/base.rb
|
115
|
-
- lib/tvrage_api/request/search.rb
|
116
|
-
- lib/tvrage_api/request/show.rb
|
117
|
-
- lib/tvrage_api/request/update.rb
|
98
|
+
- lib/tvrage_api/client.rb
|
99
|
+
- lib/tvrage_api/search.rb
|
118
100
|
- lib/tvrage_api/show.rb
|
119
|
-
- lib/tvrage_api/
|
120
|
-
- lib/tvrage_api/utility/aka_array.rb
|
121
|
-
- lib/tvrage_api/utility/date.rb
|
122
|
-
- lib/tvrage_api/utility/date_or_integer.rb
|
123
|
-
- lib/tvrage_api/utility/episode_array.rb
|
124
|
-
- lib/tvrage_api/utility/genre_array.rb
|
125
|
-
- lib/tvrage_api/utility/hashie/extensions/key_replace.rb
|
126
|
-
- lib/tvrage_api/utility/integer.rb
|
127
|
-
- lib/tvrage_api/utility/string.rb
|
101
|
+
- lib/tvrage_api/update.rb
|
128
102
|
- lib/tvrage_api/version.rb
|
103
|
+
- spec/integrations/client_spec.rb
|
129
104
|
- spec/integrations/search_spec.rb
|
130
105
|
- spec/integrations/show_spec.rb
|
131
106
|
- spec/integrations/update_spec.rb
|
132
107
|
- spec/spec_helper.rb
|
133
|
-
- spec/tvrage_api/
|
134
|
-
- spec/tvrage_api/
|
135
|
-
- spec/tvrage_api/
|
136
|
-
- spec/tvrage_api/request/show_spec.rb
|
137
|
-
- spec/tvrage_api/request/update_spec.rb
|
108
|
+
- spec/tvrage_api/base_spec.rb
|
109
|
+
- spec/tvrage_api/client_spec.rb
|
110
|
+
- spec/tvrage_api/search_spec.rb
|
138
111
|
- spec/tvrage_api/show_spec.rb
|
139
|
-
- spec/tvrage_api/
|
140
|
-
- spec/tvrage_api/utility/date_or_integer_spec.rb
|
141
|
-
- spec/tvrage_api/utility/date_spec.rb
|
142
|
-
- spec/tvrage_api/utility/genre_array_spec.rb
|
143
|
-
- spec/tvrage_api/utility/integer_spec.rb
|
144
|
-
- spec/tvrage_api/utility/string_spec.rb
|
112
|
+
- spec/tvrage_api/update_spec.rb
|
145
113
|
- tvrage_api.gemspec
|
146
114
|
homepage: http://github.com/wafcio/tvrage_api
|
147
115
|
licenses:
|
@@ -168,19 +136,13 @@ signing_key:
|
|
168
136
|
specification_version: 4
|
169
137
|
summary: Ruby client for tvrage.com API
|
170
138
|
test_files:
|
139
|
+
- spec/integrations/client_spec.rb
|
171
140
|
- spec/integrations/search_spec.rb
|
172
141
|
- spec/integrations/show_spec.rb
|
173
142
|
- spec/integrations/update_spec.rb
|
174
143
|
- spec/spec_helper.rb
|
175
|
-
- spec/tvrage_api/
|
176
|
-
- spec/tvrage_api/
|
177
|
-
- spec/tvrage_api/
|
178
|
-
- spec/tvrage_api/request/show_spec.rb
|
179
|
-
- spec/tvrage_api/request/update_spec.rb
|
144
|
+
- spec/tvrage_api/base_spec.rb
|
145
|
+
- spec/tvrage_api/client_spec.rb
|
146
|
+
- spec/tvrage_api/search_spec.rb
|
180
147
|
- spec/tvrage_api/show_spec.rb
|
181
|
-
- spec/tvrage_api/
|
182
|
-
- spec/tvrage_api/utility/date_or_integer_spec.rb
|
183
|
-
- spec/tvrage_api/utility/date_spec.rb
|
184
|
-
- spec/tvrage_api/utility/genre_array_spec.rb
|
185
|
-
- spec/tvrage_api/utility/integer_spec.rb
|
186
|
-
- spec/tvrage_api/utility/string_spec.rb
|
148
|
+
- spec/tvrage_api/update_spec.rb
|
data/lib/tvrage_api/element.rb
DELETED
data/lib/tvrage_api/episode.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
class TvrageApi::Episode < TvrageApi::Base
|
2
|
-
replace_key :epnum, :episode_number
|
3
|
-
replace_key :seasonnum, :season_number
|
4
|
-
replace_key :prodnum, :production_number
|
5
|
-
|
6
|
-
coerce_key :airdate, Date
|
7
|
-
coerce_key :episode_number, Integer
|
8
|
-
coerce_key :season_number, Integer
|
9
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
|
3
|
-
class TvrageApi::Request::Base
|
4
|
-
include HTTParty
|
5
|
-
|
6
|
-
attr_reader :uri
|
7
|
-
|
8
|
-
def initialize(uri, options = {})
|
9
|
-
@uri = uri
|
10
|
-
@options = options
|
11
|
-
end
|
12
|
-
|
13
|
-
def response
|
14
|
-
@response ||= self.class.get(uri, request_options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def request_options
|
18
|
-
{
|
19
|
-
query: @options,
|
20
|
-
base_uri: 'http://services.tvrage.com/feeds/'
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
def collection_response(key, klass)
|
25
|
-
response_condition? ? array_mapped(klass, key) : []
|
26
|
-
end
|
27
|
-
|
28
|
-
def object_response(key, klass)
|
29
|
-
response_condition? ? klass.new(data[key]) : nil
|
30
|
-
end
|
31
|
-
|
32
|
-
def response_condition?
|
33
|
-
response.code == 200 && data.is_a?(Hash)
|
34
|
-
end
|
35
|
-
|
36
|
-
def array_normalize(key)
|
37
|
-
dig(key).is_a?(Array) ? dig(key) : [dig(key)]
|
38
|
-
end
|
39
|
-
|
40
|
-
def array_mapped(klass, key)
|
41
|
-
array_normalize(key).map { |data| klass.new(data) }
|
42
|
-
end
|
43
|
-
|
44
|
-
def dig(key)
|
45
|
-
data[key]
|
46
|
-
end
|
47
|
-
|
48
|
-
def data
|
49
|
-
response[data_key]
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def data_key
|
55
|
-
'Results'
|
56
|
-
end
|
57
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class TvrageApi::Request::Search < TvrageApi::Request::Base
|
2
|
-
def self.find(name)
|
3
|
-
new('search.php', show: name)
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.find_full(name)
|
7
|
-
new('full_search.php', show: name)
|
8
|
-
end
|
9
|
-
|
10
|
-
def result
|
11
|
-
collection_response('show', TvrageApi::Show)
|
12
|
-
end
|
13
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
class TvrageApi::Request::Show < TvrageApi::Request::Base
|
2
|
-
def self.find(id)
|
3
|
-
new('showinfo.php', :simple, sid: id)
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.find_full(id)
|
7
|
-
new('full_show_info.php', :full, sid: id)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.episodes(id)
|
11
|
-
new('episode_list.php', :full, sid: id)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.episode(series_id, season, episode)
|
15
|
-
new('episodeinfo.php', :episode, sid: series_id, ep: "#{season}x#{episode}")
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(uri, kind, options = {})
|
19
|
-
@kind = kind
|
20
|
-
super(uri, options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def result
|
24
|
-
@result ||= case @kind
|
25
|
-
when :simple
|
26
|
-
object_response('Showinfo', TvrageApi::Show)
|
27
|
-
when :full
|
28
|
-
object_response('Show', TvrageApi::Show)
|
29
|
-
when :episode
|
30
|
-
object_response('show', TvrageApi::Show)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def data
|
35
|
-
response
|
36
|
-
end
|
37
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class EpisodeArray
|
2
|
-
def self.coerce(value)
|
3
|
-
episodes = []
|
4
|
-
|
5
|
-
if value.respond_to?(:season)
|
6
|
-
value.season.each do |season|
|
7
|
-
season.episode.each do |episode|
|
8
|
-
episodes << TvrageApi::Episode.new(episode.to_hash)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
episodes
|
14
|
-
end
|
15
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Hashie
|
2
|
-
module Extensions
|
3
|
-
module KeyReplace
|
4
|
-
def self.included(base)
|
5
|
-
base.send :extend, ClassMethods
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize(source_hash = nil, default = nil, &blk)
|
9
|
-
source_hash = replace_keys(source_hash)
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
def replace_keys(source_hash)
|
14
|
-
source_hash.keys.each do |key|
|
15
|
-
new_key = self.class.key_replace(key) || key.to_s.underscore
|
16
|
-
|
17
|
-
if new_key != key
|
18
|
-
source_hash[new_key] = source_hash[key]
|
19
|
-
source_hash.delete(key)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
source_hash
|
23
|
-
end
|
24
|
-
|
25
|
-
module ClassMethods
|
26
|
-
def replace_key(*attrs)
|
27
|
-
@key_replaces ||= {}
|
28
|
-
into = attrs.pop
|
29
|
-
attrs.each { |key| @key_replaces[key] = into }
|
30
|
-
end
|
31
|
-
|
32
|
-
def key_replaces
|
33
|
-
@key_replaces || {}
|
34
|
-
end
|
35
|
-
|
36
|
-
def key_replace(key)
|
37
|
-
key_replaces[key.to_sym]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/tvrage_api/utility.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'tvrage_api/utility/aka_array'
|
2
|
-
require 'tvrage_api/utility/date'
|
3
|
-
require 'tvrage_api/utility/date_or_integer'
|
4
|
-
require 'tvrage_api/utility/episode_array'
|
5
|
-
require 'tvrage_api/utility/genre_array'
|
6
|
-
require 'tvrage_api/utility/integer'
|
7
|
-
require 'tvrage_api/utility/string'
|
8
|
-
require 'tvrage_api/utility/hashie/extensions/key_replace'
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TvrageApi::Episode do
|
4
|
-
let(:klass) { TvrageApi::Episode }
|
5
|
-
|
6
|
-
shared_examples 'mapping' do |field, field_mapped|
|
7
|
-
it "should save as #{field_mapped}" do
|
8
|
-
klass.new(field => '123').send(field_mapped).should_not == nil
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
shared_examples 'integer mapping' do |field|
|
13
|
-
it 'should save as Integer' do
|
14
|
-
klass.new(field => '123').send(field).should == 123
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
shared_examples 'date mapping' do |field|
|
19
|
-
it 'should save as Date' do
|
20
|
-
klass.new(field => '2000-01-01').send(field).should == Date.new(2000, 1, 1)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'key mapping' do
|
25
|
-
describe 'epnum attribute' do
|
26
|
-
include_examples 'mapping', :epnum, :episode_number
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'seasonnum attribute' do
|
30
|
-
include_examples 'mapping', :seasonnum, :season_number
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'prodnum attribute' do
|
34
|
-
include_examples 'mapping', :prodnum, :production_number
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'ceorce' do
|
39
|
-
describe 'airdate attribute' do
|
40
|
-
include_examples 'date mapping', :airdate
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'episode_number attribute' do
|
44
|
-
include_examples 'integer mapping', :episode_number
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'season_number attribute' do
|
48
|
-
include_examples 'integer mapping', :season_number
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class ExampleRequestClass < TvrageApi::Request::Base
|
4
|
-
end
|
5
|
-
|
6
|
-
describe TvrageApi::Request::Base do
|
7
|
-
let(:klass) { ExampleRequestClass }
|
8
|
-
let(:model) { klass.new('test') }
|
9
|
-
|
10
|
-
describe '#response' do
|
11
|
-
it 'should call get klass method' do
|
12
|
-
klass.should_receive(:get)
|
13
|
-
model.stub(:request_options).and_return({})
|
14
|
-
|
15
|
-
model.response
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#request_options' do
|
20
|
-
it 'should return correct keys' do
|
21
|
-
model.request_options.keys.sort.should == [:query, :base_uri].sort
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#collection_response' do
|
26
|
-
it 'should return filled array when condition is true' do
|
27
|
-
model.stub(:response_condition?).and_return(true)
|
28
|
-
model.stub(:array_mapped).and_return(['test'])
|
29
|
-
|
30
|
-
model.collection_response('Series', OpenStruct).should_not be_empty
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should return empty array when condition is false' do
|
34
|
-
model.stub(:response_condition?).and_return(false)
|
35
|
-
|
36
|
-
model.collection_response('Series', OpenStruct).should be_empty
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#object_response' do
|
41
|
-
it 'should return object when condition is true' do
|
42
|
-
model.stub(:response_condition?).and_return(true)
|
43
|
-
model.stub_chain(:response, :[]).and_return({})
|
44
|
-
|
45
|
-
model.object_response('Series', OpenStruct).class.should == OpenStruct
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should return nil when condition is false' do
|
49
|
-
model.stub(:response_condition?).and_return(false)
|
50
|
-
|
51
|
-
model.object_response('Series', OpenStruct).should be_nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#response_condition?' do
|
56
|
-
it 'should return true when code is 200 and return Data hash' do
|
57
|
-
model.stub_chain(:response, :code).and_return 200
|
58
|
-
model.stub_chain(:response, :[]).and_return({})
|
59
|
-
|
60
|
-
model.response_condition?.should be_true
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should return false when code is different than 200' do
|
64
|
-
model.stub_chain(:response, :code).and_return 400
|
65
|
-
model.stub_chain(:response, :[]).and_return({})
|
66
|
-
|
67
|
-
model.response_condition?.should be_false
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should return false when return blank response' do
|
71
|
-
model.stub_chain(:response, :code).and_return 200
|
72
|
-
model.stub_chain(:response, :[]).and_return('')
|
73
|
-
|
74
|
-
model.response_condition?.should be_false
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#array_normalize' do
|
79
|
-
it 'should return Array when dig return Array' do
|
80
|
-
model.stub(:dig).and_return(Array)
|
81
|
-
model.array_normalize('Series').class.should == Array
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should return Array when dig return Hash' do
|
85
|
-
model.stub(:dig).and_return(Hash)
|
86
|
-
model.array_normalize('Series').class.should == Array
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe '#array_mapped' do
|
91
|
-
it 'should map Array elements to objects' do
|
92
|
-
model.stub(:array_normalize).and_return([{ 'test' => 'value' }])
|
93
|
-
model.array_mapped(OpenStruct, 'Series').first.class.should == OpenStruct
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#dig' do
|
98
|
-
it 'should dig to correct hash' do
|
99
|
-
model.stub(:response).and_return({ 'Results' => { 'Series' => 'series value' } })
|
100
|
-
|
101
|
-
model.dig('Series').should == 'series value'
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe '#data' do
|
106
|
-
it 'should return correct value' do
|
107
|
-
model.stub(:response).and_return({ 'key' => 'value' })
|
108
|
-
model.stub(:data_key).and_return('key')
|
109
|
-
|
110
|
-
model.data.should == 'value'
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TvrageApi::Request::Search do
|
4
|
-
let(:klass) { TvrageApi::Request::Search }
|
5
|
-
let(:model) { klass.new('http://example.com', name: 'buffy') }
|
6
|
-
|
7
|
-
describe '#find' do
|
8
|
-
it 'should call new with specific params' do
|
9
|
-
klass.should_receive(:new).with('search.php', show: 'buffy')
|
10
|
-
|
11
|
-
klass.find('buffy')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#find_full' do
|
16
|
-
it 'should call new with specific params' do
|
17
|
-
klass.should_receive(:new).with('full_search.php', show: 'buffy')
|
18
|
-
|
19
|
-
klass.find_full('buffy')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#result' do
|
24
|
-
it 'should call collection_response method' do
|
25
|
-
model.should_receive(:collection_response)
|
26
|
-
|
27
|
-
model.result
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TvrageApi::Request::Show do
|
4
|
-
let(:klass) { TvrageApi::Request::Show }
|
5
|
-
let(:kind) { :simple }
|
6
|
-
let(:model) { klass.new('http://example.com', kind, sid: 123) }
|
7
|
-
|
8
|
-
describe '#find' do
|
9
|
-
it 'should call new with specific params' do
|
10
|
-
klass.should_receive(:new).with('showinfo.php', :simple, sid: 123)
|
11
|
-
|
12
|
-
klass.find(123)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#find_full' do
|
17
|
-
it 'should call new with specific params' do
|
18
|
-
klass.should_receive(:new).with('full_show_info.php', :full, sid: 123)
|
19
|
-
|
20
|
-
klass.find_full(123)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#episodes' do
|
25
|
-
it 'should call new with specific params' do
|
26
|
-
klass.should_receive(:new).with('episode_list.php', :full, sid: 123)
|
27
|
-
|
28
|
-
klass.episodes(123)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#episode' do
|
33
|
-
it 'should call new with specific params' do
|
34
|
-
klass.should_receive(:new).with('episodeinfo.php', :episode, sid: 123, ep: '1x2')
|
35
|
-
|
36
|
-
klass.episode(123, 1, 2)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#result' do
|
41
|
-
describe 'when kind is simple' do
|
42
|
-
let(:kind) { :simple }
|
43
|
-
|
44
|
-
it 'should call collection_response method' do
|
45
|
-
model.should_receive(:object_response).with('Showinfo', TvrageApi::Show)
|
46
|
-
|
47
|
-
model.result
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'when kind is full' do
|
52
|
-
let(:kind) { :full }
|
53
|
-
|
54
|
-
it 'should call collection_response method' do
|
55
|
-
model.should_receive(:object_response).with('Show', TvrageApi::Show)
|
56
|
-
|
57
|
-
model.result
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'when kind is episode' do
|
62
|
-
let(:kind) { :episode }
|
63
|
-
|
64
|
-
it 'should call collection_response method' do
|
65
|
-
model.should_receive(:object_response).with('show', TvrageApi::Show)
|
66
|
-
|
67
|
-
model.result
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TvrageApi::Request::Update do
|
4
|
-
let(:klass) { TvrageApi::Request::Update }
|
5
|
-
let(:model) { klass.new('http://example.com') }
|
6
|
-
|
7
|
-
describe '#all' do
|
8
|
-
it 'should call new with specific params' do
|
9
|
-
klass.should_receive(:new).with('show_list.php')
|
10
|
-
|
11
|
-
klass.all
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#result' do
|
16
|
-
it 'should call collection_response method' do
|
17
|
-
model.should_receive(:collection_response)
|
18
|
-
|
19
|
-
model.result
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#data_key' do
|
24
|
-
it 'should return correct value' do
|
25
|
-
model.data_key.should == 'shows'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|