From f6359cd5684431d31b4eadd28e8eb33f368e787d Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Wed, 20 Feb 2019 15:42:54 -0800 Subject: [PATCH] Use FactoryBot rather than factory-bot-rails --- hydra-access-controls/spec/factories.rb | 58 ++++++++++++------------- hydra-core/hydra-core.gemspec | 1 - hydra-core/spec/factories.rb | 11 ----- hydra-core/spec/models/user_spec.rb | 2 +- hydra-core/spec/spec_helper.rb | 2 - hydra-head.gemspec | 2 +- 6 files changed, 31 insertions(+), 45 deletions(-) delete mode 100644 hydra-core/spec/factories.rb diff --git a/hydra-access-controls/spec/factories.rb b/hydra-access-controls/spec/factories.rb index a65c4d3d0..51e891865 100644 --- a/hydra-access-controls/spec/factories.rb +++ b/hydra-access-controls/spec/factories.rb @@ -11,52 +11,52 @@ end factory :archivist, :parent=>:user do |u| - uid 'archivist1' - password 'archivist1' + uid { 'archivist1' } + password { 'archivist1' } end factory :registered_user, :parent=>:user do |u| - uid 'registered_user' - password 'registered_user' + uid { 'registered_user' } + password { 'registered_user' } end factory :staff, :parent=>:user do |u| - uid 'staff1' - password 'staff1' + uid { 'staff1' } + password { 'staff1' } end factory :student, :parent=>:user do |u| - uid 'student1' - password 'student1' + uid { 'student1' } + password { 'student1' } end factory :joe_creator, :parent=>:user do |u| - uid 'joe_creator' - password 'joe_creator' + uid { 'joe_creator' } + password { 'joe_creator' } end factory :martia_morocco, :parent=>:user do |u| - uid 'martia_morocco' - password 'martia_morocco' + uid { 'martia_morocco' } + password { 'martia_morocco' } end factory :ira_instructor, :parent=>:user do |u| - uid 'ira_instructor' - password 'ira_instructor' + uid { 'ira_instructor' } + password { 'ira_instructor' } end factory :calvin_collaborator, :parent=>:user do |u| - uid 'calvin_collaborator' - password 'calvin_collaborator' + uid { 'calvin_collaborator' } + password { 'calvin_collaborator' } end factory :sara_student, :parent=>:user do |u| - uid 'sara_student' - password 'sara_student' + uid { 'sara_student' } + password { 'sara_student' } end factory :louis_librarian, :parent=>:user do |u| - uid 'louis_librarian' - password 'louis_librarian' + uid { 'louis_librarian' } + password { 'louis_librarian' } end factory :carol_curator, :parent=>:user do |u| - uid 'carol_curator' - password 'carol_curator' + uid { 'carol_curator' } + password { 'carol_curator' } end factory :alice_admin, :parent=>:user do |u| - uid 'alice_admin' - password 'alice_admin' + uid { 'alice_admin' } + password { 'alice_admin' } end # @@ -70,23 +70,23 @@ end factory :default_access_asset, :parent=>:asset do |a| - permissions_attributes [{ name: "joe_creator", access: "edit", type: "person" }] + permissions_attributes { [{ name: "joe_creator", access: "edit", type: "person" }] } end factory :dept_access_asset, :parent=>:asset do |a| - permissions_attributes [{ name: "africana-faculty", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }] + permissions_attributes { [{ name: "africana-faculty", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }] } end factory :group_edit_asset, :parent=>:asset do |a| - permissions_attributes [{ name:"africana-faculty", access: "edit", type: "group" }, {name: "calvin_collaborator", access: "edit", type: "person"}] + permissions_attributes { [{ name:"africana-faculty", access: "edit", type: "group" }, {name: "calvin_collaborator", access: "edit", type: "person"}] } end factory :org_read_access_asset, :parent=>:asset do |a| - permissions_attributes [{ name: "registered", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }] + permissions_attributes { [{ name: "registered", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }] } end factory :open_access_asset, :parent=>:asset do |a| - permissions_attributes [{ name: "public", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }] + permissions_attributes { [{ name: "public", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }] } end end diff --git a/hydra-core/hydra-core.gemspec b/hydra-core/hydra-core.gemspec index 1c4d838f7..70e6c3fe0 100644 --- a/hydra-core/hydra-core.gemspec +++ b/hydra-core/hydra-core.gemspec @@ -21,7 +21,6 @@ Gem::Specification.new do |gem| gem.add_dependency 'hydra-access-controls', version gem.add_dependency "railties", '>= 4.0.0', '< 6' - gem.add_development_dependency 'factory_bot_rails', '~> 4.8.2' gem.add_development_dependency 'rails-controller-testing', '~> 1' gem.add_development_dependency 'rspec-rails', '~> 3.1' gem.add_development_dependency 'sqlite3', '~> 1.3' diff --git a/hydra-core/spec/factories.rb b/hydra-core/spec/factories.rb deleted file mode 100644 index 1b377047b..000000000 --- a/hydra-core/spec/factories.rb +++ /dev/null @@ -1,11 +0,0 @@ -FactoryBot.define do - sequence :email do |n| - "person#{n}@example.com" - end - - factory :user do - email - password 'password' - end - -end diff --git a/hydra-core/spec/models/user_spec.rb b/hydra-core/spec/models/user_spec.rb index 39ab02d78..a42778628 100644 --- a/hydra-core/spec/models/user_spec.rb +++ b/hydra-core/spec/models/user_spec.rb @@ -32,7 +32,7 @@ end describe "#groups" do - let(:user) { FactoryBot.create(:user) } + let(:user) { described_class.new } let(:mock_service) { double } before do user.group_service = mock_service diff --git a/hydra-core/spec/spec_helper.rb b/hydra-core/spec/spec_helper.rb index ccee68a5e..6d41f43a2 100644 --- a/hydra-core/spec/spec_helper.rb +++ b/hydra-core/spec/spec_helper.rb @@ -7,8 +7,6 @@ require 'bundler/setup' require 'rspec/rails' require 'hydra-core' -require "factory_bot" -require "factories" def coverage_needed? ENV['COVERAGE'] || ENV['TRAVIS'] diff --git a/hydra-head.gemspec b/hydra-head.gemspec index a2b17d44b..81156a8da 100644 --- a/hydra-head.gemspec +++ b/hydra-head.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'coveralls' s.add_development_dependency 'engine_cart', '~> 2.1' - s.add_development_dependency 'factory_bot_rails' + s.add_development_dependency 'factory_bot' s.add_development_dependency 'fcrepo_wrapper', '~> 0.6' s.add_development_dependency 'rspec-rails' s.add_development_dependency 'simplecov'