How to use FactoryGirl to create an attribute called “alias”?

后端 未结 2 1898
萌比男神i
萌比男神i 2021-02-07 02:02

I\'m just wondering whether it\'s possible to create an attribute called \"alias\" using FactoryGirl, since alias is a reserved word in Ruby.

FactoryGirl.define          


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-07 02:30

    Define a variable for the factory .. do block and call methods on it.

    FactoryGirl.define do
      factory :blah do |f|
        f.name "dummy"
        f.alias "dummy"
      end
    end
    

提交回复
热议问题