diff --git a/Gemfile b/Gemfile index 82c279b..e46745a 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'memory_profiler', require: false if RUBY_VERSION < "2.2" gem "sqlite3", "~> 1.3.0" -elsif RUBY_VERSION < "2.5" +elsif RUBY_VERSION < "3.1" gem "sqlite3", "~> 1.4.0" gem "term-ansicolor", "< 1.10.3" elsif RUBY_VERSION >= "3.4" diff --git a/restpack_serializer.gemspec b/restpack_serializer.gemspec index 5c7b60c..bc272fc 100644 --- a/restpack_serializer.gemspec +++ b/restpack_serializer.gemspec @@ -17,15 +17,15 @@ Gem::Specification.new do |gem| gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.add_dependency 'activesupport', ['>= 4.0.3', '< 7.2'] - gem.add_dependency 'activerecord', ['>= 4.0.3', '< 7.2'] + gem.add_dependency 'activesupport', ['>= 4.0.3', '< 8.1'] + gem.add_dependency 'activerecord', ['>= 4.0.3', '< 8.1'] gem.add_dependency 'kaminari', ['>= 0.17.0', '< 2.0'] gem.add_development_dependency 'restpack_gem', '~> 0.0.9' gem.add_development_dependency 'rake', '~> 13' gem.add_development_dependency 'guard-rspec', '~> 4.7' - gem.add_development_dependency 'factory_girl', '~> 4.7' - gem.add_development_dependency 'sqlite3', '~> 1.3' + gem.add_development_dependency 'sqlite3', '~> 2.1' + gem.add_development_dependency 'factory_bot', '~> 5.0' gem.add_development_dependency 'database_cleaner' gem.add_development_dependency 'rspec' gem.add_development_dependency 'bump' diff --git a/spec/serializable/paging_spec.rb b/spec/serializable/paging_spec.rb index ba1ffbf..60d9f91 100644 --- a/spec/serializable/paging_spec.rb +++ b/spec/serializable/paging_spec.rb @@ -2,8 +2,8 @@ describe RestPack::Serializer::Paging do before(:each) do - @album1 = FactoryGirl.create(:album_with_songs, song_count: 11) - @album2 = FactoryGirl.create(:album_with_songs, song_count: 7) + @album1 = FactoryBot.create(:album_with_songs, song_count: 11) + @album2 = FactoryBot.create(:album_with_songs, song_count: 7) end context "#page" do @@ -229,8 +229,8 @@ context "with custom scope" do before do - FactoryGirl.create(:album, year: 1930) - FactoryGirl.create(:album, year: 1948) + FactoryBot.create(:album, year: 1930) + FactoryBot.create(:album, year: 1948) end let(:page) { MyApp::AlbumSerializer.page(params, scope) } let(:scope) { MyApp::Album.classic } diff --git a/spec/serializable/resource_spec.rb b/spec/serializable/resource_spec.rb index 55177a7..2fd358b 100644 --- a/spec/serializable/resource_spec.rb +++ b/spec/serializable/resource_spec.rb @@ -2,7 +2,7 @@ describe RestPack::Serializer::Resource do before(:each) do - @album = FactoryGirl.create(:album_with_songs, song_count: 11) + @album = FactoryBot.create(:album_with_songs, song_count: 11) @song = @album.songs.first end @@ -50,7 +50,7 @@ end describe "song with no artist" do - let(:song) { FactoryGirl.create(:song, artist: nil) } + let(:song) { FactoryBot.create(:song, artist: nil) } let(:resource) { MyApp::SongSerializer.resource(id: song.id.to_s) } it "should not have an artist link" do diff --git a/spec/serializable/serializer_spec.rb b/spec/serializable/serializer_spec.rb index e5238e0..d11416a 100644 --- a/spec/serializable/serializer_spec.rb +++ b/spec/serializable/serializer_spec.rb @@ -266,7 +266,7 @@ def custom_attributes let(:serializer) { MyApp::SongSerializer.new } it "includes 'links' data for :belongs_to associations" do - @album1 = FactoryGirl.create(:album_with_songs, song_count: 11) + @album1 = FactoryBot.create(:album_with_songs, song_count: 11) json = serializer.as_json(@album1.songs.first) expect(json[:links]).to eq( artist: @album1.artist_id.to_s, @@ -276,7 +276,7 @@ def custom_attributes end context "with a serializer with has_* associations" do - let(:artist_factory) { FactoryGirl.create :artist_with_fans } + let(:artist_factory) { FactoryBot.create :artist_with_fans } let(:artist_serializer) { MyApp::ArtistSerializer.new } let(:json) { artist_serializer.as_json(artist_factory) } let(:side_load_ids) { artist_has_association.map { |obj| obj.id.to_s } } @@ -302,7 +302,7 @@ def custom_attributes end describe "'has_and_belongs_to_many' associations" do - let(:artist_factory) { FactoryGirl.create :artist_with_stalkers } + let(:artist_factory) { FactoryBot.create :artist_with_stalkers } let(:artist_has_association) { artist_factory.stalkers } it "includes 'links' data when there are associated records" do diff --git a/spec/serializable/side_loading/belongs_to_spec.rb b/spec/serializable/side_loading/belongs_to_spec.rb index 899546a..b7b3a89 100644 --- a/spec/serializable/side_loading/belongs_to_spec.rb +++ b/spec/serializable/side_loading/belongs_to_spec.rb @@ -5,8 +5,8 @@ describe ".belongs_to" do before(:each) do - FactoryGirl.create(:artist_with_albums, album_count: 2) - FactoryGirl.create(:artist_with_albums, album_count: 1) + FactoryBot.create(:artist_with_albums, album_count: 2) + FactoryBot.create(:artist_with_albums, album_count: 1) end let(:side_loads) { MyApp::SongSerializer.side_loads(models, options) } @@ -68,7 +68,7 @@ end context 'without an associated model' do - let!(:b_side) { FactoryGirl.create(:song, album: nil) } + let!(:b_side) { FactoryBot.create(:song, album: nil) } let(:models) { [b_side] } context 'when including :albums' do diff --git a/spec/serializable/side_loading/has_and_belongs_many_spec.rb b/spec/serializable/side_loading/has_and_belongs_many_spec.rb index f67603e..7d2de01 100644 --- a/spec/serializable/side_loading/has_and_belongs_many_spec.rb +++ b/spec/serializable/side_loading/has_and_belongs_many_spec.rb @@ -7,8 +7,8 @@ describe ".has_and_belongs_to_many" do before(:each) do - @artist1 = FactoryGirl.create(:artist_with_stalkers, stalker_count: 2) - @artist2 = FactoryGirl.create(:artist_with_stalkers, stalker_count: 3) + @artist1 = FactoryBot.create(:artist_with_stalkers, stalker_count: 2) + @artist2 = FactoryBot.create(:artist_with_stalkers, stalker_count: 3) end context "with a single model" do diff --git a/spec/serializable/side_loading/has_many_spec.rb b/spec/serializable/side_loading/has_many_spec.rb index 9a24ef2..8b7492d 100644 --- a/spec/serializable/side_loading/has_many_spec.rb +++ b/spec/serializable/side_loading/has_many_spec.rb @@ -7,8 +7,8 @@ describe ".has_many" do before(:each) do - @artist1 = FactoryGirl.create(:artist_with_albums, album_count: 2) - @artist2 = FactoryGirl.create(:artist_with_albums, album_count: 1) + @artist1 = FactoryBot.create(:artist_with_albums, album_count: 2) + @artist2 = FactoryBot.create(:artist_with_albums, album_count: 1) end context "with a single model" do @@ -43,8 +43,8 @@ describe '.has_many through' do context 'when including :fans' do let(:options) { RestPack::Serializer::Options.new(MyApp::ArtistSerializer, "include" => "fans") } - let(:artist_1) { FactoryGirl.create :artist_with_fans } - let(:artist_2) { FactoryGirl.create :artist_with_fans } + let(:artist_1) { FactoryBot.create :artist_with_fans } + let(:artist_2) { FactoryBot.create :artist_with_fans } context "with a single model" do let(:models) { [artist_1] } diff --git a/spec/serializable/side_loading/side_loading_spec.rb b/spec/serializable/side_loading/side_loading_spec.rb index 8b10e0d..e666ccb 100644 --- a/spec/serializable/side_loading/side_loading_spec.rb +++ b/spec/serializable/side_loading/side_loading_spec.rb @@ -3,7 +3,7 @@ describe RestPack::Serializer::SideLoading do context "invalid :include" do before(:each) do - FactoryGirl.create(:song) + FactoryBot.create(:song) end context "an include to an inexistent model" do @@ -19,7 +19,7 @@ context "an include to a model which has not been whitelisted with 'can_include'" do it "raises an exception" do - payment = FactoryGirl.create(:payment) + payment = FactoryBot.create(:payment) exception = RestPack::Serializer::InvalidInclude message = ":payments is not a valid include for MyApp::Artist" diff --git a/spec/serializable/single_spec.rb b/spec/serializable/single_spec.rb index b82e406..30c8f92 100644 --- a/spec/serializable/single_spec.rb +++ b/spec/serializable/single_spec.rb @@ -2,7 +2,7 @@ describe RestPack::Serializer::Single do before(:each) do - @album = FactoryGirl.create(:album_with_songs, song_count: 11) + @album = FactoryBot.create(:album_with_songs, song_count: 11) @song = @album.songs.first end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fdd0a23..ffba060 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'rspec' -require './lib/restpack_serializer' require 'logger' +require './lib/restpack_serializer' require './spec/fixtures/db' require './spec/fixtures/serializers' require './spec/support/factory' @@ -9,10 +9,10 @@ Coveralls::Output.silent = true unless ENV["CI"] Coveralls.wear! -FactoryGirl.find_definitions +FactoryBot.find_definitions RSpec.configure do |config| - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.raise_errors_for_deprecations! config.before(:suite) do diff --git a/spec/support/factory.rb b/spec/support/factory.rb index 8f43ef6..1fd508e 100644 --- a/spec/support/factory.rb +++ b/spec/support/factory.rb @@ -1,12 +1,12 @@ -require 'factory_girl' +require 'factory_bot' -FactoryGirl.define do +FactoryBot.define do factory :artist, class: MyApp::Artist do sequence(:name) { |n| "Artist ##{n}" } sequence(:website) { |n| "http://website#{n}.com/" } factory :artist_with_albums do - transient { album_count 3 } + transient { album_count { 3 } } after(:create) do |artist, evaluator| create_list(:album_with_songs, evaluator.album_count, artist: artist) @@ -14,7 +14,7 @@ end factory :artist_with_fans do - transient { fans_count 3 } + transient { fans_count { 3 } } after(:create) do |artist, evaluator| create_list(:payment, evaluator.fans_count, artist: artist) @@ -22,7 +22,7 @@ end factory :artist_with_stalkers do - transient { stalker_count 2 } + transient { stalker_count { 2 } } after(:create) do |artist, evaluator| create_list(:stalker, evaluator.stalker_count, artists: [artist]) @@ -36,7 +36,7 @@ artist factory :album_with_songs do - transient { song_count 10 } + transient { song_count { 10 } } after(:create) do |album, evaluator| create_list(:song, evaluator.song_count, album: album, artist: album.artist) @@ -51,7 +51,7 @@ end factory :payment, class: MyApp::Payment do - amount 999 + amount { 999 } artist fan end