Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Ruby 3.3 to test matrix #25

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '3.0', '3.1', '3.2', 'jruby', 'truffleruby' ]
ruby: [ '3.0', '3.1', '3.2', '3.3', 'jruby', 'truffleruby' ]
name: Ruby ${{ matrix.ruby }}
steps:
- uses: actions/checkout@v2
Expand Down
16 changes: 10 additions & 6 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@

describe 'client' do
it 'should update allowances' do
client.games_by_id(1904)
monthly = client.remaining_monthly_allowance
client.games_by_id(1527)
expect(client.remaining_monthly_allowance).must_equal(monthly - 1)
VCR.use_cassette('should update allowances') do
client.games_by_id(1904)
monthly = client.remaining_monthly_allowance
client.games_by_id(1527)
expect(client.remaining_monthly_allowance).must_equal(monthly - 1)
end
end

describe 'errors' do
let(:client) { Gamesdb::Client.new('invalid_api_key') }

it 'should raise http error' do
assert_raises Gamesdb::Error do
client.games_by_id(1904)
VCR.use_cassette('should raise error') do
assert_raises Gamesdb::Error do
client.games_by_id(1904)
end
end
end
end
Expand Down
8 changes: 5 additions & 3 deletions test/developers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

describe 'developers' do
it 'should return the developers' do
@developers = client.developers
VCR.use_cassette('developers') do
@developers = client.developers

expect(@developers.count.positive?)
expect(@developers.first.keys).must_equal(['id', 'name'])
expect(@developers.count.positive?)
expect(@developers.first.keys).must_equal(['id', 'name'])
end
end
end
end
98 changes: 59 additions & 39 deletions test/games_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

describe 'game' do
before do
@game = client.games_by_id(109)
VCR.use_cassette('games test: games_by_id') do
@game = client.games_by_id(109)
end
end

it 'should have a valid id' do
Expand All @@ -23,17 +25,21 @@

describe 'game by several ids' do
it 'should return games for a String of ids' do
@games = client.games_by_id('109,108').sort_by { |g| g[:id] }
VCR.use_cassette('games test: string of ids') do
@games = client.games_by_id('109,108').sort_by { |g| g[:id] }

expect(@games.count).must_equal 2
expect(@games.first[:id]).must_equal 108
expect(@games.last[:id]).must_equal 109
expect(@games.count).must_equal 2
expect(@games.first[:id]).must_equal 108
expect(@games.last[:id]).must_equal 109
end
end
end

describe 'empty game' do
before do
@game = client.games_by_id(3)
VCR.use_cassette('empty_game') do
@game = client.games_by_id(3)
end
end

it 'should return an empty array' do
Expand All @@ -43,7 +49,9 @@

describe 'games by name' do
before do
@games_list = client.games_by_name('turrican')
VCR.use_cassette('games by name') do
@games_list = client.games_by_name('turrican')
end
end

it 'should return a list' do
Expand All @@ -57,8 +65,10 @@

describe 'games by name pages' do
before do
@first_page = client.games_by_name('mario', page: 1)
@second_page = client.games_by_name('mario', page: 2)
VCR.use_cassette('pages') do
@first_page = client.games_by_name('mario', page: 1)
@second_page = client.games_by_name('mario', page: 2)
end
end

it 'should return games in platform by id' do
Expand All @@ -75,7 +85,9 @@

describe 'games by name and platform' do
before do
@games_list = client.games_by_name('mario', platform: 7)
VCR.use_cassette('games by name and platform') do
@games_list = client.games_by_name('mario', platform: 7)
end
end

it 'should return a list' do
Expand All @@ -91,7 +103,9 @@
describe 'games art', :vcr do
describe 'when most of the art is available' do
before do
@images = client.games_images('218')
VCR.use_cassette('games art') do
@images = client.games_images('218')
end
end

it 'should return logo and boxart' do
Expand Down Expand Up @@ -120,7 +134,9 @@

describe 'when some art is missing' do
before do
@images = client.games_images(65_238)
VCR.use_cassette('games missing art') do
@images = client.games_images(65_238)
end
end

it 'should return an empty array' do
Expand All @@ -130,37 +146,41 @@

describe 'update games' do
it 'should return updates' do
updates = client.games_update(1)

expect(updates[:updates].count).must_equal 100
expect(updates[:updates].first).must_equal(
{
'edit_id' => 2,
'game_id' => 38_113,
'timestamp' => '2018-06-28 15:20:54',
'type' => 'boxart',
'value' => 'boxart/front/38113-1.jpg'
}
)
expect(updates[:updates].last).must_equal(
{
'edit_id' => 101,
'game_id' => 22_208,
'timestamp' => '2018-06-29 01:36:38',
'type' => 'rating',
'value' => 'E - Everyone'
}
)
expect(updates[:previous_page]).must_be_nil
expect(updates[:next_page]).must_equal 2
VCR.use_cassette('game updates') do
updates = client.games_update(1)

expect(updates[:updates].count).must_equal 100
expect(updates[:updates].first).must_equal(
{
'edit_id' => 2,
'game_id' => 38_113,
'timestamp' => '2018-06-28 15:20:54',
'type' => 'boxart',
'value' => 'boxart/front/38113-1.jpg'
}
)
expect(updates[:updates].last).must_equal(
{
'edit_id' => 101,
'game_id' => 22_208,
'timestamp' => '2018-06-29 01:36:38',
'type' => 'rating',
'value' => 'E - Everyone'
}
)
expect(updates[:previous_page]).must_be_nil
expect(updates[:next_page]).must_equal 2
end
end

it 'should return updates when using a page parameter' do
updates = client.games_update(1, { page: 1_000 })
VCR.use_cassette('games updates paging') do
updates = client.games_update(1, { page: 1_000 })

expect(updates[:updates].count).must_equal 100
expect(updates[:previous_page]).must_equal 999
expect(updates[:next_page]).must_equal 1001
expect(updates[:updates].count).must_equal 100
expect(updates[:previous_page]).must_equal 999
expect(updates[:next_page]).must_equal 1001
end
end
end
end
Expand Down
8 changes: 5 additions & 3 deletions test/genres_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

describe 'genres' do
it 'should return the genres' do
@genres = client.genres
VCR.use_cassette('genres') do
@genres = client.genres

expect(@genres.count).must_equal 29
expect(@genres.min_by { |g| g['id'] }).must_equal({ 'id' => 1, 'name' => 'Action' })
expect(@genres.count).must_equal 29
expect(@genres.min_by { |g| g['id'] }).must_equal({ 'id' => 1, 'name' => 'Action' })
end
end
end
end
68 changes: 42 additions & 26 deletions test/platform_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

describe 'platforms' do
before do
@platforms = client.platforms
VCR.use_cassette('platforms') do
@platforms = client.platforms
end
end

it 'should get gaming platforms' do
expect(@platforms.count).wont_be :<, 0
expect(@platforms.count).must_equal 147
expect(@platforms.count).must_equal 150
end

it 'should have a valid name' do
Expand Down Expand Up @@ -45,9 +47,11 @@

describe 'games by platform' do
before do
platforms = client.platforms
@first_page = client.games_by_platform_id(platforms[0][:id])
@second_page = client.games_by_platform_id(platforms[0][:id], 2)
VCR.use_cassette('games by platform') do
platforms = client.platforms
@first_page = client.games_by_platform_id(platforms[0][:id])
@second_page = client.games_by_platform_id(platforms[0][:id], 2)
end
end

it 'should return games in platform by id' do
Expand All @@ -64,9 +68,11 @@

describe 'games by platform parameters' do
before do
@games1 = client.games_by_platform_id(4950)
@games2 = client.games_by_platform_id(4948)
@games3 = client.games_by_platform_id('4950,4948')
VCR.use_cassette('games by platform parameters') do
@games1 = client.games_by_platform_id(4950)
@games2 = client.games_by_platform_id(4948)
@games3 = client.games_by_platform_id('4950,4948')
end
end

it 'supports comma separated list' do
Expand All @@ -81,7 +87,9 @@
describe 'platform' do
describe 'assigning basic info' do
before do
@platform = client.platforms_by_id(6)
VCR.use_cassette('platform basic info') do
@platform = client.platforms_by_id(6)
end
end

it 'should return valid platform info' do
Expand All @@ -98,7 +106,9 @@

describe 'without hardware or images' do
before do
@platform = client.platforms_by_id(4916)
VCR.use_cassette('platform without hardware images') do
@platform = client.platforms_by_id(4916)
end
end

it 'should return valid platform info' do
Expand All @@ -116,32 +126,38 @@

describe 'platforms by name' do
it 'should return platforms' do
@platforms = client.platforms_by_name('Nintendo')

expect(@platforms.count).must_equal 14
names = @platforms.sort_by { |p| p[:name] }.map { |p| p[:name] }
expect(names).must_equal [
'Nintendo 3DS', 'Nintendo 64', 'Nintendo DS', 'Nintendo Entertainment System (NES)',
'Nintendo Game Boy', 'Nintendo Game Boy Advance', 'Nintendo Game Boy Color', 'Nintendo GameCube',
'Nintendo Pokémon Mini', 'Nintendo Switch', 'Nintendo Virtual Boy', 'Nintendo Wii', 'Nintendo Wii U',
'Super Nintendo (SNES)'
]
VCR.use_cassette('platforms by name') do
@platforms = client.platforms_by_name('Nintendo')

expect(@platforms.count).must_equal 14
names = @platforms.sort_by { |p| p[:name] }.map { |p| p[:name] }
expect(names).must_equal [
'Nintendo 3DS', 'Nintendo 64', 'Nintendo DS', 'Nintendo Entertainment System (NES)',
'Nintendo Game Boy', 'Nintendo Game Boy Advance', 'Nintendo Game Boy Color', 'Nintendo GameCube',
'Nintendo Pokémon Mini', 'Nintendo Switch', 'Nintendo Virtual Boy', 'Nintendo Wii', 'Nintendo Wii U',
'Super Nintendo (SNES)'
]
end
end
end

describe 'platform images' do
it 'should return all images for a platform' do
@images = client.platform_images(7)
VCR.use_cassette('all images platform') do
@images = client.platform_images(7)

expect(@images.count).must_equal(10)
expect(@images.first.keys).must_equal(['id', 'type', 'filename'])
expect(@images.count).must_equal(10)
expect(@images.first.keys).must_equal(['id', 'type', 'filename'])
end
end

it 'should filter image type for a platform' do
@images = client.platform_images(7, type: 'boxart')
VCR.use_cassette('filter image type platform') do
@images = client.platform_images(7, type: 'boxart')

expect(@images.count).must_equal(1)
expect(@images.first).must_equal({ 'id' => 222, 'type' => 'boxart', 'filename' => 'platform/boxart/7-2.jpg' })
expect(@images.count).must_equal(1)
expect(@images.first).must_equal({ 'id' => 222, 'type' => 'boxart', 'filename' => 'platform/boxart/7-2.jpg' })
end
end
end
end
8 changes: 5 additions & 3 deletions test/publishers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

describe 'publishers' do
it 'should return publishers' do
publishers = client.publishers
VCR.use_cassette('publishers') do
publishers = client.publishers

expect(publishers.count.positive?)
expect(publishers.first.keys).must_equal(['id', 'name'])
expect(publishers.count.positive?)
expect(publishers.first.keys).must_equal(['id', 'name'])
end
end
end
end
2 changes: 0 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
require 'minitest/reporters'
require 'minitest/spec'
require 'vcr'
require 'minitest-vcr'

Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
MinitestVcr::Spec.configure!

require 'thegamesdb'

Expand Down
2 changes: 1 addition & 1 deletion thegamesdb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']
spec.required_ruby_version = '> 2.7.0'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'byebug' unless defined?(JRUBY_VERSION)
spec.add_development_dependency 'debug' unless defined?(JRUBY_VERSION)
spec.add_development_dependency 'minitest-reporters'
spec.add_development_dependency 'minitest-vcr'
spec.add_development_dependency 'rake'
Expand Down
Loading