Permalink
Browse files

FactoryGirl 2.0 API is quite different. Adjust adapter to use correct…

… behavior depending on whether new FactoryGirl API is present.
  • Loading branch information...
1 parent ecb6dfc commit 787712d99e48374adc354a73c12b45e59afc596a @aepstein aepstein committed with Jul 13, 2011
Showing with 17 additions and 3 deletions.
  1. +17 −3 lib/pickle/adapter.rb
View
@@ -106,15 +106,29 @@ def create(attrs = {})
# factory-girl adapter
class FactoryGirl < Adapter
def self.factories
- (::Factory.factories.values rescue []).map {|factory| new(factory)}
+ if defined? ::FactoryGirl
+ factories = []
+ ::FactoryGirl.factories.each {|v| factories << new(v)}
+ factories
+ else
+ (::Factory.factories.values rescue []).map {|factory| new(factory)}
+ end
end
def initialize(factory)
- @klass, @name = factory.build_class, factory.factory_name.to_s
+ if defined? ::FactoryGirl
+ @klass, @name = factory.build_class, factory.name.to_s
+ else
+ @klass, @name = factory.build_class, factory.factory_name.to_s
+ end
end
def create(attrs = {})
- Factory(@name, attrs)
+ if defined? ::FactoryGirl
+ ::FactoryGirl.create(@name, attrs)
+ else
+ Factory(@name, attrs)
+ end
end
end

0 comments on commit 787712d

Please sign in to comment.