mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Added default strategy parameter
This commit is contained in:
parent
f7a3ca5001
commit
fb5a506558
3 changed files with 11 additions and 2 deletions
|
@ -174,7 +174,7 @@ class Factory
|
|||
s = Sequence.new(&block)
|
||||
add_attribute(name) { s.next }
|
||||
end
|
||||
|
||||
|
||||
# Generates and returns a Hash of attributes from this factory. Attributes
|
||||
# can be individually overridden by passing in a Hash of attribute => value
|
||||
# pairs.
|
||||
|
|
|
@ -366,6 +366,15 @@ factory = Factory.new(:post)
|
|||
returns('result')
|
||||
assert_equal 'result', Factory.stub(@name, :attr => 'value')
|
||||
end
|
||||
|
||||
should "use default strategy option as Factory.default_strategy" do
|
||||
@factory.stubs(:default_strategy).returns(:create)
|
||||
@factory.
|
||||
expects(:run).
|
||||
with(Factory::Proxy::Create, :attr => 'value').
|
||||
returns('result')
|
||||
assert_equal 'result', Factory.default_strategy(@name, :attr => 'value')
|
||||
end
|
||||
|
||||
should "use the default strategy for the global Factory method" do
|
||||
@factory.stubs(:default_strategy).returns(:create)
|
||||
|
|
|
@ -131,7 +131,7 @@ class IntegrationTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
context "an instance generated by a factory with a custom class name" do
|
||||
|
||||
setup do
|
||||
|
|
Loading…
Reference in a new issue