sick-beard 1.0.0.pre

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.
@@ -0,0 +1,106 @@
1
+ require 'spec_helper'
2
+
3
+ describe SickBeard::Client, vcr: {
4
+ cassette_name: 'sickbeard',
5
+ record: :new_episodes,
6
+ match_requests_on: [:uri]
7
+ } do
8
+ let(:sickbeard) { SickBeard::Client.new(server: api_uri, api_key: api_key ) }
9
+
10
+ describe "#make_json_request" do
11
+ it "should raise an exception if the result is not success" do
12
+ expect { sickbeard.make_json_request('testing') }.to raise_error(SickBeard::Error)
13
+ end
14
+ end
15
+
16
+ describe "#make_request" do
17
+ it "should make a request and return the body of the response" do
18
+ sickbeard.make_request('testing').should == '{"result":"failure"}'
19
+ end
20
+ end
21
+
22
+ describe "#sb" do
23
+ it "should request the SickBeard server information" do
24
+ response = sickbeard.sb
25
+ end
26
+ end
27
+
28
+ describe "#future" do
29
+ it "should return a list of upcoming TV shows" do
30
+ response = sickbeard.future
31
+ response.keys.should == ['later', 'missed', 'soon', 'today']
32
+ end
33
+
34
+ it "should return a list of upcoming TV shows for today" do
35
+ response = sickbeard.future
36
+ response['today'].length.should == 3
37
+ response['today'].collect {|e| e['show_name']}.should == ['Leverage', 'True Blood', 'Falling Skies']
38
+ response['today'].collect {|e| e['ep_name']}.should == ['The French Connection Job', 'Gone, Gone, Gone', 'The Price of Greatness']
39
+ response['today'].collect {|e| e['network']}.should == ['TNT', 'HBO', 'TNT']
40
+ response['today'].collect {|e| e['tvdbid']}.should == [82339, 82283, 205281]
41
+ end
42
+
43
+ it "should filter the results by type" do
44
+ response = sickbeard.future(:type => ['missed', 'soon'])
45
+ response.keys.should == ['missed', 'soon']
46
+ end
47
+
48
+ it "should order the results" do
49
+ response = sickbeard.future(:sort => 'network')
50
+ response['today'].collect {|e| e['network']}.should == ['HBO', 'TNT', 'TNT']
51
+ end
52
+ end
53
+
54
+ describe "#shows_stats" do
55
+ it "should return global episode and show statistics" do
56
+ response = sickbeard.shows_stats
57
+ response['ep_downloaded'].should == 1653
58
+ response['ep_total'].should == 7595
59
+ response['shows_active'].should == 40
60
+ response['shows_total'].should == 89
61
+ end
62
+ end
63
+
64
+ describe "#shows" do
65
+ it "should return a list of all known TV shows in SickBeard" do
66
+ response = sickbeard.shows
67
+
68
+ response.length.should == 89
69
+ response[0..4].collect { |show| show.name }.should == [
70
+ 'Farscape', 'Twin Peaks', 'Babylon 5',
71
+ 'Star Trek: The Next Generation', 'The Wild Wild West']
72
+ end
73
+
74
+ it "should order the results" do
75
+ response = sickbeard.shows(sort: 'name')
76
+
77
+ response.length.should == 89
78
+ response[0..4].collect { |show| show.name }.should == [
79
+ '30 Rock', 'Accidentally On Purpose', 'American Gothic',
80
+ 'American Horror Story', 'Andromeda']
81
+ end
82
+ end
83
+
84
+ describe "#show" do
85
+ it "should get the information for a given show" do
86
+ show = sickbeard.show(70522)
87
+ show.should be_an_instance_of SickBeard::Show
88
+ show.name.should == 'Farscape'
89
+ show.genres.should == ['Science-Fiction']
90
+ show.status.should == 'Ended'
91
+ show.season_list.should == [0, 1, 2, 3, 4, 5]
92
+ show.tvdbid.should == 70522
93
+ show.server.should == sickbeard
94
+ show.quality.should == "SD"
95
+ end
96
+ end
97
+
98
+ describe "#searchtvdb" do
99
+ it "should search the tv db by name" do
100
+ result = sickbeard.searchtvdb('Star')
101
+ result.length.should == 94
102
+ result[0].should be_an_instance_of SickBeard::Show
103
+ result[0].name.should == 'Fist of the North Star'
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,142 @@
1
+ require 'spec_helper'
2
+
3
+ describe SickBeard::Show, vcr: {
4
+ cassette_name: 'sickbeard',
5
+ record: :new_episodes,
6
+ match_requests_on: [:uri]
7
+ } do
8
+ let(:sickbeard) { SickBeard::Client.new(server: api_uri, api_key: api_key) }
9
+ let(:show) { SickBeard::Show.new(server: sickbeard, tvdbid: 70522) }
10
+
11
+ describe "#seasons" do
12
+ it "should get all seasons if no season is supplied" do
13
+ result = show.seasons
14
+ result.keys.should == ['0', '1', '2', '3', '4', '5']
15
+ end
16
+
17
+ it "should get the specified season if one is provided" do
18
+ result = show.seasons(1)
19
+ result.keys.should == ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
20
+ end
21
+ end
22
+
23
+ describe "#get_banner" do
24
+ it "should fetch the banner for this show" do
25
+ show.get_banner.should == "show.get_banner returns a JPEG file directly.\n"
26
+ end
27
+ end
28
+
29
+ describe "#get_poster" do
30
+ it "should fetch the poster for this show" do
31
+ show.get_poster.should == "show.get_poster returns a JPEG file directly.\n"
32
+ end
33
+ end
34
+
35
+ describe "#pause" do
36
+ it "should set the show's paused state in SickBeard to be paused" do
37
+ show.pause.should == 'Farscape has been paused'
38
+ end
39
+ end
40
+
41
+ describe "#unpause" do
42
+ it "should set the show's paused state in SickBeard to be unpaused" do
43
+ show.unpause.should == 'Farscape has been unpaused'
44
+ end
45
+ end
46
+
47
+ describe "#paused?" do
48
+ it "should return false if the show is not currently paused in SickBeard" do
49
+ show.should_not be_paused
50
+ end
51
+ end
52
+
53
+ describe "#set_quality" do
54
+ it "should set the quality of a show given a list of initial quality settings" do
55
+ show.set_quality(initial: ['sdtv', 'hdtv']).should == 'Farscape quality has been changed to Custom'
56
+ end
57
+ it "should set the quality of a show given a single initial quality setting" do
58
+ show.set_quality(initial: 'sdtv').should == 'Farscape quality has been changed to Custom'
59
+ end
60
+ it "should set the quality of a show given a list of archive quality settings" do
61
+ show.set_quality(archive: ['sdtv', 'hdtv']).should == 'Farscape quality has been changed to Custom'
62
+ end
63
+ it "should set the quality of a show given a single archive quality setting" do
64
+ show.set_quality(archive: 'sdtv').should == 'Farscape quality has been changed to Custom'
65
+ end
66
+ it "should set the quality of a show given both an initial and archive quality setting" do
67
+ show.set_quality(archive: 'sdtv', initial: 'hdtv').should == 'Farscape quality has been changed to Custom'
68
+ end
69
+ end
70
+
71
+ describe "#season_list" do
72
+ it "should return the season list if it was already populated" do
73
+ new_show = SickBeard::Show.new(server: sickbeard, tvdbid: 70522, season_list: [3, 2, 1, 0])
74
+ new_show.season_list.should == [0, 1, 2, 3]
75
+ end
76
+ it "should fetch the season list if it is unknown" do
77
+ new_show = SickBeard::Show.new(server: sickbeard, tvdbid: 70522)
78
+ new_show.season_list.should == [0, 1, 2, 3, 4, 5]
79
+ end
80
+ end
81
+
82
+ describe "#show_stats" do
83
+ it "should get the stats for the show" do
84
+ response = show.stats
85
+ response['total'].should == 92
86
+ end
87
+ end
88
+
89
+ describe "#cached_banner?" do
90
+ it "should return true if the banner image cache is valid for this show" do
91
+ show.should have_cached_banner
92
+ end
93
+ end
94
+
95
+ describe "#cached_poster?" do
96
+ it "should return true if the banner image cache is valid for this show" do
97
+ show.should have_cached_poster
98
+ end
99
+ end
100
+
101
+ describe "#update" do
102
+ it "should update a show in SickBeard by pulling down information from TVDB and rescan local files." do
103
+ show.update.should == 'Farscape has queued to be updated'
104
+ end
105
+ end
106
+
107
+ describe "#refresh" do
108
+ it "should refresh a show in SickBeard by pulling down information from TVDB and rescan local files." do
109
+ show.refresh.should == 'Farscape has queued to be refreshed'
110
+ end
111
+ end
112
+
113
+ describe "#addnew" do
114
+ it "should add a show to SickBeard." do
115
+ show.addnew.should == 'Farscape has been queued to be added'
116
+ end
117
+ it "should pass the season_folder option if provided." do
118
+ show.addnew(season_folder: 1).should == 'Farscape has been queued to be added'
119
+ end
120
+ it "should pass the location option if provided." do
121
+ show.addnew(location: '/storage/videos/').should == 'Farscape has been queued to be added'
122
+ end
123
+ it "should pass the status option if provided" do
124
+ show.addnew(status: 'wanted').should == 'Farscape has been queued to be added'
125
+ end
126
+ it "should pass the lang option if provided" do
127
+ show.addnew(lang: 'nl').should == 'Farscape has been queued to be added'
128
+ end
129
+ it "should correctly pass initial options if provided." do
130
+ show.addnew(initial: ['sdtv','hdtv']).should == 'Farscape has been queued to be added'
131
+ end
132
+ it "should correctly pass archive options if provided." do
133
+ show.addnew(archive: ['sdtv','hdtv']).should == 'Farscape has been queued to be added'
134
+ end
135
+ end
136
+
137
+ describe "#delete" do
138
+ it "should remove a show from SickBeard." do
139
+ show.delete.should == 'Farscape has been deleted'
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,59 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ require 'pry'
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ Coveralls::SimpleCov::Formatter,
6
+ SimpleCov::Formatter::HTMLFormatter
7
+ ]
8
+ SimpleCov.start do
9
+ add_filter '/spec/'
10
+ end
11
+
12
+ # Previous content of test helper now starts here
13
+ require 'sickbeard'
14
+
15
+ # This file was generated by the `rspec --init` command. Conventionally, all
16
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
17
+ # Require this file using `require "spec_helper"` to ensure that it is only
18
+ # loaded once.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+
22
+ require 'webmock/rspec'
23
+ require 'vcr'
24
+
25
+ def api_key
26
+ key = 'VALID_SICKBEARD_API_KEY'
27
+ key = ENV['SICKBEARD_API_KEY'] if ENV.has_key?('SICKBEARD_API_KEY')
28
+ key
29
+ end
30
+
31
+ def api_uri
32
+ uri = 'http://example.com:8080/'
33
+ uri = ENV['SICKBEARD_API_URI'] if ENV.has_key?('SICKBEARD_API_URI')
34
+ uri
35
+ end
36
+
37
+ RSpec.configure do |config|
38
+ config.treat_symbols_as_metadata_keys_with_true_values = true
39
+ config.run_all_when_everything_filtered = true
40
+ config.filter_run :focus
41
+
42
+ # Run specs in random order to surface order dependencies. If you find an
43
+ # order dependency and want to debug it, you can fix the order by providing
44
+ # the seed, which is printed after each run.
45
+ # --seed 1234
46
+ config.order = 'random'
47
+ end
48
+
49
+ VCR.configure do |c|
50
+ c.cassette_library_dir = 'spec/cassettes'
51
+ c.hook_into :webmock
52
+ c.preserve_exact_body_bytes { true }
53
+ c.configure_rspec_metadata!
54
+
55
+ ##
56
+ # Filter the real API key so that it does not make its way into the VCR cassette
57
+ c.filter_sensitive_data('<API_KEY>') { api_key }
58
+ c.filter_sensitive_data('<API_URI>') { api_uri }
59
+ end
metadata ADDED
@@ -0,0 +1,267 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sick-beard
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - Kevin McDermott
8
+ - Ryan Lovelett
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 1.8.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 1.8.1
28
+ - !ruby/object:Gem::Dependency
29
+ name: rest-client
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.6.7
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 1.6.7
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 10.0.4
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 10.0.4
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 2.13.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.13.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec-xml
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.0.6
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 0.0.6
84
+ - !ruby/object:Gem::Dependency
85
+ name: guard-rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 2.5.1
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: 2.5.1
98
+ - !ruby/object:Gem::Dependency
99
+ name: rb-fsevent
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ version: 0.9.1
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: 0.9.1
112
+ - !ruby/object:Gem::Dependency
113
+ name: growl
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: 1.0.3
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.0.3
126
+ - !ruby/object:Gem::Dependency
127
+ name: terminal-notifier-guard
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ~>
131
+ - !ruby/object:Gem::Version
132
+ version: 1.5.3
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ~>
138
+ - !ruby/object:Gem::Version
139
+ version: 1.5.3
140
+ - !ruby/object:Gem::Dependency
141
+ name: vcr
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ~>
145
+ - !ruby/object:Gem::Version
146
+ version: 2.8.0
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ version: 2.8.0
154
+ - !ruby/object:Gem::Dependency
155
+ name: webmock
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ~>
159
+ - !ruby/object:Gem::Version
160
+ version: 1.9.0
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ~>
166
+ - !ruby/object:Gem::Version
167
+ version: 1.9.0
168
+ - !ruby/object:Gem::Dependency
169
+ name: faker
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ~>
173
+ - !ruby/object:Gem::Version
174
+ version: 1.1.2
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: 1.1.2
182
+ - !ruby/object:Gem::Dependency
183
+ name: simplecov
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ~>
187
+ - !ruby/object:Gem::Version
188
+ version: 0.7.1
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ~>
194
+ - !ruby/object:Gem::Version
195
+ version: 0.7.1
196
+ - !ruby/object:Gem::Dependency
197
+ name: coveralls
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ! '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ description: A Ruby interface for interacting with the Sick Beard PRV API (http://sickbeard.com/api)
211
+ email:
212
+ - bigkevmcd@gmail.com
213
+ - ryan@lovelett.me
214
+ executables: []
215
+ extensions: []
216
+ extra_rdoc_files: []
217
+ files:
218
+ - .gitignore
219
+ - .rspec
220
+ - .ruby-gemset
221
+ - .ruby-version
222
+ - .travis.yml
223
+ - Changelog.md
224
+ - Gemfile
225
+ - Guardfile
226
+ - LICENSE
227
+ - README.md
228
+ - Rakefile
229
+ - lib/sickbeard.rb
230
+ - lib/sickbeard/api.rb
231
+ - lib/sickbeard/show.rb
232
+ - lib/sickbeard/version.rb
233
+ - sick-beard.gemspec
234
+ - spec/.rspec
235
+ - spec/cassettes/sickbeard.yml
236
+ - spec/client_spec.rb
237
+ - spec/show_spec.rb
238
+ - spec/spec_helper.rb
239
+ homepage: https://github.com/RLovelett/sick-beard
240
+ licenses: []
241
+ metadata: {}
242
+ post_install_message:
243
+ rdoc_options: []
244
+ require_paths:
245
+ - lib
246
+ required_ruby_version: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ! '>='
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ required_rubygems_version: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - ! '>'
254
+ - !ruby/object:Gem::Version
255
+ version: 1.3.1
256
+ requirements: []
257
+ rubyforge_project:
258
+ rubygems_version: 2.1.11
259
+ signing_key:
260
+ specification_version: 4
261
+ summary: A Ruby interface for the Sick Beard API
262
+ test_files:
263
+ - spec/.rspec
264
+ - spec/cassettes/sickbeard.yml
265
+ - spec/client_spec.rb
266
+ - spec/show_spec.rb
267
+ - spec/spec_helper.rb