アプリでテストをセットアップしようとしていますが、RSpec、FactoryGirl、および Mongoid で問題が発生しました。私は次の工場を持っています:
FactoryGirl.define do
factory :user do |u|
u.name { Faker::Name.name }
u.email { Faker::Internet.email }
u.crypted_password { Faker::Lorem.characters(10) }
u.password_salt { Faker::Lorem.characters(10) }
u.role :user
end
end
テストでこのファクトリを使用しようとしています:
require 'spec_helper'
describe User do
it "has a valid factory" do
create(:user).should be_valid
end
end
しかし、私はこのエラーが発生します:
1) User has a valid factory
Failure/Error: FactoryGirl.create(:user).should be_valid
NoMethodError:
undefined method `user' for #<User:0x007ff24a119b28>
# ./spec/models/user_spec.rb:5:in `block (2 levels) in <top (required)>'
このエラーの原因がわかりません。また、rspec を使用して完全なスタック トレースを表示する方法はありますか?