lib/generators/katapult/clearance/clearance_generator.rb in katapult-0.3.0 vs lib/generators/katapult/clearance/clearance_generator.rb in katapult-0.4.0
- old
+ new
@@ -17,11 +17,11 @@
rake 'db:migrate' # Clearance must see the users table in the db
end
def install_clearance
insert_into_file 'Gemfile', <<-GEM, before: "gem 'katapult'"
-gem 'clearance', '< 1.14.0' # Has broken InstallGenerator :(
+gem 'clearance'
GEM
run 'bundle install --quiet'
generate 'clearance:install'
end
@@ -120,11 +120,15 @@
CONTENT
end
def add_user_factory
- inject_into_file 'spec/factories/factories.rb', <<-'CONTENT', after: 'FactoryBot.define do'
+ factories_file = 'spec/factories/factories.rb'
+ # Remove empty factory, if it exists
+ gsub_file factories_file, " factory :user\n\n", ''
+
+ inject_into_file factories_file, <<-'CONTENT', before: /end\n\z/
factory :user do
sequence(:email) { |i| "user-#{ i }@example.com" }
password 'password'
end