thegamesdb 1.1.2 → 2.0.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/.github/workflows/master.yml +26 -0
- data/.github/workflows/rubocop.yml +20 -0
- data/.rubocop.yml +39 -0
- data/CHANGELOG.md +42 -0
- data/Gemfile +2 -0
- data/README.md +313 -52
- data/Rakefile +3 -0
- data/lib/thegamesdb.rb +115 -215
- data/lib/thegamesdb/developers.rb +17 -0
- data/lib/thegamesdb/games.rb +130 -0
- data/lib/thegamesdb/genres.rb +13 -0
- data/lib/thegamesdb/images.rb +7 -0
- data/lib/thegamesdb/platforms.rb +106 -0
- data/lib/thegamesdb/publishers.rb +15 -0
- data/lib/thegamesdb/version.rb +3 -1
- data/test/client_test.rb +16 -0
- data/test/developers_test.rb +16 -0
- data/test/games_test.rb +92 -42
- data/test/genres_test.rb +16 -0
- data/test/platform_test.rb +85 -51
- data/test/publishers_test.rb +16 -0
- data/test/test_helper.rb +3 -2
- data/thegamesdb.gemspec +14 -9
- metadata +23 -8
- data/.travis.yml +0 -24
- data/lib/thegamesdb/config.rb +0 -9
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamesdb
|
4
|
+
# Genres related API Endpoints
|
5
|
+
module Genres
|
6
|
+
# Fetches genres list
|
7
|
+
def genres
|
8
|
+
url = 'Genres'
|
9
|
+
data = perform_request(url)
|
10
|
+
data['data']['genres'].map { |_id, genre| genre }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamesdb
|
4
|
+
# Platforms related API Endpoints
|
5
|
+
module Platforms
|
6
|
+
# Method for listing platforms
|
7
|
+
#
|
8
|
+
# @see https://api.thegamesdb.net/#/Platforms/Platforms
|
9
|
+
#
|
10
|
+
# @return [Array] Array of Hashes with platforms info
|
11
|
+
#
|
12
|
+
def platforms
|
13
|
+
url = 'Platforms'
|
14
|
+
params = { fields:
|
15
|
+
'icon,console,controller,developer,manufacturer,media,cpu,memory,graphics,sound,maxcontrollers,'\
|
16
|
+
'display,overview,youtube' }
|
17
|
+
data = perform_request(url, params)
|
18
|
+
|
19
|
+
data['data']['platforms'].map do |p|
|
20
|
+
symbolize_keys(p.last)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# This API feature returns a set of metadata and artwork data for a specified Platform ID.
|
25
|
+
#
|
26
|
+
# @see https://api.thegamesdb.net/#/Platforms/PlatformsByPlatformID
|
27
|
+
#
|
28
|
+
# @param id [Integer|String] The numeric ID of the platform in the GamesDB
|
29
|
+
# database or a String with comma delimited list of Ids.
|
30
|
+
#
|
31
|
+
# @return [Hash|Array] Returns a Hash when there's one result or an Array of
|
32
|
+
# Hashes when there's more than one
|
33
|
+
#
|
34
|
+
def platforms_by_id(id)
|
35
|
+
url = 'Platforms/ByPlatformID'
|
36
|
+
params = {
|
37
|
+
id: id,
|
38
|
+
fields:
|
39
|
+
'icon,console,controller,developer,manufacturer,media,cpu,memory,graphics,sound,maxcontrollers,' \
|
40
|
+
'display,overview,youtube'
|
41
|
+
}
|
42
|
+
data = perform_request(url, params)
|
43
|
+
|
44
|
+
platform_api_response(data)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Fetches platforms by name
|
48
|
+
#
|
49
|
+
# @see https://api.thegamesdb.net/#/Platforms/PlatformsByPlatformName
|
50
|
+
#
|
51
|
+
# @param name [String] Platform name (Required)
|
52
|
+
#
|
53
|
+
# @return [Hash|Array] Returns a Hash when there's one result or an Array of
|
54
|
+
# Hashes when there's more than one
|
55
|
+
def platforms_by_name(name)
|
56
|
+
url = 'Platforms/ByPlatformName'
|
57
|
+
params = {
|
58
|
+
name: name,
|
59
|
+
fields:
|
60
|
+
'icon,console,controller,developer,manufacturer,media,cpu,memory,graphics,sound,maxcontrollers,display,' \
|
61
|
+
'overview,youtube'
|
62
|
+
}
|
63
|
+
data = perform_request(url, params)
|
64
|
+
|
65
|
+
platform_api_response(data)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Fetch platform(s) images by platform(s) id
|
69
|
+
#
|
70
|
+
# @see https://api.thegamesdb.net/#/Platforms/PlatformsImages
|
71
|
+
#
|
72
|
+
# @param platforms_id [Integer|String] The numeric ID of the platform in the GamesDB
|
73
|
+
# database or a String with comma delimited list of Ids. (Required)
|
74
|
+
# @param filter [String] options: 'fanart', 'banner', 'boxart' (supports
|
75
|
+
# comma delimited list)
|
76
|
+
# @param page [Integer]
|
77
|
+
#
|
78
|
+
# @return Array of Hashes
|
79
|
+
def platform_images(platforms_id, args = {})
|
80
|
+
url = 'Platforms/Images'
|
81
|
+
args['filter[type]'] = args.delete(:type) if args[:type]
|
82
|
+
args = args.merge({ platforms_id: platforms_id })
|
83
|
+
data = perform_request(url, args)
|
84
|
+
data['data']['images'].values.flatten
|
85
|
+
end
|
86
|
+
|
87
|
+
# Auxiliary method to return either one hash when there's only one result or
|
88
|
+
# an Array of Hashes for several results
|
89
|
+
def platform_api_response(data)
|
90
|
+
return [] if data['data']['count'].zero?
|
91
|
+
|
92
|
+
platforms = data['data']['platforms']
|
93
|
+
|
94
|
+
response = case platforms
|
95
|
+
when Hash
|
96
|
+
platforms.map { |_k, platform| symbolize_keys(platform) }
|
97
|
+
when Array
|
98
|
+
platforms.map { |platform| symbolize_keys(platform) }
|
99
|
+
end
|
100
|
+
|
101
|
+
return response.first if response.count == 1
|
102
|
+
|
103
|
+
response
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamesdb
|
4
|
+
# Publishers related API Endpoints
|
5
|
+
module Publishers
|
6
|
+
def publishers
|
7
|
+
url = 'Publishers'
|
8
|
+
|
9
|
+
data = perform_request(url)
|
10
|
+
data['data']['publishers'].map do |_id, publisher|
|
11
|
+
publisher
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/thegamesdb/version.rb
CHANGED
data/test/client_test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './test_helper'
|
4
|
+
|
5
|
+
describe 'Gamesdb - client', :vcr do
|
6
|
+
let(:client) { Gamesdb::Client.new(ENV['GAMESDB_API_KEY']) }
|
7
|
+
|
8
|
+
describe 'client' do
|
9
|
+
it 'should update allowances' do
|
10
|
+
client.games_by_id(1904)
|
11
|
+
monthly = client.remaining_monthly_allowance
|
12
|
+
client.games_by_id(1527)
|
13
|
+
expect(client.remaining_monthly_allowance).must_equal(monthly - 1)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './test_helper'
|
4
|
+
|
5
|
+
describe 'Gamesdb - developers', :vcr do
|
6
|
+
let(:client) { Gamesdb::Client.new(ENV['GAMESDB_API_KEY']) }
|
7
|
+
|
8
|
+
describe 'developers' do
|
9
|
+
it 'should return the developers' do
|
10
|
+
@developers = client.developers
|
11
|
+
|
12
|
+
expect(@developers.count).must_equal 8168
|
13
|
+
expect(@developers.first.keys).must_equal(['id', 'name'])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/test/games_test.rb
CHANGED
@@ -1,75 +1,89 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './test_helper'
|
2
4
|
|
3
5
|
describe 'Gamesdb - games', :vcr do
|
6
|
+
let(:client) { Gamesdb::Client.new(ENV['GAMESDB_API_KEY']) }
|
7
|
+
|
4
8
|
describe 'game' do
|
5
9
|
before do
|
6
|
-
@game =
|
10
|
+
@game = client.games_by_id(109)
|
7
11
|
end
|
8
12
|
|
9
13
|
it 'should have a valid id' do
|
10
|
-
@game[:id].must_be_kind_of Integer
|
11
|
-
@game[:id].must_equal 109
|
14
|
+
expect(@game[:id]).must_be_kind_of Integer
|
15
|
+
expect(@game[:id]).must_equal 109
|
12
16
|
end
|
13
17
|
|
14
18
|
it 'should have valid fields' do
|
15
|
-
@game[:game_title].must_be_kind_of String
|
16
|
-
@game[:game_title].length.wont_be :<, 0
|
19
|
+
expect(@game[:game_title]).must_be_kind_of String
|
20
|
+
expect(@game[:game_title].length).wont_be :<, 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'game by several ids' do
|
25
|
+
it 'should return games for a String of ids' do
|
26
|
+
@games = client.games_by_id('109,108').sort_by { |g| g[:id] }
|
27
|
+
|
28
|
+
expect(@games.count).must_equal 2
|
29
|
+
expect(@games.first[:id]).must_equal 108
|
30
|
+
expect(@games.last[:id]).must_equal 109
|
17
31
|
end
|
18
32
|
end
|
19
33
|
|
20
34
|
describe 'empty game' do
|
21
35
|
before do
|
22
|
-
@game =
|
36
|
+
@game = client.games_by_id(3)
|
23
37
|
end
|
24
38
|
|
25
39
|
it 'should return an empty array' do
|
26
|
-
@game.must_equal []
|
40
|
+
expect(@game).must_equal []
|
27
41
|
end
|
28
42
|
end
|
29
43
|
|
30
44
|
describe 'games by name' do
|
31
45
|
before do
|
32
|
-
@games_list =
|
46
|
+
@games_list = client.games_by_name('turrican')
|
33
47
|
end
|
34
48
|
|
35
49
|
it 'should return a list' do
|
36
50
|
game = @games_list.first
|
37
|
-
game[:id].must_be_kind_of Integer
|
38
|
-
game[:name].must_be_kind_of String
|
39
|
-
game[:platform].must_be_kind_of Integer
|
40
|
-
game[:release_date].must_be_kind_of String
|
51
|
+
expect(game[:id]).must_be_kind_of Integer
|
52
|
+
expect(game[:name]).must_be_kind_of String
|
53
|
+
expect(game[:platform]).must_be_kind_of Integer
|
54
|
+
expect(game[:release_date]).must_be_kind_of String
|
41
55
|
end
|
42
56
|
end
|
43
57
|
|
44
58
|
describe 'games by name pages' do
|
45
59
|
before do
|
46
|
-
@first_page =
|
47
|
-
@second_page =
|
60
|
+
@first_page = client.games_by_name('mario', page: 1)
|
61
|
+
@second_page = client.games_by_name('mario', page: 2)
|
48
62
|
end
|
49
63
|
|
50
64
|
it 'should return games in platform by id' do
|
51
|
-
@first_page.count.wont_be :<, 0
|
52
|
-
@first_page.count.must_equal 20
|
65
|
+
expect(@first_page.count).wont_be :<, 0
|
66
|
+
expect(@first_page.count).must_equal 20
|
53
67
|
end
|
54
68
|
|
55
69
|
it 'should return games in the platform for the second page' do
|
56
|
-
@second_page.count.wont_be :<, 0
|
57
|
-
@second_page.count.must_equal 20
|
58
|
-
(@first_page & @second_page).must_equal []
|
70
|
+
expect(@second_page.count).wont_be :<, 0
|
71
|
+
expect(@second_page.count).must_equal 20
|
72
|
+
expect(@first_page & @second_page).must_equal []
|
59
73
|
end
|
60
74
|
end
|
61
75
|
|
62
76
|
describe 'games by name and platform' do
|
63
77
|
before do
|
64
|
-
@games_list =
|
78
|
+
@games_list = client.games_by_name('mario', platform: 7)
|
65
79
|
end
|
66
80
|
|
67
81
|
it 'should return a list' do
|
68
82
|
@games_list.each do |game|
|
69
|
-
game[:id].must_be_kind_of Integer
|
70
|
-
game[:id].must_be_kind_of Integer
|
71
|
-
game[:name].must_be_kind_of String
|
72
|
-
game[:platform].must_equal 7
|
83
|
+
expect(game[:id]).must_be_kind_of Integer
|
84
|
+
expect(game[:id]).must_be_kind_of Integer
|
85
|
+
expect(game[:name]).must_be_kind_of String
|
86
|
+
expect(game[:platform]).must_equal 7
|
73
87
|
end
|
74
88
|
end
|
75
89
|
end
|
@@ -77,40 +91,76 @@ describe 'Gamesdb - games', :vcr do
|
|
77
91
|
describe 'games art', :vcr do
|
78
92
|
describe 'when most of the art is available' do
|
79
93
|
before do
|
80
|
-
@images =
|
94
|
+
@images = client.games_images('218')
|
81
95
|
end
|
82
96
|
|
83
97
|
it 'should return logo and boxart' do
|
84
|
-
@images[:boxart].count.wont_be :<, 0
|
85
|
-
@images[:logo].must_be_kind_of String
|
86
|
-
@images[:boxart][:front][:url].must_be_kind_of String
|
87
|
-
@images[:boxart][:front][:width].must_be_kind_of String
|
88
|
-
@images[:boxart][:front][:height].must_be_kind_of String
|
89
|
-
@images[:boxart][:front][:resolution].must_be_kind_of String
|
98
|
+
expect(@images[:boxart].count).wont_be :<, 0
|
99
|
+
expect(@images[:logo]).must_be_kind_of String
|
100
|
+
expect(@images[:boxart][:front][:url]).must_be_kind_of String
|
101
|
+
expect(@images[:boxart][:front][:width]).must_be_kind_of String
|
102
|
+
expect(@images[:boxart][:front][:height]).must_be_kind_of String
|
103
|
+
expect(@images[:boxart][:front][:resolution]).must_be_kind_of String
|
90
104
|
end
|
91
105
|
|
92
106
|
it 'should return screenshots' do
|
93
|
-
@images[:screenshot].count.wont_be :<, 0
|
94
|
-
@images[:screenshot].first.must_be_kind_of Hash
|
95
|
-
@images[:screenshot].first[:filename].must_be_kind_of String
|
107
|
+
expect(@images[:screenshot].count).wont_be :<, 0
|
108
|
+
expect(@images[:screenshot].first).must_be_kind_of Hash
|
109
|
+
expect(@images[:screenshot].first[:filename]).must_be_kind_of String
|
96
110
|
end
|
97
111
|
|
98
112
|
it 'should return fanart' do
|
99
|
-
@images[:fanart].count.wont_be :<, 0
|
100
|
-
@images[:fanart].first[:url].must_be_kind_of String
|
101
|
-
@images[:fanart].first[:width].must_be_kind_of String
|
102
|
-
@images[:fanart].first[:height].must_be_kind_of String
|
103
|
-
@images[:fanart].first[:resolution].must_be_kind_of String
|
113
|
+
expect(@images[:fanart].count).wont_be :<, 0
|
114
|
+
expect(@images[:fanart].first[:url]).must_be_kind_of String
|
115
|
+
expect(@images[:fanart].first[:width]).must_be_kind_of String
|
116
|
+
expect(@images[:fanart].first[:height]).must_be_kind_of String
|
117
|
+
expect(@images[:fanart].first[:resolution]).must_be_kind_of String
|
104
118
|
end
|
105
119
|
end
|
106
120
|
|
107
121
|
describe 'when some art is missing' do
|
108
122
|
before do
|
109
|
-
@images =
|
123
|
+
@images = client.games_images(65_238)
|
110
124
|
end
|
111
125
|
|
112
126
|
it 'should return an empty array' do
|
113
|
-
@images.must_be_kind_of Hash
|
127
|
+
expect(@images).must_be_kind_of Hash
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe 'update games' do
|
132
|
+
it 'should return updates' do
|
133
|
+
updates = client.games_update(1)
|
134
|
+
|
135
|
+
expect(updates[:updates].count).must_equal 100
|
136
|
+
expect(updates[:updates].first).must_equal(
|
137
|
+
{
|
138
|
+
'edit_id' => 2,
|
139
|
+
'game_id' => 38_113,
|
140
|
+
'timestamp' => '2018-06-28 16:20:54',
|
141
|
+
'type' => 'boxart',
|
142
|
+
'value' => 'boxart/front/38113-1.jpg'
|
143
|
+
}
|
144
|
+
)
|
145
|
+
expect(updates[:updates].last).must_equal(
|
146
|
+
{
|
147
|
+
'edit_id' => 101,
|
148
|
+
'game_id' => 22_208,
|
149
|
+
'timestamp' => '2018-06-29 02:36:38',
|
150
|
+
'type' => 'rating',
|
151
|
+
'value' => 'E - Everyone'
|
152
|
+
}
|
153
|
+
)
|
154
|
+
expect(updates[:previous_page]).must_be_nil
|
155
|
+
expect(updates[:next_page]).must_equal 2
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should return updates when using a page parameter' do
|
159
|
+
updates = client.games_update(1, { page: 1_000 })
|
160
|
+
|
161
|
+
expect(updates[:updates].count).must_equal 100
|
162
|
+
expect(updates[:previous_page]).must_equal 999
|
163
|
+
expect(updates[:next_page]).must_equal 1001
|
114
164
|
end
|
115
165
|
end
|
116
166
|
end
|
data/test/genres_test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './test_helper'
|
4
|
+
|
5
|
+
describe 'Gamesdb - genres', :vcr do
|
6
|
+
let(:client) { Gamesdb::Client.new(ENV['GAMESDB_API_KEY']) }
|
7
|
+
|
8
|
+
describe 'genres' do
|
9
|
+
it 'should return the genres' do
|
10
|
+
@genres = client.genres
|
11
|
+
|
12
|
+
expect(@genres.count).must_equal 29
|
13
|
+
expect(@genres.min_by { |g| g['id'] }).must_equal({ 'id' => 1, 'name' => 'Action' })
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/test/platform_test.rb
CHANGED
@@ -1,113 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './test_helper'
|
2
4
|
|
3
5
|
describe 'GamesDB - platforms', :vcr do
|
6
|
+
let(:client) { Gamesdb::Client.new(ENV['GAMESDB_API_KEY']) }
|
7
|
+
|
4
8
|
describe 'platforms' do
|
5
9
|
before do
|
6
|
-
@platforms =
|
10
|
+
@platforms = client.platforms
|
7
11
|
end
|
8
12
|
|
9
13
|
it 'should get gaming platforms' do
|
10
|
-
@platforms.count.wont_be :<, 0
|
11
|
-
@platforms.count.must_equal
|
14
|
+
expect(@platforms.count).wont_be :<, 0
|
15
|
+
expect(@platforms.count).must_equal 114
|
12
16
|
end
|
13
17
|
|
14
18
|
it 'should have a valid name' do
|
15
|
-
@platforms[0][:name].must_be_kind_of String
|
19
|
+
expect(@platforms[0][:name]).must_be_kind_of String
|
16
20
|
end
|
17
21
|
|
18
22
|
it 'should have a valid id' do
|
19
|
-
@platforms[0][:id].must_be_kind_of Integer
|
23
|
+
expect(@platforms[0][:id]).must_be_kind_of Integer
|
20
24
|
end
|
21
25
|
|
22
26
|
it 'should have a valid alias' do
|
23
|
-
@platforms[0][:alias].must_be_kind_of String
|
27
|
+
expect(@platforms[0][:alias]).must_be_kind_of String
|
24
28
|
end
|
25
29
|
|
26
30
|
it 'should have valid fields for other stuff' do
|
27
31
|
nes = @platforms.select { |p| p[:id] == 7 }.first
|
28
|
-
nes[:icon].must_be_kind_of String
|
29
|
-
nes[:console].must_be_kind_of String
|
30
|
-
nes[:controller].must_be_kind_of String
|
31
|
-
nes[:developer].must_be_kind_of String
|
32
|
-
nes[:manufacturer].must_be_kind_of String
|
33
|
-
nes[:maxcontrollers].must_be_kind_of String
|
34
|
-
nes[:cpu].must_be_kind_of String
|
35
|
-
nes[:memory].must_be_kind_of String
|
36
|
-
nes[:sound].must_be_kind_of String
|
37
|
-
nes[:display].must_be_kind_of String
|
38
|
-
nes[:overview].must_be_kind_of String
|
32
|
+
expect(nes[:icon]).must_be_kind_of String
|
33
|
+
expect(nes[:console]).must_be_kind_of String
|
34
|
+
expect(nes[:controller]).must_be_kind_of String
|
35
|
+
expect(nes[:developer]).must_be_kind_of String
|
36
|
+
expect(nes[:manufacturer]).must_be_kind_of String
|
37
|
+
expect(nes[:maxcontrollers]).must_be_kind_of String
|
38
|
+
expect(nes[:cpu]).must_be_kind_of String
|
39
|
+
expect(nes[:memory]).must_be_kind_of String
|
40
|
+
expect(nes[:sound]).must_be_kind_of String
|
41
|
+
expect(nes[:display]).must_be_kind_of String
|
42
|
+
expect(nes[:overview]).must_be_kind_of String
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
46
|
describe 'games by platform' do
|
43
47
|
before do
|
44
|
-
platforms =
|
45
|
-
@first_page =
|
46
|
-
@second_page =
|
48
|
+
platforms = client.platforms
|
49
|
+
@first_page = client.games_by_platform_id(platforms[0][:id])
|
50
|
+
@second_page = client.games_by_platform_id(platforms[0][:id], 2)
|
47
51
|
end
|
48
52
|
|
49
53
|
it 'should return games in platform by id' do
|
50
|
-
@first_page.count.wont_be :<, 0
|
51
|
-
@first_page.count.must_equal 20
|
54
|
+
expect(@first_page.count).wont_be :<, 0
|
55
|
+
expect(@first_page.count).must_equal 20
|
52
56
|
end
|
53
57
|
|
54
58
|
it 'should return games in the platform for the second page' do
|
55
|
-
@second_page.count.wont_be :<, 0
|
56
|
-
@second_page.count.must_equal 20
|
57
|
-
(@first_page & @second_page).must_equal []
|
59
|
+
expect(@second_page.count).wont_be :<, 0
|
60
|
+
expect(@second_page.count).must_equal 20
|
61
|
+
expect(@first_page & @second_page).must_equal []
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
65
|
describe 'games by platform parameters' do
|
62
66
|
before do
|
63
|
-
@games1 =
|
64
|
-
@games2 =
|
65
|
-
@games3 =
|
67
|
+
@games1 = client.games_by_platform_id(4950)
|
68
|
+
@games2 = client.games_by_platform_id(4948)
|
69
|
+
@games3 = client.games_by_platform_id('4950,4948')
|
66
70
|
end
|
67
71
|
|
68
72
|
it 'supports comma separated list' do
|
69
|
-
@games1.count.must_equal 20
|
70
|
-
@games2.count.must_equal 1
|
71
|
-
@games3.count.must_equal 20
|
73
|
+
expect(@games1.count).must_equal 20
|
74
|
+
expect(@games2.count).must_equal 1
|
75
|
+
expect(@games3.count).must_equal 20
|
72
76
|
|
73
|
-
(@games3 - @games1).must_equal @games2
|
77
|
+
expect(@games3 - @games1).must_equal @games2
|
74
78
|
end
|
75
|
-
|
76
79
|
end
|
77
80
|
|
78
81
|
describe 'platform' do
|
79
82
|
describe 'assigning basic info' do
|
80
83
|
before do
|
81
|
-
@platform =
|
84
|
+
@platform = client.platforms_by_id(6)
|
82
85
|
end
|
83
86
|
|
84
87
|
it 'should return valid platform info' do
|
85
|
-
@platform[:name].must_equal 'Super Nintendo (SNES)'
|
86
|
-
@platform[:overview].must_be_kind_of String
|
87
|
-
@platform[:developer].must_be_kind_of String
|
88
|
-
@platform[:manufacturer].must_equal 'Nintendo'
|
89
|
-
@platform[:cpu].must_be_kind_of String
|
90
|
-
@platform[:memory].must_be_kind_of String
|
91
|
-
@platform[:sound].must_be_kind_of String
|
92
|
-
@platform[:display].must_be_kind_of String
|
88
|
+
expect(@platform[:name]).must_equal 'Super Nintendo (SNES)'
|
89
|
+
expect(@platform[:overview]).must_be_kind_of String
|
90
|
+
expect(@platform[:developer]).must_be_kind_of String
|
91
|
+
expect(@platform[:manufacturer]).must_equal 'Nintendo'
|
92
|
+
expect(@platform[:cpu]).must_be_kind_of String
|
93
|
+
expect(@platform[:memory]).must_be_kind_of String
|
94
|
+
expect(@platform[:sound]).must_be_kind_of String
|
95
|
+
expect(@platform[:display]).must_be_kind_of String
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
96
99
|
describe 'without hardware or images' do
|
97
100
|
before do
|
98
|
-
@platform =
|
101
|
+
@platform = client.platforms_by_id(4916)
|
99
102
|
end
|
100
103
|
|
101
104
|
it 'should return valid platform info' do
|
102
|
-
@platform[:name].must_equal 'Android'
|
103
|
-
@platform[:overview].must_be_kind_of String
|
104
|
-
@platform[:developer].must_be_kind_of String
|
105
|
-
@platform[:manufacturer].must_be_nil
|
106
|
-
@platform[:cpu].must_be_nil
|
107
|
-
@platform[:memory].must_be_nil
|
108
|
-
@platform[:sound].must_be_nil
|
109
|
-
@platform[:display].must_be_nil
|
105
|
+
expect(@platform[:name]).must_equal 'Android'
|
106
|
+
expect(@platform[:overview]).must_be_kind_of String
|
107
|
+
expect(@platform[:developer]).must_be_kind_of String
|
108
|
+
expect(@platform[:manufacturer]).must_be_nil
|
109
|
+
expect(@platform[:cpu]).must_be_nil
|
110
|
+
expect(@platform[:memory]).must_be_nil
|
111
|
+
expect(@platform[:sound]).must_be_nil
|
112
|
+
expect(@platform[:display]).must_be_nil
|
110
113
|
end
|
111
114
|
end
|
112
115
|
end
|
116
|
+
|
117
|
+
describe 'platforms by name' do
|
118
|
+
it 'should return platforms' do
|
119
|
+
@platforms = client.platforms_by_name('Nintendo')
|
120
|
+
|
121
|
+
expect(@platforms.count).must_equal 14
|
122
|
+
names = @platforms.sort_by { |p| p[:name] }.map { |p| p[:name] }
|
123
|
+
expect(names).must_equal [
|
124
|
+
'Nintendo 3DS', 'Nintendo 64', 'Nintendo DS', 'Nintendo Entertainment System (NES)',
|
125
|
+
'Nintendo Game Boy', 'Nintendo Game Boy Advance', 'Nintendo Game Boy Color', 'Nintendo GameCube',
|
126
|
+
'Nintendo Pokémon Mini', 'Nintendo Switch', 'Nintendo Virtual Boy', 'Nintendo Wii', 'Nintendo Wii U',
|
127
|
+
'Super Nintendo (SNES)'
|
128
|
+
]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'platform images' do
|
133
|
+
it 'should return all images for a platform' do
|
134
|
+
@images = client.platform_images(7)
|
135
|
+
|
136
|
+
expect(@images.count).must_equal(10)
|
137
|
+
expect(@images.first.keys).must_equal(['id', 'type', 'filename'])
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should filter image type for a platform' do
|
141
|
+
@images = client.platform_images(7, type: 'boxart')
|
142
|
+
|
143
|
+
expect(@images.count).must_equal(1)
|
144
|
+
expect(@images.first).must_equal({ 'id' => 222, 'type' => 'boxart', 'filename' => 'platform/boxart/7-2.jpg' })
|
145
|
+
end
|
146
|
+
end
|
113
147
|
end
|