RSpec gives error 'trait not registered: name'

后端 未结 2 1881
北荒
北荒 2021-02-18 14:08

I tried to test my Rails 3 application on Windows with RSpec. I\'ve wrote tests and factories, but can\'t solve the issues which raise when I run RSpec on command line.

2条回答
  •  不知归路
    2021-02-18 14:22

    I know this is an old question, but in case anyone else ends up here when searching "Trait not registered":

    When using a dependent attribute like how email depends on name in the :club factory from the question, you need to wrap the attribute in curly braces so it gets lazy evaluated:

    email {"#{name}@example.com"}
    

提交回复
热议问题