Skip to content
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 Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions restpack_serializer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 4 additions & 4 deletions spec/serializable/paging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions spec/serializable/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/serializable/serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 } }
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/serializable/side_loading/belongs_to_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/serializable/side_loading/has_and_belongs_many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/serializable/side_loading/has_many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] }
Expand Down
4 changes: 2 additions & 2 deletions spec/serializable/side_loading/side_loading_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion spec/serializable/single_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions spec/support/factory.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
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)
end
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)
end
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])
Expand All @@ -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)
Expand All @@ -51,7 +51,7 @@
end

factory :payment, class: MyApp::Payment do
amount 999
amount { 999 }
artist
fan
end
Expand Down