dima-exe-factory_girl 1.1.5.0 → 1.1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/factory_girl/factory.rb +5 -4
- data/test/factory_test.rb +7 -0
- metadata +1 -1
data/lib/factory_girl/factory.rb
CHANGED
@@ -111,9 +111,10 @@ class Factory
|
|
111
111
|
add_attribute(name, *args, &block)
|
112
112
|
end
|
113
113
|
|
114
|
-
def self.method_missing(*args, &block)
|
115
|
-
|
116
|
-
|
114
|
+
def self.method_missing(chain, *args, &block)
|
115
|
+
name = args[0]
|
116
|
+
chain = chain.to_s
|
117
|
+
options = args.extract_options!
|
117
118
|
factory = Factory.factories[name.to_sym]
|
118
119
|
super(*args, &block) unless factory
|
119
120
|
|
@@ -133,7 +134,7 @@ class Factory
|
|
133
134
|
end
|
134
135
|
|
135
136
|
raise ScopeNotFoundError, "Can't found scope with name '#{chain}'" unless chain.empty?
|
136
|
-
Factory(name.to_sym, assigned)
|
137
|
+
Factory(name.to_sym, assigned.merge(options))
|
137
138
|
end
|
138
139
|
|
139
140
|
# Adds an attribute that builds an association. The associated instance will
|
data/test/factory_test.rb
CHANGED
@@ -504,6 +504,13 @@ class FactoryTest < Test::Unit::TestCase
|
|
504
504
|
assert_equal 1, factory.status
|
505
505
|
assert_equal 1, factory.rotations
|
506
506
|
end
|
507
|
+
|
508
|
+
should "assign scope with options" do
|
509
|
+
factory = Factory.approved_radio(@name, :status => 2, :broadcast => :bogus)
|
510
|
+
assert_equal 1, factory.rotations
|
511
|
+
assert_equal 2, factory.status
|
512
|
+
assert_equal :bogus, factory.broadcast
|
513
|
+
end
|
507
514
|
end
|
508
515
|
|
509
516
|
def self.context_in_directory_with_files(*files)
|