traktr 0.3.0 → 0.4.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.
@@ -3,74 +3,50 @@ require 'spec_helper'
3
3
  describe Traktr::Show::Season do
4
4
  context 'POST methods' do
5
5
  before :all do
6
- Traktr.api_key = API_KEY
7
- @show = Traktr::Show.summary('dexter')
6
+ trakt = Traktr::Client.new(API_KEY)
7
+ @show = trakt.show.summary('dexter')
8
8
  @season = 1
9
- Traktr.api_key = ''
10
- end
11
-
12
- after :all do
13
- @show = nil
14
- @season = nil
15
9
  end
16
10
 
17
11
  context 'with valid api_key and auth credentials' do
18
12
  before :all do
19
- Traktr.api_key = API_KEY
20
- Traktr.username = USERNAME
21
- Traktr.password = PASSWORD
22
- end
23
-
24
- after :all do
25
- Traktr.api_key = ''
26
- Traktr.username = ''
27
- Traktr.password = ''
13
+ @trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
28
14
  end
29
15
 
30
16
  it '#library' do
31
- expect(Traktr::Show::Season.library(@show, @season).status).to eql('success')
17
+ expect( @trakt.show.season.library(@show, @season).status ).to eql('success')
32
18
  end
33
19
 
34
20
  it '#seen' do
35
- expect(Traktr::Show::Season.seen(@show, @season).status).to eql('success')
21
+ expect( @trakt.show.season.seen(@show, @season).status ).to eql('success')
36
22
  end
37
23
  end
38
24
 
39
25
  context 'without valid api_key' do
40
26
  before :all do
41
- Traktr.username = USERNAME
42
- Traktr.password = PASSWORD
43
- end
44
-
45
- after :all do
46
- Traktr.username = ''
47
- Traktr.password = ''
27
+ @trakt = Traktr::Client.new(nil)
48
28
  end
49
29
 
50
30
  it '#library' do
51
- expect { comments = Traktr::Show::Season.library(@show, @season) }.to raise_error(Traktr::ResponseError)
31
+ expect { @trakt.show.season.library(@show, @season) }.to raise_error(Traktr::ResponseError)
52
32
  end
53
33
 
54
34
  it '#seen' do
55
- expect { summary = Traktr::Show::Season.seen(@show, @season) }.to raise_error(Traktr::ResponseError)
35
+ expect { @trakt.show.season.seen(@show, @season) }.to raise_error(Traktr::ResponseError)
56
36
  end
57
37
  end
58
38
 
59
39
  context 'without valid auth credentials' do
60
40
  before :all do
61
- Traktr.api_key = API_KEY
62
- end
63
-
64
- after :all do
65
- Traktr.api_key = ''
41
+ @trakt = Traktr::Client.new(API_KEY)
66
42
  end
67
43
 
68
44
  it '#library' do
69
- expect { comments = Traktr::Show::Season.library(@show, @season) }.to raise_error(Traktr::ResponseError)
45
+ expect { @trakt.show.season.library(@show, @season) }.to raise_error(Traktr::ResponseError)
70
46
  end
71
47
 
72
48
  it '#seen' do
73
- expect { summary = Traktr::Show::Season.seen(@show, @season) }.to raise_error(Traktr::ResponseError)
49
+ expect { @trakt.show.season.seen(@show, @season) }.to raise_error(Traktr::ResponseError)
74
50
  end
75
51
  end
76
52
  end
@@ -4,217 +4,188 @@ describe Traktr::Show do
4
4
  context 'GET methods' do
5
5
  context 'with valid api_key' do
6
6
  before :all do
7
- Traktr.api_key = API_KEY
8
- end
9
-
10
- after :all do
11
- Traktr.api_key = ''
7
+ @trakt = Traktr::Client.new(API_KEY)
12
8
  end
13
9
 
14
10
  context 'with valid query' do
15
11
  it '#comments' do
16
- comments = Traktr::Show.comments('dexter')
17
- expect(comments.size).to be > 0
12
+ expect( @trakt.show.comments('dexter').size ).to be > 0
18
13
  end
19
14
 
20
15
  it '#season' do
21
- season = Traktr::Show.season('dexter', 1)
22
- expect(season.size).to eql(12)
16
+ expect( @trakt.show.season('dexter', 1).size ).to eql(12)
23
17
  end
24
18
 
25
19
  it '#seasons' do
26
- seasons = Traktr::Show.seasons('dexter')
27
- expect(seasons.size).to eql(9)
20
+ expect( @trakt.show.seasons('dexter').size ).to eql(9)
28
21
  end
29
22
 
30
23
  it '#summary' do
31
- summary = Traktr::Show.summary('dexter')
32
- expect(summary.imdb_id).to eql('tt0773262')
24
+ expect( @trakt.show.summary('dexter').imdb_id ).to eql('tt0773262')
33
25
  end
34
26
 
35
27
  it '#summaries' do
36
- summaries = Traktr::Show.summaries(['dexter', 'the-walking-dead'])
37
- expect(summaries.size).to eql(2)
28
+ expect( @trakt.show.summaries(['dexter', 'the-walking-dead']).size ).to eql(2)
38
29
  end
39
30
 
40
31
  it '#watchingnow' do
41
- watchingnow = Traktr::Show.watchingnow('dexter')
42
- expect(watchingnow.size).to be >= 0
32
+ expect( @trakt.show.watchingnow('dexter').size ).to be >= 0
43
33
  end
44
34
 
45
35
  it '#related' do
46
- related = Traktr::Show.related('dexter')
47
- expect(related.size).to eql(10)
36
+ expect( @trakt.show.related('dexter').size ).to eql(10)
48
37
  end
49
38
  end
50
39
 
51
40
  context 'with invalid query' do
52
41
  it '#comments' do
53
- expect { comments = Traktr::Show.comments('blah') }.to raise_error(Traktr::ResponseError)
42
+ expect { @trakt.show.comments('blah') }.to raise_error(Traktr::ResponseError)
54
43
  end
55
44
 
56
45
  it '#season' do
57
- expect { season = Traktr::Show.season('blah', 1) }.to raise_error(Traktr::ResponseError)
46
+ expect { @trakt.show.season('blah', 1) }.to raise_error(Traktr::ResponseError)
47
+ expect { @trakt.show.season('dexter') }.to raise_error(ArgumentError)
58
48
  end
59
49
 
60
50
  it '#seasons' do
61
- expect { seasons = Traktr::Show.seasons('blah') }.to raise_error(Traktr::ResponseError)
51
+ expect { @trakt.show.seasons('blah') }.to raise_error(Traktr::ResponseError)
62
52
  end
63
53
 
64
54
  it '#summary' do
65
- expect { summary = Traktr::Show.summary('blah') }.to raise_error(Traktr::ResponseError)
55
+ expect { @trakt.show.summary('blah') }.to raise_error(Traktr::ResponseError)
66
56
  end
67
57
 
68
58
  it '#summaries' do
69
- expect { summaries = Traktr::Show.summaries(['blah', 'blah-blah']) }.to raise_error(Traktr::ResponseError)
59
+ expect { @trakt.show.summaries(['blah', 'blah-blah']) }.to raise_error(Traktr::ResponseError)
70
60
  end
71
61
 
72
62
  it '#watchingnow' do
73
- expect { watchingnow = Traktr::Show.watchingnow('blah') }.to raise_error(Traktr::ResponseError)
63
+ expect { @trakt.show.watchingnow('blah') }.to raise_error(Traktr::ResponseError)
74
64
  end
75
65
 
76
66
  it '#related' do
77
- expect { related = Traktr::Show.related('blah') }.to raise_error(Traktr::ResponseError)
67
+ expect { @trakt.show.related('blah') }.to raise_error(Traktr::ResponseError)
78
68
  end
79
69
  end
80
70
 
81
71
  end
82
72
 
83
73
  context 'without valid api_key' do
74
+ before :all do
75
+ @trakt = Traktr::Client.new(nil)
76
+ end
77
+
84
78
  it '#comments' do
85
- expect { comments = Traktr::Show.comments('the-walking-dead') }.to raise_error(Traktr::ResponseError)
79
+ expect { @trakt.show.comments('the-walking-dead') }.to raise_error(Traktr::ResponseError)
86
80
  end
87
81
 
88
82
  it '#season' do
89
- expect { season = Traktr::Show.season('the-walking-dead', 1) }.to raise_error(Traktr::ResponseError)
83
+ expect { @trakt.show.season('the-walking-dead', 1) }.to raise_error(Traktr::ResponseError)
90
84
  end
91
85
 
92
86
  it '#seasons' do
93
- expect { seasons = Traktr::Show.seasons('the-walking-dead') }.to raise_error(Traktr::ResponseError)
87
+ expect { @trakt.show.seasons('the-walking-dead') }.to raise_error(Traktr::ResponseError)
94
88
  end
95
89
 
96
90
  it '#summary' do
97
- expect { summary = Traktr::Show.summary('the-walking-dead') }.to raise_error(Traktr::ResponseError)
91
+ expect { @trakt.show.summary('the-walking-dead') }.to raise_error(Traktr::ResponseError)
98
92
  end
99
93
 
100
94
  it '#summaries' do
101
- expect { summaries = Traktr::Show.summaries(['the-walking-dead', 'dexter']) }.to raise_error(Traktr::ResponseError)
95
+ expect { @trakt.show.summaries(['the-walking-dead', 'dexter']) }.to raise_error(Traktr::ResponseError)
102
96
  end
103
97
 
104
98
  it '#watchingnow' do
105
- expect { watchingnow = Traktr::Show.watchingnow('the-walking-dead') }.to raise_error(Traktr::ResponseError)
99
+ expect { @trakt.show.watchingnow('the-walking-dead') }.to raise_error(Traktr::ResponseError)
106
100
  end
107
101
 
108
102
  it '#related' do
109
- expect { related = Traktr::Show.related('the-walking-dead') }.to raise_error(Traktr::ResponseError)
103
+ expect { @trakt.show.related('the-walking-dead') }.to raise_error(Traktr::ResponseError)
110
104
  end
111
105
  end
112
106
  end
113
107
 
114
108
  context 'POST methods' do
115
109
  before :all do
116
- Traktr.api_key = API_KEY
117
- @show = Traktr::Show.summary('dexter')
118
- Traktr.api_key = ''
119
- end
120
-
121
- after :all do
122
- @show = nil
110
+ trakt = Traktr::Client.new(API_KEY)
111
+ @show = trakt.show.summary('dexter')
123
112
  end
124
113
 
125
114
  context 'with valid api_key and auth credentials' do
126
115
  before :all do
127
- Traktr.api_key = API_KEY
128
- Traktr.username = USERNAME
129
- Traktr.password = PASSWORD
130
- end
131
-
132
- after :all do
133
- Traktr.api_key = ''
134
- Traktr.username = ''
135
- Traktr.password = ''
116
+ @trakt = Traktr::Client.new(API_KEY, USERNAME, PASSWORD)
136
117
  end
137
118
 
138
119
  it '#library' do
139
- expect(Traktr::Show.library(@show).status).to eql('success')
120
+ expect( @trakt.show.library(@show).status ).to eql('success')
140
121
  end
141
122
 
142
123
  it '#unlibrary' do
143
- expect(Traktr::Show.unlibrary(@show).status).to eql('success')
124
+ expect( @trakt.show.unlibrary(@show).status ).to eql('success')
144
125
  end
145
126
 
146
127
  it '#watchlist' do
147
- expect(Traktr::Show.watchlist(@show).status).to eql('success')
128
+ expect( @trakt.show.watchlist(@show).status ).to eql('success')
148
129
  end
149
130
 
150
131
  it '#unwatchlist' do
151
- expect(Traktr::Show.unwatchlist(@show).status).to eql('success')
132
+ expect( @trakt.show.unwatchlist(@show).status ).to eql('success')
152
133
  end
153
134
 
154
135
  it '#seen' do
155
- expect(Traktr::Show.seen(@show).status).to eql('success')
136
+ expect( @trakt.show.seen(@show).status ).to eql('success')
156
137
  end
157
138
  end
158
139
 
159
140
  context 'without valid api_key' do
160
141
  before :all do
161
- Traktr.username = USERNAME
162
- Traktr.password = PASSWORD
163
- end
164
-
165
- after :all do
166
- Traktr.username = ''
167
- Traktr.password = ''
142
+ @trakt = Traktr::Client.new(nil, USERNAME, PASSWORD)
168
143
  end
169
144
 
170
145
  it '#library' do
171
- expect { comments = Traktr::Show.library(@show) }.to raise_error(Traktr::ResponseError)
146
+ expect { @trakt.show.library(@show) }.to raise_error(Traktr::ResponseError)
172
147
  end
173
148
 
174
149
  it '#unlibrary' do
175
- expect { season = Traktr::Show.unlibrary(@show) }.to raise_error(Traktr::ResponseError)
150
+ expect { @trakt.show.unlibrary(@show) }.to raise_error(Traktr::ResponseError)
176
151
  end
177
152
 
178
153
  it '#watchlist' do
179
- expect { seasons = Traktr::Show.watchlist(@show) }.to raise_error(Traktr::ResponseError)
154
+ expect { @trakt.show.watchlist(@show) }.to raise_error(Traktr::ResponseError)
180
155
  end
181
156
 
182
157
  it '#unwatchlist' do
183
- expect { seasons = Traktr::Show.unwatchlist(@show) }.to raise_error(Traktr::ResponseError)
158
+ expect { @trakt.show.unwatchlist(@show) }.to raise_error(Traktr::ResponseError)
184
159
  end
185
160
 
186
161
  it '#seen' do
187
- expect { summary = Traktr::Show.seen(@show) }.to raise_error(Traktr::ResponseError)
162
+ expect { @trakt.show.seen(@show) }.to raise_error(Traktr::ResponseError)
188
163
  end
189
164
  end
190
165
 
191
166
  context 'without valid auth credentials' do
192
167
  before :all do
193
- Traktr.api_key = API_KEY
194
- end
195
-
196
- after :all do
197
- Traktr.api_key = ''
168
+ @trakt = Traktr::Client.new(API_KEY)
198
169
  end
199
170
 
200
171
  it '#library' do
201
- expect { comments = Traktr::Show.library(@show) }.to raise_error(Traktr::ResponseError)
172
+ expect { @trakt.show.library(@show) }.to raise_error(Traktr::ResponseError)
202
173
  end
203
174
 
204
175
  it '#unlibrary' do
205
- expect { season = Traktr::Show.unlibrary(@show) }.to raise_error(Traktr::ResponseError)
176
+ expect { @trakt.show.unlibrary(@show) }.to raise_error(Traktr::ResponseError)
206
177
  end
207
178
 
208
179
  it '#watchlist' do
209
- expect { seasons = Traktr::Show.watchlist(@show) }.to raise_error(Traktr::ResponseError)
180
+ expect { @trakt.show.watchlist(@show) }.to raise_error(Traktr::ResponseError)
210
181
  end
211
182
 
212
183
  it '#unwatchlist' do
213
- expect { seasons = Traktr::Show.unwatchlist(@show) }.to raise_error(Traktr::ResponseError)
184
+ expect { @trakt.show.unwatchlist(@show) }.to raise_error(Traktr::ResponseError)
214
185
  end
215
186
 
216
187
  it '#seen' do
217
- expect { summary = Traktr::Show.seen(@show) }.to raise_error(Traktr::ResponseError)
188
+ expect { @trakt.show.seen(@show) }.to raise_error(Traktr::ResponseError)
218
189
  end
219
190
  end
220
191
  end
@@ -4,31 +4,29 @@ describe Traktr::Shows do
4
4
  context 'GET methods' do
5
5
  context 'with valid api_key' do
6
6
  before :all do
7
- Traktr.api_key = API_KEY
8
- end
9
-
10
- after :all do
11
- Traktr.api_key = ''
7
+ @trakt = Traktr::Client.new(API_KEY)
12
8
  end
13
9
 
14
10
  it '#trending' do
15
- shows = Traktr::Shows.trending
16
- expect(shows.size).to be > 0
11
+ expect( @trakt.shows.trending.size ).to be > 0
17
12
  end
18
13
 
19
14
  it '#updated' do
20
- shows = Traktr::Shows.updated(Time.now - 3600 * 24)
21
- expect(shows.size).to be > 0
15
+ expect( @trakt.shows.updated(Time.now - 3600 * 24).size ).to be > 0
22
16
  end
23
17
  end
24
18
 
25
19
  context 'without valid api_key' do
20
+ before :all do
21
+ @trakt = Traktr::Client.new(nil)
22
+ end
23
+
26
24
  it '#trending' do
27
- expect { Traktr::Shows.trending }.to raise_error(Traktr::ResponseError)
25
+ expect { @trakt.shows.trending }.to raise_error(Traktr::ResponseError)
28
26
  end
29
27
 
30
28
  it '#updated' do
31
- expect { Traktr::Shows.updated(Time.now - 3600 * 24) }.to raise_error(Traktr::ResponseError)
29
+ expect { @trakt.shows.updated(Time.now - 3600 * 24) }.to raise_error(Traktr::ResponseError)
32
30
  end
33
31
  end
34
32
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Traktr::VERSION
9
9
  spec.authors = ["Joe Lanford"]
10
10
  spec.email = ["joe.lanford@gmail.com"]
11
- spec.description = %q{Implementation of the track.tv REST API. See the documentation at http://trakt.tv/api-docs}
12
- spec.summary = %q{Implementation of the track.tv REST API}
11
+ spec.description = %q{Implementation of the trakt.tv REST API. See the documentation at http://trakt.tv/api-docs}
12
+ spec.summary = %q{Implementation of the trakt.tv REST API}
13
13
  spec.homepage = "https://github.com/joelanford/traktr"
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traktr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Lanford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-17 00:00:00.000000000 Z
11
+ date: 2013-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Implementation of the track.tv REST API. See the documentation at http://trakt.tv/api-docs
97
+ description: Implementation of the trakt.tv REST API. See the documentation at http://trakt.tv/api-docs
98
98
  email:
99
99
  - joe.lanford@gmail.com
100
100
  executables: []
@@ -109,7 +109,7 @@ files:
109
109
  - Rakefile
110
110
  - lib/traktr.rb
111
111
  - lib/traktr/account.rb
112
- - lib/traktr/authentication.rb
112
+ - lib/traktr/client.rb
113
113
  - lib/traktr/movie.rb
114
114
  - lib/traktr/movies.rb
115
115
  - lib/traktr/search.rb
@@ -160,7 +160,7 @@ rubyforge_project:
160
160
  rubygems_version: 2.1.1
161
161
  signing_key:
162
162
  specification_version: 4
163
- summary: Implementation of the track.tv REST API
163
+ summary: Implementation of the trakt.tv REST API
164
164
  test_files:
165
165
  - spec/account_spec.rb
166
166
  - spec/movie_spec.rb
@@ -171,3 +171,4 @@ test_files:
171
171
  - spec/show_spec.rb
172
172
  - spec/shows_spec.rb
173
173
  - spec/spec_helper.rb
174
+ has_rdoc: