tvrage_api 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +1,51 @@
1
1
  class TvrageApi::Update < TvrageApi::Base
2
+ include Ov
3
+
4
+ # List For Last Updated Shows
5
+ #
6
+ # access: FREE
7
+ # param:
8
+ # last
9
+ # output: Faraday::Response instance with parsed XML string
10
+ let :last do
11
+ last({})
12
+ end
13
+
2
14
  # List For Last Updated Shows
3
15
  #
4
16
  # access: FREE
5
- # param: options hash
6
- # hours: number of hours (optional)
7
- # sort: unfortunatelly unspecified (optional)
8
- # since: timestampe (optional)
17
+ # param:
18
+ # hours: number of hours
19
+ # sort: unfortunatelly unspecified
20
+ # since: timestampe
21
+ # param:
22
+ # last(hours: 48, sort: 'episodes', since: 1418056721)
9
23
  # output: Faraday::Response instance with parsed XML string
10
- def last(options = {})
24
+ let :last, Hash do |options|
11
25
  last_path_with_params(options).get
12
26
  end
13
27
 
14
28
  # List For Last Updated Shows - return only url
15
29
  #
16
30
  # access: FREE
17
- # param: options hash
18
- # hours: number of hours (optional)
19
- # sort: unfortunatelly unspecified (optional)
20
- # since: timestampe (optional)
31
+ # param:
32
+ # last_url()
33
+ # output: url string
34
+ let :last_url do
35
+ last_url({})
36
+ end
37
+
38
+ # List For Last Updated Shows - return only url
39
+ #
40
+ # access: FREE
41
+ # param:
42
+ # hours: number of hours
43
+ # sort: unfortunatelly unspecified
44
+ # since: timestampe
45
+ # param:
46
+ # last_url(hours: 48, sort: 'episodes', since: 1418056721)
21
47
  # output: url string
22
- def last_url(options = {})
48
+ let :last_url, Hash do |options|
23
49
  last_path_with_params(options).url
24
50
  end
25
51
 
@@ -1,3 +1,3 @@
1
1
  module TvrageApi
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -13,18 +13,38 @@ describe TvrageApi::Info do
13
13
  end
14
14
 
15
15
  describe '.find' do
16
- it 'should return Faraday::Response class' do
17
- expect(model.find(show: 'Alias')).to be_a(Faraday::Response)
16
+ context 'hash attributes' do
17
+ it 'should return Faraday::Response class' do
18
+ expect(model.find(show: 'Alias')).to be_a(Faraday::Response)
19
+ end
20
+
21
+ it 'should return String class for body reponse' do
22
+ expect(model.find(show: 'Alias').body).to be_a(String)
23
+ end
18
24
  end
19
25
 
20
- it 'should return String class for body reponse' do
21
- expect(model.find(show: 'Alias').body).to be_a(String)
26
+ context 'normal attributes' do
27
+ it 'should return Faraday::Response class' do
28
+ expect(model.find('Alias')).to be_a(Faraday::Response)
29
+ end
30
+
31
+ it 'should return String class for body reponse' do
32
+ expect(model.find('Alias').body).to be_a(String)
33
+ end
22
34
  end
23
35
  end
24
36
 
25
37
  describe '.find_url' do
26
- it 'should return correct url' do
27
- expect(model.find_url(show: 'Alias')).to eq('http://services.tvrage.com/tools/quickinfo.php?show=Alias')
38
+ context 'hash attributes' do
39
+ it 'should return correct url' do
40
+ expect(model.find_url(show: 'Alias')).to eq('http://services.tvrage.com/tools/quickinfo.php?show=Alias')
41
+ end
42
+ end
43
+
44
+ context 'normal attributes' do
45
+ it 'should return correct url' do
46
+ expect(model.find_url('Alias')).to eq('http://services.tvrage.com/tools/quickinfo.php?show=Alias')
47
+ end
28
48
  end
29
49
  end
30
50
  end
@@ -12,7 +12,7 @@ describe TvrageApi::Recap do
12
12
  Faraday::Adapter::Test::Stubs.new do |stub|
13
13
  stub.get('/recaps/all_recaps.php') { [200, { content_type: 'xml' }, all_data] }
14
14
  stub.get('/recaps/show_recaps.php?show=5410') { [200, { content_type: 'xml' }, show_data] }
15
- stub.get('/recaps/last_recaps.php') { [200, { content_type: 'xml' }, last_data] }
15
+ stub.get('/recaps/last_recaps.php?days=30') { [200, { content_type: 'xml' }, last_data] }
16
16
  end
17
17
  end
18
18
 
@@ -33,34 +33,74 @@ describe TvrageApi::Recap do
33
33
  end
34
34
 
35
35
  describe '.show' do
36
- it 'should return Faraday::Response class' do
37
- expect(model.show(show: 5410)).to be_a(Faraday::Response)
36
+ context 'hash attributes' do
37
+ it 'should return Faraday::Response class' do
38
+ expect(model.show(id: 5410)).to be_a(Faraday::Response)
39
+ end
40
+
41
+ it 'should return Hash class for body reponse' do
42
+ expect(model.show(id: 5410).body).to be_a(Hash)
43
+ end
38
44
  end
39
45
 
40
- it 'should return Hash class for body reponse' do
41
- expect(model.show(show: 5410).body).to be_a(Hash)
46
+ context 'normal attributes' do
47
+ it 'should return Faraday::Response class' do
48
+ expect(model.show(5410)).to be_a(Faraday::Response)
49
+ end
50
+
51
+ it 'should return Hash class for body reponse' do
52
+ expect(model.show(5410).body).to be_a(Hash)
53
+ end
42
54
  end
43
55
  end
44
56
 
45
- describe '.all_url' do
46
- it 'should return correct url' do
47
- expect(model.show_url(show: 5410)).to eq('http://services.tvrage.com/recaps/show_recaps.php?show=5410')
57
+ describe '.show_url' do
58
+ context 'hash attributes' do
59
+ it 'should return correct url' do
60
+ expect(model.show_url(id: 5410)).to eq('http://services.tvrage.com/recaps/show_recaps.php?show=5410')
61
+ end
62
+ end
63
+
64
+ context 'normal attributes' do
65
+ it 'should return correct url' do
66
+ expect(model.show_url(5410)).to eq('http://services.tvrage.com/recaps/show_recaps.php?show=5410')
67
+ end
48
68
  end
49
69
  end
50
70
 
51
71
  describe '.last' do
52
- it 'should return Faraday::Response class' do
53
- expect(model.last).to be_a(Faraday::Response)
72
+ context 'hash attributes' do
73
+ it 'should return Faraday::Response class' do
74
+ expect(model.last(days: 30)).to be_a(Faraday::Response)
75
+ end
76
+
77
+ it 'should return Hash class for body reponse' do
78
+ expect(model.last(days: 30).body).to be_a(Hash)
79
+ end
54
80
  end
55
81
 
56
- it 'should return Hash class for body reponse' do
57
- expect(model.last.body).to be_a(Hash)
82
+ context 'normal attributes' do
83
+ it 'should return Faraday::Response class' do
84
+ expect(model.last(30)).to be_a(Faraday::Response)
85
+ end
86
+
87
+ it 'should return String class for body reponse' do
88
+ expect(model.last(30).body).to be_a(Hash)
89
+ end
58
90
  end
59
91
  end
60
92
 
61
- describe '.all_url' do
62
- it 'should return correct url' do
63
- expect(model.last_url).to eq('http://services.tvrage.com/recaps/last_recaps.php')
93
+ describe '.last_url' do
94
+ context 'hash attributes' do
95
+ it 'should return correct url' do
96
+ expect(model.last_url(days: 30)).to eq('http://services.tvrage.com/recaps/last_recaps.php?days=30')
97
+ end
98
+ end
99
+
100
+ context 'normal attributes' do
101
+ it 'should return correct url' do
102
+ expect(model.last_url(30)).to eq('http://services.tvrage.com/recaps/last_recaps.php?days=30')
103
+ end
64
104
  end
65
105
  end
66
106
  end
@@ -10,39 +10,80 @@ describe TvrageApi::Schedule do
10
10
  let(:faraday_stubs) do
11
11
  Faraday::Adapter::Test::Stubs.new do |stub|
12
12
  stub.get('/tools/quickschedule.php') { [200, { content_type: 'text' }, quick_data] }
13
+ stub.get('/feeds/fullschedule.php') { [200, { content_type: 'xml' }, full_data] }
13
14
  stub.get('/feeds/fullschedule.php?country=US') { [200, { content_type: 'xml' }, full_data] }
14
15
  end
15
16
  end
16
17
 
17
18
  describe '.quick' do
18
- it 'should return Faraday::Response class' do
19
- expect(model.quick).to be_a(Faraday::Response)
19
+ context 'hash attributes' do
20
+ it 'should return Faraday::Response class' do
21
+ expect(model.quick(country: 'US')).to be_a(Faraday::Response)
22
+ end
23
+
24
+ it 'should return String class for body reponse' do
25
+ expect(model.quick(country: 'US').body).to be_a(String)
26
+ end
20
27
  end
21
28
 
22
- it 'should return String class for body reponse' do
23
- expect(model.quick.body).to be_a(String)
29
+ context 'normal attributes' do
30
+ it 'should return Faraday::Response class' do
31
+ expect(model.quick('US')).to be_a(Faraday::Response)
32
+ end
33
+
34
+ it 'should return String class for body reponse' do
35
+ expect(model.quick('US').body).to be_a(String)
36
+ end
24
37
  end
25
38
  end
26
39
 
27
40
  describe '.quick_url' do
28
- it 'should return correct url' do
29
- expect(model.quick_url).to eq('http://services.tvrage.com/tools/quickschedule.php')
41
+ context 'hash attributes' do
42
+ it 'should return correct url' do
43
+ expect(model.quick_url(country: 'US')).to eq('http://services.tvrage.com/tools/quickschedule.php?country=US')
44
+ end
45
+ end
46
+
47
+ context 'normal attributes' do
48
+ it 'should return correct url' do
49
+ expect(model.quick_url('US')).to eq('http://services.tvrage.com/tools/quickschedule.php?country=US')
50
+ end
30
51
  end
31
52
  end
32
53
 
33
54
  describe '.full' do
34
- it 'should return Faraday::Response class' do
35
- expect(model.full(country: 'US')).to be_a(Faraday::Response)
55
+ context 'hash attributes' do
56
+ it 'should return Faraday::Response class' do
57
+ expect(model.full(country: 'US')).to be_a(Faraday::Response)
58
+ end
59
+
60
+ it 'should return Hash class for body reponse' do
61
+ expect(model.full(country: 'US').body).to be_a(Hash)
62
+ end
36
63
  end
37
64
 
38
- it 'should return Hash class for body reponse' do
39
- expect(model.full(country: 'US').body).to be_a(Hash)
65
+ context 'normal attributes' do
66
+ it 'should return Faraday::Response class' do
67
+ expect(model.full).to be_a(Faraday::Response)
68
+ end
69
+
70
+ it 'should return Hash class for body reponse' do
71
+ expect(model.full.body).to be_a(Hash)
72
+ end
40
73
  end
41
74
  end
42
75
 
43
76
  describe '.quick_url' do
44
- it 'should return correct url' do
45
- expect(model.full_url(country: 'US')).to eq('http://services.tvrage.com/feeds/fullschedule.php?country=US')
77
+ context 'hash attributes' do
78
+ it 'should return correct url' do
79
+ expect(model.full_url(country: 'US')).to eq('http://services.tvrage.com/feeds/fullschedule.php?country=US')
80
+ end
81
+ end
82
+
83
+ context 'normal attributes' do
84
+ it 'should return correct url' do
85
+ expect(model.full_url).to eq('http://services.tvrage.com/feeds/fullschedule.php')
86
+ end
46
87
  end
47
88
  end
48
89
  end
@@ -15,34 +15,74 @@ describe TvrageApi::Search do
15
15
  end
16
16
 
17
17
  describe '.by_name' do
18
- it 'should return Faraday::Response class' do
19
- expect(model.by_name(show: 'buffy')).to be_a(Faraday::Response)
18
+ context 'hash attributes' do
19
+ it 'should return Faraday::Response class' do
20
+ expect(model.by_name(name: 'buffy')).to be_a(Faraday::Response)
21
+ end
22
+
23
+ it 'should return Hash class for body reponse' do
24
+ expect(model.by_name(name: 'buffy').body).to be_a(Hash)
25
+ end
20
26
  end
21
27
 
22
- it 'should return Hash class for body reponse' do
23
- expect(model.by_name(show: 'buffy').body).to be_a(Hash)
28
+ context 'normal attributes' do
29
+ it 'should return Faraday::Response class' do
30
+ expect(model.by_name('buffy')).to be_a(Faraday::Response)
31
+ end
32
+
33
+ it 'should return Hash class for body reponse' do
34
+ expect(model.by_name('buffy').body).to be_a(Hash)
35
+ end
24
36
  end
25
37
  end
26
38
 
27
39
  describe '.by_name_url' do
28
- it 'should return correct url' do
29
- expect(model.by_name_url(show: 'buffy')).to eq('http://services.tvrage.com/feeds/search.php?show=buffy')
40
+ context 'hash attributes' do
41
+ it 'should return correct url' do
42
+ expect(model.by_name_url(name: 'buffy')).to eq('http://services.tvrage.com/feeds/search.php?show=buffy')
43
+ end
44
+ end
45
+
46
+ context 'normal attributes' do
47
+ it 'should return correct url' do
48
+ expect(model.by_name_url('buffy')).to eq('http://services.tvrage.com/feeds/search.php?show=buffy')
49
+ end
30
50
  end
31
51
  end
32
52
 
33
53
  describe '.full_by_name' do
34
- it 'should return Faraday::Response class' do
35
- expect(model.full_by_name(show: 'buffy')).to be_a(Faraday::Response)
54
+ context 'hash attributes' do
55
+ it 'should return Faraday::Response class' do
56
+ expect(model.full_by_name(name: 'buffy')).to be_a(Faraday::Response)
57
+ end
58
+
59
+ it 'should return Hash class for body reponse' do
60
+ expect(model.full_by_name(name: 'buffy').body).to be_a(Hash)
61
+ end
36
62
  end
37
63
 
38
- it 'should return Hash class for body reponse' do
39
- expect(model.full_by_name(show: 'buffy').body).to be_a(Hash)
64
+ context 'normal attributes' do
65
+ it 'should return Faraday::Response class' do
66
+ expect(model.full_by_name('buffy')).to be_a(Faraday::Response)
67
+ end
68
+
69
+ it 'should return Hash class for body reponse' do
70
+ expect(model.full_by_name('buffy').body).to be_a(Hash)
71
+ end
40
72
  end
41
73
  end
42
74
 
43
75
  describe '.full_by_name_url' do
44
- it 'should return correct url' do
45
- expect(model.full_by_name_url(show: 'buffy')).to eq('http://services.tvrage.com/feeds/full_search.php?show=buffy')
76
+ context 'hash attributes' do
77
+ it 'should return correct url' do
78
+ expect(model.full_by_name_url(name: 'buffy')).to eq('http://services.tvrage.com/feeds/full_search.php?show=buffy')
79
+ end
80
+ end
81
+
82
+ context 'normal attributes' do
83
+ it 'should return correct url' do
84
+ expect(model.full_by_name_url('buffy')).to eq('http://services.tvrage.com/feeds/full_search.php?show=buffy')
85
+ end
46
86
  end
47
87
  end
48
88
  end
@@ -21,66 +21,146 @@ describe TvrageApi::Show do
21
21
  end
22
22
 
23
23
  describe '.find' do
24
- it 'should return Faraday::Response class' do
25
- expect(model.find(sid: 2930)).to be_a(Faraday::Response)
24
+ context 'hash attributes' do
25
+ it 'should return Faraday::Response class' do
26
+ expect(model.find(id: 2930)).to be_a(Faraday::Response)
27
+ end
28
+
29
+ it 'should return Hash class for body reponse' do
30
+ expect(model.find(id: 2930).body).to be_a(Hash)
31
+ end
26
32
  end
27
33
 
28
- it 'should return Hash class for body reponse' do
29
- expect(model.find(sid: 2930).body).to be_a(Hash)
34
+ context 'normal attributes' do
35
+ it 'should return Faraday::Response class' do
36
+ expect(model.find(2930)).to be_a(Faraday::Response)
37
+ end
38
+
39
+ it 'should return Hash class for body reponse' do
40
+ expect(model.find(2930).body).to be_a(Hash)
41
+ end
30
42
  end
31
43
  end
32
44
 
33
45
  describe '.find_url' do
34
- it 'should return correct url' do
35
- expect(model.find_url(sid: 2930)).to eq('http://services.tvrage.com/feeds/showinfo.php?sid=2930')
46
+ context 'hash attributes' do
47
+ it 'should return correct url' do
48
+ expect(model.find_url(id: 2930)).to eq('http://services.tvrage.com/feeds/showinfo.php?sid=2930')
49
+ end
50
+ end
51
+
52
+ context 'normal attributes' do
53
+ it 'should return correct url' do
54
+ expect(model.find_url(2930)).to eq('http://services.tvrage.com/feeds/showinfo.php?sid=2930')
55
+ end
36
56
  end
37
57
  end
38
58
 
39
59
  describe '.find_full' do
40
- it 'should return Faraday::Response class' do
41
- expect(model.find_full(sid: 2930)).to be_a(Faraday::Response)
60
+ context 'hash attributes' do
61
+ it 'should return Faraday::Response class' do
62
+ expect(model.find_full(id: 2930)).to be_a(Faraday::Response)
63
+ end
64
+
65
+ it 'should return Hash class for body reponse' do
66
+ expect(model.find_full(id: 2930).body).to be_a(Hash)
67
+ end
42
68
  end
43
69
 
44
- it 'should return Hash class for body reponse' do
45
- expect(model.find_full(sid: 2930).body).to be_a(Hash)
70
+ context 'normal attributes' do
71
+ it 'should return Faraday::Response class' do
72
+ expect(model.find_full(2930)).to be_a(Faraday::Response)
73
+ end
74
+
75
+ it 'should return Hash class for body reponse' do
76
+ expect(model.find_full(2930).body).to be_a(Hash)
77
+ end
46
78
  end
47
79
  end
48
80
 
49
81
  describe '.find_full_url' do
50
- it 'should return correct url' do
51
- expect(model.find_full_url(sid: 2930)).to eq('http://services.tvrage.com/feeds/full_show_info.php?sid=2930')
82
+ context 'hash attributes' do
83
+ it 'should return correct url' do
84
+ expect(model.find_full_url(id: 2930)).to eq('http://services.tvrage.com/feeds/full_show_info.php?sid=2930')
85
+ end
86
+ end
87
+
88
+ context 'normal attributes' do
89
+ it 'should return correct url' do
90
+ expect(model.find_full_url(2930)).to eq('http://services.tvrage.com/feeds/full_show_info.php?sid=2930')
91
+ end
52
92
  end
53
93
  end
54
94
 
55
95
  describe '.episodes' do
56
- it 'should return Faraday::Response class' do
57
- expect(model.episodes(sid: 2930)).to be_a(Faraday::Response)
96
+ context 'hash attributes' do
97
+ it 'should return Faraday::Response class' do
98
+ expect(model.episodes(id: 2930)).to be_a(Faraday::Response)
99
+ end
100
+
101
+ it 'should return Hash class for body reponse' do
102
+ expect(model.episodes(id: 2930).body).to be_a(Hash)
103
+ end
58
104
  end
59
105
 
60
- it 'should return Hash class for body reponse' do
61
- expect(model.episodes(sid: 2930).body).to be_a(Hash)
106
+ context 'normal attributes' do
107
+ it 'should return Faraday::Response class' do
108
+ expect(model.episodes(2930)).to be_a(Faraday::Response)
109
+ end
110
+
111
+ it 'should return Hash class for body reponse' do
112
+ expect(model.episodes(2930).body).to be_a(Hash)
113
+ end
62
114
  end
63
115
  end
64
116
 
65
117
  describe '.episodes_url' do
66
- it 'should return correct url' do
67
- expect(model.episodes_url(sid: 2930)).to eq('http://services.tvrage.com/feeds/episode_list.php?sid=2930')
118
+ context 'hash attributes' do
119
+ it 'should return correct url' do
120
+ expect(model.episodes_url(id: 2930)).to eq('http://services.tvrage.com/feeds/episode_list.php?sid=2930')
121
+ end
122
+ end
123
+
124
+ context 'normal attributes' do
125
+ it 'should return correct url' do
126
+ expect(model.episodes_url(2930)).to eq('http://services.tvrage.com/feeds/episode_list.php?sid=2930')
127
+ end
68
128
  end
69
129
  end
70
130
 
71
131
  describe '.episode' do
72
- it 'should return Faraday::Response class' do
73
- expect(model.episode(sid: 2930, ep: '2x04')).to be_a(Faraday::Response)
132
+ context 'hash attributes' do
133
+ it 'should return Faraday::Response class' do
134
+ expect(model.episode(show_id: 2930, episode: '2x04')).to be_a(Faraday::Response)
135
+ end
136
+
137
+ it 'should return Hash class for body reponse' do
138
+ expect(model.episode(show_id: 2930, episode: '2x04').body).to be_a(Hash)
139
+ end
74
140
  end
75
141
 
76
- it 'should return Hash class for body reponse' do
77
- expect(model.episode(sid: 2930, ep: '2x04').body).to be_a(Hash)
142
+ context 'normal attributes' do
143
+ it 'should return Faraday::Response class' do
144
+ expect(model.episode(2930, '2x04')).to be_a(Faraday::Response)
145
+ end
146
+
147
+ it 'should return Hash class for body reponse' do
148
+ expect(model.episode(2930, '2x04').body).to be_a(Hash)
149
+ end
78
150
  end
79
151
  end
80
152
 
81
153
  describe '.episode_url' do
82
- it 'should return correct url' do
83
- expect(model.episode_url(sid: 2930, ep: '2x04')).to eq('http://services.tvrage.com/feeds/episodeinfo.php?sid=2930&ep=2x04')
154
+ context 'hash attributes' do
155
+ it 'should return correct url' do
156
+ expect(model.episode_url(show_id: 2930, episode: '2x04')).to eq('http://services.tvrage.com/feeds/episodeinfo.php?sid=2930&ep=2x04')
157
+ end
158
+ end
159
+
160
+ context 'normal attributes' do
161
+ it 'should return correct url' do
162
+ expect(model.episode_url(2930, '2x04')).to eq('http://services.tvrage.com/feeds/episodeinfo.php?sid=2930&ep=2x04')
163
+ end
84
164
  end
85
165
  end
86
166