mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Fix factory named camel case string
This commit is contained in:
parent
261574c935
commit
69a6c9e14f
2 changed files with 16 additions and 1 deletions
|
@ -8,7 +8,7 @@ module FactoryGirl
|
|||
|
||||
def initialize(name, options = {})
|
||||
assert_valid_options(options)
|
||||
@name = name.is_a?(Symbol) ? name : name.to_s.underscore.to_sym
|
||||
@name = name.respond_to?(:to_sym) ? name.to_sym : name.to_s.underscore.to_sym
|
||||
@parent = options[:parent]
|
||||
@aliases = options[:aliases] || []
|
||||
@class_name = options[:class]
|
||||
|
|
15
spec/acceptance/definition_camel_string_spec.rb
Normal file
15
spec/acceptance/definition_camel_string_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "an instance generated by a factory named a camel case string " do
|
||||
before do
|
||||
define_model("UserModel")
|
||||
|
||||
FactoryGirl.define do
|
||||
factory 'UserModel', class: UserModel
|
||||
end
|
||||
end
|
||||
|
||||
it "registers the UserModel factory" do
|
||||
expect(FactoryGirl.factory_by_name('UserModel')).to be_a(FactoryGirl::Factory)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue