spec/spec_helper.rb in localtower-0.5.0 vs spec/spec_helper.rb in localtower-1.0.0
- old
+ new
@@ -14,21 +14,27 @@
File.open("#{Rails.root}/db/schema.rb", "w") do |f|
f.write(content_schema)
end
- Dir["#{Rails.root}/app/models/**/*.*"].each { |model_file| File.delete(model_file) }
+ Dir["#{Rails.root}/app/models/**/*.*"]
+ .reject { |file_name| file_name['application_record.rb']}
+ .each { |model_file| File.delete(model_file) }
end
def migration_files
Dir["#{Rails.root}/db/migrate/*"]
end
def last_migration
migration_files.sort.last
end
+def word_in_file?(file, word_or_exp)
+ File.readlines(file).grep(word_or_exp).size > 0
+end
+
#============================
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../dummy/config/environment.rb', __FILE__)
require 'rspec/rails'
@@ -43,16 +49,15 @@
config.mock_with :rspec
config.use_transactional_fixtures = false
config.infer_base_class_for_anonymous_controllers = true
config.order = 123
- # config.order = 'random'
config.before(:suite) do
FactoryBot.find_definitions
end
- config.before(:all) do
+ config.before(:each) do
clean_files
end
config.after(:all) do
clean_files