Presumably, FactoryGirl.create(:a_patpay)
is defined to return an instance of ABCD
, which is not a valid argument for FactoryGirl.attributes_for
and which prints out as you've indicated due to the definition of to_s
.
Factory not registered error due to to_s method in model
-
02-10-2022 - |
質問
I created factories for the model ABCD and it's associated models including the model "another_model" which has a belongs_to relation to ABCD.
The model ABCD has a to_s method that returns
def to_s
"Check: #{another_model.check_number} SSNUM: #{something_some_val}"
end
Now when I try to test an action in the ABCD_Controller class I get this error.
Failure/Error: get :document_save, {"abcd"=>attributes_for(FactoryGirl.create(:a_patpay)) }
ArgumentError:
Factory not registered: Check: 456465 SSNUM: 06122469
Now Check and SSNUM are obviously not attributes of the ABCD Model they are just strings returned by the to_s method in the model. Wondering why FactoryGIrl thinks they are attributes that are not registered...
Any help is much appreciated!
解決
所属していません StackOverflow