rr_games_radar 1.0.2
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.
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +104 -0
- data/Rakefile +9 -0
- data/games_radar_api.gemspec +28 -0
- data/lib/faraday/raise_http_exception.rb +51 -0
- data/lib/games_radar_api/api.rb +22 -0
- data/lib/games_radar_api/client/cheats.rb +18 -0
- data/lib/games_radar_api/client/developers.rb +9 -0
- data/lib/games_radar_api/client/franchises.rb +9 -0
- data/lib/games_radar_api/client/games.rb +61 -0
- data/lib/games_radar_api/client/genres.rb +9 -0
- data/lib/games_radar_api/client/guides.rb +18 -0
- data/lib/games_radar_api/client/news.rb +44 -0
- data/lib/games_radar_api/client/platforms.rb +9 -0
- data/lib/games_radar_api/client/publishers.rb +9 -0
- data/lib/games_radar_api/client/screenshots.rb +20 -0
- data/lib/games_radar_api/client/videos.rb +18 -0
- data/lib/games_radar_api/client.rb +18 -0
- data/lib/games_radar_api/configuration.rb +51 -0
- data/lib/games_radar_api/connection.rb +32 -0
- data/lib/games_radar_api/error.rb +19 -0
- data/lib/games_radar_api/request.rb +42 -0
- data/lib/games_radar_api/version.rb +3 -0
- data/lib/games_radar_api.rb +26 -0
- data/spec/lib/games_radar_api/client/cheats_spec.rb +33 -0
- data/spec/lib/games_radar_api/client/developers_spec.rb +22 -0
- data/spec/lib/games_radar_api/client/franchises_spec.rb +22 -0
- data/spec/lib/games_radar_api/client/games_spec.rb +68 -0
- data/spec/lib/games_radar_api/client/genres_spec.rb +21 -0
- data/spec/lib/games_radar_api/client/guides_spec.rb +31 -0
- data/spec/lib/games_radar_api/client/news_spec.rb +60 -0
- data/spec/lib/games_radar_api/client/platforms_spec.rb +22 -0
- data/spec/lib/games_radar_api/client/publishers_spec.rb +22 -0
- data/spec/lib/games_radar_api/client/screenshots_spec.rb +29 -0
- data/spec/lib/games_radar_api/client/videos_spec.rb +24 -0
- data/spec/lib/games_radar_api/client_spec.rb +59 -0
- data/spec/lib/games_radar_api/configuration_spec.rb +26 -0
- data/spec/lib/games_radar_api/games_radar_api_spec.rb +7 -0
- data/spec/spec_helper.rb +15 -0
- metadata +203 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/games_radar_api/*.rb'].each do |file|
|
2
|
+
require file
|
3
|
+
end
|
4
|
+
|
5
|
+
module GamesRadarApi
|
6
|
+
extend Configuration
|
7
|
+
|
8
|
+
# Alias for GamesRadarApi::Client.new
|
9
|
+
#
|
10
|
+
# @return [GamesRadarApi::Client]
|
11
|
+
def self.client(options={})
|
12
|
+
GamesRadarApi::Client.new(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Delegate to GamesRadarApi::Client
|
16
|
+
def self.method_missing(method, *args, &block)
|
17
|
+
return super unless client.respond_to?(method)
|
18
|
+
client.send(method, *args, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Delegate to GamesRadarApi::Client
|
22
|
+
def self.respond_to?(method)
|
23
|
+
return client.respond_to?(method) || super
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
3
|
+
|
4
|
+
describe GamesRadarApi::Client::Cheats do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = get_client
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'Cheats List' do
|
11
|
+
it 'should have at least one result' do
|
12
|
+
@client.cheats
|
13
|
+
@client.total_rows.must_be :>, 0
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have a cheat url' do
|
17
|
+
response = @client.cheats
|
18
|
+
response.each do |c|
|
19
|
+
c.url.wont_be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Game Cheats' do
|
26
|
+
it 'should fetch cheats for a specified game' do
|
27
|
+
@client.game_cheats(2008021217411530005)
|
28
|
+
@client.total_rows.must_be :>, 0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Developers do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Developers list' do
|
10
|
+
let(:response) { @client.developers }
|
11
|
+
it 'should have at least one result' do
|
12
|
+
response.size.must_be :>, 0
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return valid developers' do
|
16
|
+
response.first.name.must_equal ' Eyebrow Interactive'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Franchises do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Franchises list' do
|
10
|
+
let(:response) { @client.franchises }
|
11
|
+
it 'should have at least one result' do
|
12
|
+
response.size.must_be :>, 0
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return valid franchises' do
|
16
|
+
response.first.name.us.must_equal '.hack'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Games do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Game List' do
|
10
|
+
it 'should fetch 10 games by default' do
|
11
|
+
response = @client.games
|
12
|
+
response.size.must_equal 10
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should filter by platform' do
|
16
|
+
response = @client.games(:platform=>'ps3')
|
17
|
+
response.each do |g|
|
18
|
+
g.platform.name.must_equal 'PS3'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'Game Detail' do
|
24
|
+
it 'should fetch the correct game' do
|
25
|
+
response = @client.game('16725')
|
26
|
+
response.name.must_equal 'God of War Saga'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return nil for an invalid game' do
|
30
|
+
response = @client.game('34$')
|
31
|
+
response.must_be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "with response.release_date equal nil" do
|
35
|
+
it "should return nil of field release_date" do
|
36
|
+
response = @client.game('894')
|
37
|
+
response.release_date.must_be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return name of platform" do
|
42
|
+
response = @client.game('16725')
|
43
|
+
response.platform.must_equal('PS3')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return name of genre" do
|
47
|
+
response = @client.game('16725')
|
48
|
+
response.genre.must_equal("Action")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'Game Search' do
|
53
|
+
it 'should fetch relevant games' do
|
54
|
+
response = @client.game_search('Darksiders','xbox360')
|
55
|
+
response.each do |g|
|
56
|
+
g.name.downcase.must_include 'darksiders'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should return nil if no games are found' do
|
61
|
+
response = @client.game_search('Darksdiers','xbox360')
|
62
|
+
response.must_be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Genres do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'genres list' do
|
10
|
+
it 'should have at least one result' do
|
11
|
+
response = @client.genres
|
12
|
+
response.size.must_be :>, 0
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
3
|
+
|
4
|
+
describe GamesRadarApi::Client::Guides do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = get_client
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'Guides and Faqs List' do
|
11
|
+
it 'should have at least one result' do
|
12
|
+
@client.guides
|
13
|
+
@client.total_rows.must_be :>, 0
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have a cheat url' do
|
17
|
+
response = @client.guides
|
18
|
+
response.each do |c|
|
19
|
+
c.url.wont_be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Game Guides' do
|
26
|
+
it 'should fetch guides for a specified game' do
|
27
|
+
@client.game_guides(8783).size.must_be :>, 0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::News do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'News list' do
|
10
|
+
it 'should have at least one result' do
|
11
|
+
@client.news
|
12
|
+
@client.total_rows.must_be :>, 0
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'Features List' do
|
17
|
+
|
18
|
+
it 'should fetch 10 features by default' do
|
19
|
+
@client.features.size.must_equal 10
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should allow filtering by game name' do
|
23
|
+
response = @client.features(:game_name=>'d')
|
24
|
+
response.each do |f|
|
25
|
+
f.game.name.downcase[0].must_equal 'd'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'Game News' do
|
32
|
+
it 'should fetch news for a specified game' do
|
33
|
+
@client.game_news(8783)
|
34
|
+
@client.total_rows.must_be :>, 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'Game Reviews' do
|
39
|
+
it 'should fetch reviews for a specified game' do
|
40
|
+
@client.game_reviews(8783)
|
41
|
+
@client.total_rows.must_be :>, 0
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'Game Previews' do
|
46
|
+
it 'should fetch previews for a specified game' do
|
47
|
+
@client.game_previews(8783)
|
48
|
+
@client.total_rows.must_be :>, 0
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'Game Features' do
|
53
|
+
it 'should fetch features for a specified game' do
|
54
|
+
@client.game_features(8783)
|
55
|
+
@client.total_rows.must_be :>, 0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Platforms do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Platforms list' do
|
10
|
+
let(:response) { @client.platforms }
|
11
|
+
it 'should have at least one result' do
|
12
|
+
response.size.must_be :>, 0
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return valid platform' do
|
16
|
+
response.first.name.must_equal '3DS'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Publishers do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Publishers list' do
|
10
|
+
let(:response) { @client.publishers }
|
11
|
+
it 'should have at least one result' do
|
12
|
+
response.size.must_be :>, 0
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return valid publishers' do
|
16
|
+
response.first.name.wont_be_nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Screenshots do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Screenshots List' do
|
10
|
+
it 'should have at least one result' do
|
11
|
+
response = @client.screenshots
|
12
|
+
# Ideally this if statement shouldn't be here, but it's just in place because the screenshot API doesn't work on 28 September 2012
|
13
|
+
if(@client.total_rows > 0)
|
14
|
+
@client.total_rows.must_be :>, 0
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should contain at least one screenshot url' do
|
20
|
+
response = @client.screenshots
|
21
|
+
# Ideally this if statement shouldn't be here, but it's just in place because the screenshot API doesn't work on 28 September 2012
|
22
|
+
if(@client.total_rows > 0)
|
23
|
+
response.images.thumbnail.wont_be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client::Videos do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = get_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Videos List' do
|
10
|
+
it 'should have at least one result' do
|
11
|
+
@client.videos
|
12
|
+
@client.total_rows.must_be :>, 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'Game Videos' do
|
18
|
+
it 'should fetch videos for a specified game' do
|
19
|
+
@client.game_videos(8783)
|
20
|
+
@client.total_rows.must_be :>, 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative '../../../spec/spec_helper'
|
2
|
+
|
3
|
+
describe GamesRadarApi::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@keys = GamesRadarApi::Configuration::VALID_CONFIG_KEYS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'with module configuration' do
|
10
|
+
before do
|
11
|
+
GamesRadarApi.configure do |config|
|
12
|
+
@keys.each do |key|
|
13
|
+
config.send("#{key}=",key)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
GamesRadarApi.reset
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should inherit module configuration' do
|
23
|
+
api = GamesRadarApi.client
|
24
|
+
@keys.each do |key|
|
25
|
+
api.send(key).must_equal key
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'with class configuration' do
|
30
|
+
before do
|
31
|
+
@config = {
|
32
|
+
:api_key => 'ak',
|
33
|
+
:format => 'of',
|
34
|
+
:endpoint => 'ep',
|
35
|
+
:user_agent => 'ua',
|
36
|
+
:method => 'hm',
|
37
|
+
:proxy => 'pr',
|
38
|
+
:adapter => 'ad'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should override module configuration' do
|
43
|
+
api = GamesRadarApi.client
|
44
|
+
@config.each do |key,value|
|
45
|
+
api.send("#{key}=",value)
|
46
|
+
end
|
47
|
+
|
48
|
+
@keys.each do |key|
|
49
|
+
api.send("#{key}").must_equal @config[key]
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../../../spec/spec_helper'
|
2
|
+
|
3
|
+
describe 'Configuration' do
|
4
|
+
|
5
|
+
after do
|
6
|
+
GamesRadarApi.reset
|
7
|
+
end
|
8
|
+
|
9
|
+
GamesRadarApi::Configuration::VALID_CONFIG_KEYS.each do |key|
|
10
|
+
describe "#{key}" do
|
11
|
+
it 'should return the default value' do
|
12
|
+
GamesRadarApi.send(key).must_equal GamesRadarApi::Configuration.const_get("DEFAULT_#{key.upcase}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
GamesRadarApi::Configuration::VALID_CONFIG_KEYS.each do |key|
|
18
|
+
it "should set the #{key}" do
|
19
|
+
GamesRadarApi.configure do |config|
|
20
|
+
config.send("#{key}=",key)
|
21
|
+
GamesRadarApi.send(key).must_equal key
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../lib/games_radar_api'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'turn'
|
5
|
+
|
6
|
+
Turn.config do |c|
|
7
|
+
c.format = :pretty
|
8
|
+
c.trace = nil
|
9
|
+
c.natural = true
|
10
|
+
c.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_client
|
14
|
+
GamesRadarApi.client(:api_key=>'0b6e6ede9f26471fadc548f7b04e7c54')
|
15
|
+
end
|