Permalink
Browse files

Change code style.

  • Loading branch information...
1 parent aa7254c commit b905da2d302eae5ba6147b10163539248febabde @fnando committed Apr 25, 2016
View
@@ -1,5 +1,6 @@
-require "bundler"
-Bundler::GemHelper.install_tasks
+require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new
+
+task default: :spec
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
s.add_dependency "factory_girl", ">= 4.0"
s.add_dependency "activerecord"
s.add_development_dependency "rails"
+ s.add_development_dependency "rake"
+ s.add_development_dependency "bundler"
s.add_development_dependency "rspec-rails"
s.add_development_dependency "mysql2"
s.add_development_dependency "pry-meta"
@@ -36,7 +36,7 @@ def self.connection
def self.run
helper = Object.new.extend(Helpers)
- connection.transaction :requires_new => true do
+ connection.transaction requires_new: true do
preloaders.each do |block|
helper.instance_eval(&block)
end
@@ -8,7 +8,6 @@ class Engine < Rails::Engine
end
initializer "factory_girl-preload" do
-
end
end
end
@@ -15,11 +15,9 @@ def self.included(base)
ActiveRecord::Base.descendants.each do |model|
method_name = model.name.underscore.gsub("/", "_").pluralize
- class_eval <<-RUBY, __FILE__, __LINE__
- def #{method_name}(name)
- factory(name, ::#{model.name})
- end
- RUBY
+ define_method(method_name) do |name|
+ factory(name, model)
+ end
end
end
@@ -8,12 +8,12 @@
end
it "should lazy load all factories, loading only when used" do
- expect(FactoryGirl::Preload.record_ids['User'][:john]).to eq(1)
- expect(FactoryGirl::Preload.factories['User'][:john]).to be_nil
+ expect(FactoryGirl::Preload.record_ids["User"][:john]).to eq(1)
+ expect(FactoryGirl::Preload.factories["User"][:john]).to be_nil
user = users(:john)
- expect(FactoryGirl::Preload.factories['User'][:john]).to eq(user)
+ expect(FactoryGirl::Preload.factories["User"][:john]).to eq(user)
end
it "injects model methods" do

0 comments on commit b905da2

Please sign in to comment.