1
0
Fork 0
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:
Fumiaki MATSUSHIMA 2013-07-23 00:17:37 +09:00 committed by Joshua Clayton
parent 261574c935
commit 69a6c9e14f
2 changed files with 16 additions and 1 deletions

View file

@ -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]

View 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