traktr 0.5.0 → 0.7.0
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 +4 -4
- data/Rakefile +4 -0
- data/lib/traktr.rb +1 -2
- data/lib/traktr/account.rb +5 -18
- data/lib/traktr/activity.rb +20 -45
- data/lib/traktr/activity/user.rb +12 -27
- data/lib/traktr/calendar.rb +13 -0
- data/lib/traktr/client.rb +52 -1
- data/lib/traktr/comment.rb +18 -0
- data/lib/traktr/endpoint.rb +38 -0
- data/lib/traktr/genres.rb +11 -0
- data/lib/traktr/lists.rb +22 -0
- data/lib/traktr/lists/items.rb +15 -0
- data/lib/traktr/movie.rb +29 -93
- data/lib/traktr/movies.rb +4 -22
- data/lib/traktr/network.rb +27 -0
- data/lib/traktr/rate.rb +30 -0
- data/lib/traktr/recommendations.rb +19 -0
- data/lib/traktr/search.rb +11 -46
- data/lib/traktr/server.rb +7 -0
- data/lib/traktr/show.rb +32 -99
- data/lib/traktr/show/episode.rb +13 -54
- data/lib/traktr/show/season.rb +3 -20
- data/lib/traktr/shows.rb +4 -22
- data/lib/traktr/user.rb +33 -36
- data/lib/traktr/user/calendar.rb +4 -12
- data/lib/traktr/user/library.rb +9 -7
- data/lib/traktr/user/library/movies.rb +6 -24
- data/lib/traktr/user/library/shows.rb +6 -24
- data/lib/traktr/user/network.rb +5 -23
- data/lib/traktr/user/progress.rb +4 -17
- data/lib/traktr/user/ratings.rb +5 -23
- data/lib/traktr/user/watchlist.rb +5 -23
- data/lib/traktr/version.rb +1 -1
- data/spec/calendar_spec.rb +78 -0
- data/spec/comment_spec.rb +65 -0
- data/spec/genres_spec.rb +33 -0
- data/spec/lists_items_spec.rb +65 -0
- data/spec/lists_spec.rb +64 -0
- data/spec/movie_spec.rb +8 -0
- data/spec/network_spec.rb +94 -0
- data/spec/rate_spec.rb +110 -0
- data/spec/recommendations_spec.rb +71 -0
- data/spec/server_spec.rb +25 -0
- data/spec/show_episode_spec.rb +8 -0
- data/spec/show_spec.rb +12 -0
- data/spec/spec.yaml.sample +11 -4
- data/spec/spec_helper.rb +13 -4
- data/spec/user_calendar_spec.rb +51 -0
- data/spec/user_library_movies_spec.rb +59 -0
- data/spec/user_library_shows_spec.rb +59 -0
- data/spec/user_network_spec.rb +59 -0
- data/spec/user_progress_spec.rb +47 -0
- data/spec/user_ratings_spec.rb +59 -0
- data/spec/user_spec.rb +115 -0
- data/spec/user_watchlist_spec.rb +59 -0
- metadata +46 -2
data/lib/traktr/version.rb
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Traktr::Calendar do
|
4
|
+
context 'GET methods' do
|
5
|
+
context 'with valid api_key' do
|
6
|
+
before :all do
|
7
|
+
@trakt = Traktr::Client.new(API_KEY)
|
8
|
+
end
|
9
|
+
|
10
|
+
it '#premieres' do
|
11
|
+
expect( @trakt.calendar.premieres.class ).to eql(Array)
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#shows' do
|
15
|
+
expect( @trakt.calendar.shows.class ).to eql(Array)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with valid api_key and auth credentials' do
|
20
|
+
before :all do
|
21
|
+
@trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#premieres' do
|
25
|
+
premieres = @trakt.calendar.premieres
|
26
|
+
expect( premieres.class ).to eql(Array)
|
27
|
+
premieres.each do |day|
|
28
|
+
day.episodes.each do |episode|
|
29
|
+
expect( episode.show.rating ).not_to eql(nil)
|
30
|
+
expect( episode.show.rating_advanced ).not_to eql(nil)
|
31
|
+
expect( episode.show.in_watchlist ).not_to eql(nil)
|
32
|
+
|
33
|
+
expect( episode.episode.watched ).not_to eql(nil)
|
34
|
+
expect( episode.episode.plays ).not_to eql(nil)
|
35
|
+
expect( episode.episode.in_watchlist ).not_to eql(nil)
|
36
|
+
expect( episode.episode.in_collection ).not_to eql(nil)
|
37
|
+
expect( episode.episode.rating ).not_to eql(nil)
|
38
|
+
expect( episode.episode.rating_advanced ).not_to eql(nil)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#shows' do
|
45
|
+
shows = @trakt.calendar.shows
|
46
|
+
expect( shows.class ).to eql(Array)
|
47
|
+
shows.each do |day|
|
48
|
+
day.episodes.each do |episode|
|
49
|
+
expect( episode.show.rating ).not_to eql(nil)
|
50
|
+
expect( episode.show.rating_advanced ).not_to eql(nil)
|
51
|
+
expect( episode.show.in_watchlist ).not_to eql(nil)
|
52
|
+
|
53
|
+
expect( episode.episode.watched ).not_to eql(nil)
|
54
|
+
expect( episode.episode.plays ).not_to eql(nil)
|
55
|
+
expect( episode.episode.in_watchlist ).not_to eql(nil)
|
56
|
+
expect( episode.episode.in_collection ).not_to eql(nil)
|
57
|
+
expect( episode.episode.rating ).not_to eql(nil)
|
58
|
+
expect( episode.episode.rating_advanced ).not_to eql(nil)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'without valid api_key' do
|
65
|
+
before :all do
|
66
|
+
@trakt = Traktr::Client.new(nil)
|
67
|
+
end
|
68
|
+
|
69
|
+
it '#premieres' do
|
70
|
+
expect { @trakt.calendar.premieres }.to raise_error(Traktr::ResponseError)
|
71
|
+
end
|
72
|
+
|
73
|
+
it '#shows' do
|
74
|
+
expect { @trakt.calendar.shows }.to raise_error(Traktr::ResponseError)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Traktr::Comment do
|
4
|
+
context 'POST methods' do
|
5
|
+
before :all do
|
6
|
+
@episode_data = { :title => "Dexter", :year => "2006", :season => "1", :episode => "1", :comment => "Test comment - #{Time.now.to_s}" }
|
7
|
+
@movie_data = { :title => "The Dark Knight Rises", :year => "2012", :comment => "Test comment - #{Time.now.to_s}" }
|
8
|
+
@show_data = { :title => "Dexter", :year => "2006", :comment => "Test comment - #{Time.now.to_s}" }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'with valid api_key and auth credentials', :misbehaving => true do
|
12
|
+
before :all do
|
13
|
+
@trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
14
|
+
end
|
15
|
+
|
16
|
+
it '#episode' do
|
17
|
+
expect( @trakt.comment.episode(@episode_data).status ).to eql('success')
|
18
|
+
end
|
19
|
+
|
20
|
+
it '#movie' do
|
21
|
+
expect( @trakt.comment.movie(@movie_data).status ).to eql('success')
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#show' do
|
25
|
+
expect( @trakt.comment.show(@show_data).status ).to eql('success')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'without valid api_key' do
|
30
|
+
before :all do
|
31
|
+
@trakt = Traktr::Client.new(nil, USERNAME, PASSWORD)
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#episode' do
|
35
|
+
expect { @trakt.comment.episode(@episode_data) }.to raise_error(Traktr::ResponseError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it '#movie' do
|
39
|
+
expect { @trakt.comment.movie(@movie_data) }.to raise_error(Traktr::ResponseError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it '#show' do
|
43
|
+
expect { @trakt.comment.show(@show_data) }.to raise_error(Traktr::ResponseError)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'without valid auth credentials' do
|
48
|
+
before :all do
|
49
|
+
@trakt = Traktr::Client.new(API_KEY)
|
50
|
+
end
|
51
|
+
|
52
|
+
it '#episode' do
|
53
|
+
expect { @trakt.comment.episode(@episode_data) }.to raise_error(Traktr::ResponseError)
|
54
|
+
end
|
55
|
+
|
56
|
+
it '#movie' do
|
57
|
+
expect { @trakt.comment.movie(@movie_data) }.to raise_error(Traktr::ResponseError)
|
58
|
+
end
|
59
|
+
|
60
|
+
it '#show' do
|
61
|
+
expect { @trakt.comment.show(@show_data) }.to raise_error(Traktr::ResponseError)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/spec/genres_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Traktr::Genres do
|
4
|
+
context 'GET methods' do
|
5
|
+
context 'with valid api_key' do
|
6
|
+
before :all do
|
7
|
+
@trakt = Traktr::Client.new(API_KEY)
|
8
|
+
end
|
9
|
+
|
10
|
+
it '#movies' do
|
11
|
+
expect( @trakt.genres.movies ).to be
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#shows' do
|
15
|
+
expect( @trakt.genres.shows ).to be
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'without valid api_key' do
|
20
|
+
before :all do
|
21
|
+
@trakt = Traktr::Client.new(nil)
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#movies' do
|
25
|
+
expect { @trakt.genres.movies }.to raise_error(Traktr::ResponseError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it '#shows' do
|
29
|
+
expect { @trakt.genres.shows }.to raise_error(Traktr::ResponseError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Traktr::Lists::Items do
|
4
|
+
context 'POST methods' do
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.order_groups_and_examples do |list|
|
7
|
+
list.sort_by { |item| ["#add", "#delete"].index(item.description) }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
client = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
13
|
+
client.lists.add({:name => "rspec private", :privacy => "private"})
|
14
|
+
@slug = "rspec-private"
|
15
|
+
@movie = { :type => "movie", :imdb_id => "tt0372784" }
|
16
|
+
end
|
17
|
+
|
18
|
+
after :all do
|
19
|
+
client = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
20
|
+
client.lists.delete(@slug)
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with valid api_key and auth credentials' do
|
24
|
+
before :all do
|
25
|
+
@trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
26
|
+
end
|
27
|
+
|
28
|
+
it '#add' do
|
29
|
+
expect( @trakt.lists.items.add(@slug, @movie).status ).to eql("success")
|
30
|
+
end
|
31
|
+
|
32
|
+
it '#delete' do
|
33
|
+
expect( @trakt.lists.items.delete(@slug, @movie).status ).to eql("success")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'without valid api_key' do
|
38
|
+
before :all do
|
39
|
+
@trakt = Traktr::Client.new(nil)
|
40
|
+
end
|
41
|
+
|
42
|
+
it '#add' do
|
43
|
+
expect{ @trakt.lists.items.add(@slug, @movie) }.to raise_error(Traktr::ResponseError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it '#delete' do
|
47
|
+
expect{ @trakt.lists.items.delete(@slug, @movie) }.to raise_error(Traktr::ResponseError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'without auth credentials' do
|
52
|
+
before :all do
|
53
|
+
@trakt = Traktr::Client.new(API_KEY)
|
54
|
+
end
|
55
|
+
|
56
|
+
it '#add' do
|
57
|
+
expect{ @trakt.lists.items.add(@slug, @movie) }.to raise_error(Traktr::ResponseError)
|
58
|
+
end
|
59
|
+
|
60
|
+
it '#delete' do
|
61
|
+
expect{ @trakt.lists.items.delete(@slug, @movie) }.to raise_error(Traktr::ResponseError)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/spec/lists_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Traktr::Lists do
|
4
|
+
context 'POST methods' do
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.order_groups_and_examples do |list|
|
7
|
+
list.sort_by { |item| ["#add", "#update", "#delete"].index(item.description) }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
context 'with valid api_key and auth credentials' do
|
11
|
+
before :all do
|
12
|
+
@trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
13
|
+
end
|
14
|
+
|
15
|
+
it '#add' do
|
16
|
+
expect( @trakt.lists.add( {:name=>"rspec private", :privacy=>"private"} ).status ).to eql("success")
|
17
|
+
end
|
18
|
+
|
19
|
+
it '#update' do
|
20
|
+
expect( @trakt.lists.update("rspec-private", {:name=>"rspec private 2"} ).status ).to eql("success")
|
21
|
+
end
|
22
|
+
|
23
|
+
it '#delete' do
|
24
|
+
expect( @trakt.lists.delete("rspec-private-2").status ).to eql("success")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'without valid api_key' do
|
29
|
+
before :all do
|
30
|
+
@trakt = Traktr::Client.new(nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
it '#add' do
|
34
|
+
expect{ @trakt.lists.add( {:name=>"rspec private", :privacy=>"private"} ) }.to raise_error(Traktr::ResponseError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it '#update' do
|
38
|
+
expect{ @trakt.lists.update("rspec-private", {:name=>"rspec private 2"} ) }.to raise_error(Traktr::ResponseError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it '#delete' do
|
42
|
+
expect{ @trakt.lists.delete("rspec-private-2") }.to raise_error(Traktr::ResponseError)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'without auth credentials' do
|
47
|
+
before :all do
|
48
|
+
@trakt = Traktr::Client.new(API_KEY)
|
49
|
+
end
|
50
|
+
|
51
|
+
it '#add' do
|
52
|
+
expect{ @trakt.lists.add( {:name=>"rspec private", :privacy=>"private"} ) }.to raise_error(Traktr::ResponseError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it '#update' do
|
56
|
+
expect{ @trakt.lists.update("rspec-private", {:name=>"rspec private 2"} ) }.to raise_error(Traktr::ResponseError)
|
57
|
+
end
|
58
|
+
|
59
|
+
it '#delete' do
|
60
|
+
expect{ @trakt.lists.delete("rspec-private-2") }.to raise_error(Traktr::ResponseError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/spec/movie_spec.rb
CHANGED
@@ -26,6 +26,10 @@ describe Traktr::Movie do
|
|
26
26
|
it '#related' do
|
27
27
|
expect( @trakt.movie.related('the-dark-knight-2008').size ).to eql(10)
|
28
28
|
end
|
29
|
+
|
30
|
+
it '#stats' do
|
31
|
+
expect( @trakt.movie.stats('the-dark-knight-2008').class ).to eql(Mash)
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
context 'without valid api_key' do
|
@@ -52,6 +56,10 @@ describe Traktr::Movie do
|
|
52
56
|
it '#related' do
|
53
57
|
expect { @trakt.movie.related('the-dark-knight-2008') }.to raise_error(Traktr::ResponseError)
|
54
58
|
end
|
59
|
+
|
60
|
+
it '#stats' do
|
61
|
+
expect { @trakt.movie.stats('the-dark-knight-2008').class }.to raise_error(Traktr::ResponseError)
|
62
|
+
end
|
55
63
|
end
|
56
64
|
end
|
57
65
|
context 'POST methods' do
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Traktr::Network do
|
4
|
+
context 'POST methods' do
|
5
|
+
context 'with valid api_key and auth credentials' do
|
6
|
+
before :all do
|
7
|
+
@trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
8
|
+
@trakt2 = Traktr::Client.new(API_KEY_2, USERNAME_2, PASSWORD_2)
|
9
|
+
end
|
10
|
+
|
11
|
+
it '#approve' do
|
12
|
+
@trakt.network.follow( USERNAME_2 )
|
13
|
+
expect( @trakt2.network.approve( USERNAME ).status ).to eql("success")
|
14
|
+
expect( @trakt.network.unfollow( USERNAME_2 ).status ).to eql("success")
|
15
|
+
end
|
16
|
+
|
17
|
+
it '#deny' do
|
18
|
+
expect( @trakt.network.follow( USERNAME_2 ).status ).to eql("success")
|
19
|
+
expect( @trakt2.network.deny( USERNAME ).status ).to eql("success")
|
20
|
+
end
|
21
|
+
|
22
|
+
it '#follow' do
|
23
|
+
expect( @trakt.network.follow( USERNAME_2 ).status ).to eql("success")
|
24
|
+
expect( @trakt2.network.deny( USERNAME ).status ).to eql("success")
|
25
|
+
end
|
26
|
+
|
27
|
+
it '#requests' do
|
28
|
+
@trakt.network.follow( USERNAME_2 )
|
29
|
+
requests = @trakt2.network.requests
|
30
|
+
expect( requests.size ).to eql(1)
|
31
|
+
expect( requests[0].username ).to eql( USERNAME )
|
32
|
+
expect( @trakt.network.unfollow( USERNAME_2 ).status ).to eql("success")
|
33
|
+
end
|
34
|
+
|
35
|
+
it '#unfollow' do
|
36
|
+
expect( @trakt.network.follow( USERNAME_2 ).status ).to eql("success")
|
37
|
+
expect( @trakt2.network.approve( USERNAME ).status ).to eql("success")
|
38
|
+
expect( @trakt.network.unfollow( USERNAME_2 ).status ).to eql("success")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'without valid api_key' do
|
43
|
+
before :all do
|
44
|
+
@trakt = Traktr::Client.new(nil)
|
45
|
+
end
|
46
|
+
|
47
|
+
it '#approve' do
|
48
|
+
expect{ @trakt.network.approve( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it '#deny' do
|
52
|
+
expect{ @trakt.network.deny( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it '#follow' do
|
56
|
+
expect{ @trakt.network.follow( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
57
|
+
end
|
58
|
+
|
59
|
+
it '#requests' do
|
60
|
+
expect{ @trakt.network.requests }.to raise_error(Traktr::ResponseError)
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#unfollow' do
|
64
|
+
expect{ @trakt.network.unfollow( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'without auth credentials' do
|
69
|
+
before :all do
|
70
|
+
@trakt = Traktr::Client.new(API_KEY)
|
71
|
+
end
|
72
|
+
|
73
|
+
it '#approve' do
|
74
|
+
expect{ @trakt.network.approve( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
75
|
+
end
|
76
|
+
|
77
|
+
it '#deny' do
|
78
|
+
expect{ @trakt.network.deny( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
79
|
+
end
|
80
|
+
|
81
|
+
it '#follow' do
|
82
|
+
expect{ @trakt.network.follow( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
83
|
+
end
|
84
|
+
|
85
|
+
it '#requests' do
|
86
|
+
expect{ @trakt.network.requests }.to raise_error(Traktr::ResponseError)
|
87
|
+
end
|
88
|
+
|
89
|
+
it '#unfollow' do
|
90
|
+
expect{ @trakt.network.unfollow( USERNAME_2 ) }.to raise_error(Traktr::ResponseError)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/spec/rate_spec.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Traktr::Rate do
|
4
|
+
context 'POST methods' do
|
5
|
+
before :all do
|
6
|
+
@episode = { :tvdb_id => 213221, :title => "Portlandia", :year => 2011, :season => 1, :episode => 1, :rating => 9 }
|
7
|
+
@movie = { :imdb_id => "tt0082971", :title => "Indiana Jones and the Raiders of the Lost Ark", :year => 1981, :rating => 9 }
|
8
|
+
@show = { :tvdb_id => 213221, :title => "Portlandia", :year => 2011, :rating => 9 }
|
9
|
+
|
10
|
+
@episode_unrate = { :tvdb_id => 213221, :title => "Portlandia", :year => 2011, :season => 1, :episode => 1, :rating => 0 }
|
11
|
+
@movie_unrate = { :imdb_id => "tt0082971", :title => "Indiana Jones and the Raiders of the Lost Ark", :year => 1981, :rating => 0 }
|
12
|
+
@show_unrate = { :tvdb_id => 213221, :title => "Portlandia", :year => 2011, :rating => 0 }
|
13
|
+
end
|
14
|
+
context 'with valid api_key and auth credentials' do
|
15
|
+
before :all do
|
16
|
+
@trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
|
17
|
+
end
|
18
|
+
|
19
|
+
it '#episode' do
|
20
|
+
expect( @trakt.rate.episode( @episode ).status ).to eql("success")
|
21
|
+
expect( @trakt.rate.episode( @episode_unrate ).status ).to eql("success")
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#episodes' do
|
25
|
+
expect( @trakt.rate.episodes( [@episode] ).status ).to eql("success")
|
26
|
+
expect( @trakt.rate.episodes( [@episode_unrate] ).status ).to eql("success")
|
27
|
+
end
|
28
|
+
|
29
|
+
it '#movie' do
|
30
|
+
expect( @trakt.rate.movie( @movie ).status ).to eql("success")
|
31
|
+
expect( @trakt.rate.movie( @movie_unrate ).status ).to eql("success")
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#movies' do
|
35
|
+
expect( @trakt.rate.movies( [@movie] ).status ).to eql("success")
|
36
|
+
expect( @trakt.rate.movies( [@movie_unrate] ).status ).to eql("success")
|
37
|
+
end
|
38
|
+
|
39
|
+
it '#show' do
|
40
|
+
expect( @trakt.rate.show( @show ).status ).to eql("success")
|
41
|
+
expect( @trakt.rate.show( @show_unrate ).status ).to eql("success")
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#shows' do
|
45
|
+
expect( @trakt.rate.shows( [@show] ).status ).to eql("success")
|
46
|
+
expect( @trakt.rate.shows( [@show_unrate] ).status ).to eql("success")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'without valid api_key' do
|
51
|
+
before :all do
|
52
|
+
@trakt = Traktr::Client.new(nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
it '#episode' do
|
56
|
+
expect{ @trakt.rate.episode( @episode ) }.to raise_error(Traktr::ResponseError)
|
57
|
+
end
|
58
|
+
|
59
|
+
it '#episodes' do
|
60
|
+
expect{ @trakt.rate.episodes( [@episode] ) }.to raise_error(Traktr::ResponseError)
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#movie' do
|
64
|
+
expect{ @trakt.rate.movie( @movie ) }.to raise_error(Traktr::ResponseError)
|
65
|
+
end
|
66
|
+
|
67
|
+
it '#movies' do
|
68
|
+
expect{ @trakt.rate.movies( [@movie] ) }.to raise_error(Traktr::ResponseError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it '#show' do
|
72
|
+
expect{ @trakt.rate.show( @show ) }.to raise_error(Traktr::ResponseError)
|
73
|
+
end
|
74
|
+
|
75
|
+
it '#shows' do
|
76
|
+
expect{ @trakt.rate.shows( [@show] ) }.to raise_error(Traktr::ResponseError)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'without auth credentials' do
|
81
|
+
before :all do
|
82
|
+
@trakt = Traktr::Client.new(API_KEY)
|
83
|
+
end
|
84
|
+
|
85
|
+
it '#episode' do
|
86
|
+
expect{ @trakt.rate.episode( @episode ) }.to raise_error(Traktr::ResponseError)
|
87
|
+
end
|
88
|
+
|
89
|
+
it '#episodes' do
|
90
|
+
expect{ @trakt.rate.episodes( [@episode] ) }.to raise_error(Traktr::ResponseError)
|
91
|
+
end
|
92
|
+
|
93
|
+
it '#movie' do
|
94
|
+
expect{ @trakt.rate.movie( @movie ) }.to raise_error(Traktr::ResponseError)
|
95
|
+
end
|
96
|
+
|
97
|
+
it '#movies' do
|
98
|
+
expect{ @trakt.rate.movies( [@movie] ) }.to raise_error(Traktr::ResponseError)
|
99
|
+
end
|
100
|
+
|
101
|
+
it '#show' do
|
102
|
+
expect{ @trakt.rate.show( @show ) }.to raise_error(Traktr::ResponseError)
|
103
|
+
end
|
104
|
+
|
105
|
+
it '#shows' do
|
106
|
+
expect{ @trakt.rate.shows( [@show] ) }.to raise_error(Traktr::ResponseError)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|