goodreads 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.travis.yml +2 -2
- data/Gemfile +2 -2
- data/README.md +18 -18
- data/Rakefile +5 -5
- data/examples/oauth.md +3 -3
- data/goodreads.gemspec +14 -14
- data/lib/goodreads.rb +22 -21
- data/lib/goodreads/client.rb +11 -13
- data/lib/goodreads/client/authorized.rb +1 -3
- data/lib/goodreads/client/authors.rb +5 -5
- data/lib/goodreads/client/books.rb +9 -9
- data/lib/goodreads/client/friends.rb +2 -2
- data/lib/goodreads/client/groups.rb +5 -5
- data/lib/goodreads/client/reviews.rb +12 -13
- data/lib/goodreads/client/shelves.rb +11 -13
- data/lib/goodreads/client/users.rb +3 -3
- data/lib/goodreads/errors.rb +5 -5
- data/lib/goodreads/request.rb +30 -29
- data/lib/goodreads/version.rb +1 -1
- data/spec/authentication_spec.rb +16 -16
- data/spec/client_spec.rb +205 -201
- data/spec/goodreads_spec.rb +31 -31
- data/spec/spec_helper.rb +13 -13
- metadata +8 -8
data/spec/goodreads_spec.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
Goodreads.new.
|
3
|
+
describe "Goodreads" do
|
4
|
+
describe ".new" do
|
5
|
+
it "returns a new client instance" do
|
6
|
+
expect(Goodreads.new).to be_a(Goodreads::Client)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
describe ".configure" do
|
11
|
+
it "sets a global configuration options" do
|
12
|
+
config = Goodreads.configure(api_key: "FOO", api_secret: "BAR")
|
13
|
+
expect(config).to be_a(Hash)
|
14
|
+
expect(config).to have_key(:api_key)
|
15
|
+
expect(config).to have_key(:api_secret)
|
16
|
+
expect(config[:api_key]).to eql("FOO")
|
17
|
+
expect(config[:api_secret]).to eql("BAR")
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
|
22
|
-
|
20
|
+
it "raises ConfigurationError on invalid config parameter" do
|
21
|
+
expect { Goodreads.configure(nil) }
|
22
|
+
.to raise_error(ArgumentError, "Options hash required.")
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
expect { Goodreads.configure("foo") }
|
25
|
+
.to raise_error(ArgumentError, "Options hash required.")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
29
|
+
describe ".configuration" do
|
30
30
|
before do
|
31
|
-
Goodreads.configure(:
|
31
|
+
Goodreads.configure(api_key: "FOO", api_secret: "BAR")
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
it "returns global configuration options" do
|
35
|
+
config = Goodreads.configuration
|
36
|
+
expect(config).to be_a(Hash)
|
37
|
+
expect(config).to have_key(:api_key)
|
38
|
+
expect(config).to have_key(:api_secret)
|
39
|
+
expect(config[:api_key]).to eql("FOO")
|
40
|
+
expect(config[:api_secret]).to eql("BAR")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
44
|
+
describe ".reset_configuration" do
|
45
45
|
before do
|
46
|
-
Goodreads.configure(:
|
46
|
+
Goodreads.configure(api_key: "FOO", api_secret: "BAR")
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it "resets global configuration options" do
|
50
50
|
Goodreads.reset_configuration
|
51
|
-
Goodreads.configuration.
|
51
|
+
expect(Goodreads.configuration).to eql({})
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
2
2
|
|
3
|
-
require
|
3
|
+
require "simplecov"
|
4
4
|
|
5
5
|
SimpleCov.start do
|
6
6
|
add_filter "spec/"
|
7
7
|
add_filter ".bundle"
|
8
8
|
end
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
10
|
+
require "goodreads"
|
11
|
+
require "webmock"
|
12
|
+
require "webmock/rspec"
|
13
13
|
|
14
14
|
def stub_get(path, params, fixture_name)
|
15
|
-
params[:format] =
|
16
|
-
stub_request(:get, api_url(path))
|
17
|
-
with(:
|
18
|
-
to_return(
|
19
|
-
:
|
20
|
-
:
|
15
|
+
params[:format] = "xml"
|
16
|
+
stub_request(:get, api_url(path))
|
17
|
+
.with(query: params)
|
18
|
+
.to_return(
|
19
|
+
status: 200,
|
20
|
+
body: fixture(fixture_name)
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
24
24
|
def stub_with_key_get(path, params, fixture_name)
|
25
|
-
params[:key] =
|
25
|
+
params[:key] = "SECRET_KEY"
|
26
26
|
stub_get(path, params, fixture_name)
|
27
27
|
end
|
28
28
|
|
29
|
-
def fixture_path(file=nil)
|
29
|
+
def fixture_path(file = nil)
|
30
30
|
path = File.expand_path("../fixtures", __FILE__)
|
31
31
|
file.nil? ? path : File.join(path, file)
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goodreads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Sosedoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: hashie
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +159,7 @@ extra_rdoc_files: []
|
|
159
159
|
files:
|
160
160
|
- ".gitignore"
|
161
161
|
- ".rspec"
|
162
|
+
- ".rubocop.yml"
|
162
163
|
- ".travis.yml"
|
163
164
|
- Gemfile
|
164
165
|
- LICENSE
|
@@ -219,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
220
|
version: '0'
|
220
221
|
requirements: []
|
221
222
|
rubyforge_project:
|
222
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.6.13
|
223
224
|
signing_key:
|
224
225
|
specification_version: 4
|
225
226
|
summary: Goodreads API wrapper
|
@@ -244,4 +245,3 @@ test_files:
|
|
244
245
|
- spec/fixtures/user.xml
|
245
246
|
- spec/goodreads_spec.rb
|
246
247
|
- spec/spec_helper.rb
|
247
|
-
has_rdoc:
|