我尝试使用 RSpec 在 Windows 上测试我的 Rails 3 应用程序。我已经编写了测试和工厂,但无法解决在命令行上运行 RSpec 时出现的问题。
这是其中一个测试文件:require 'spec_helper'
describe "SignIns" do
it "can sign in" do
user = FactoryGirl.create(:user)
visit new_user_session_path
fill_in "login", with: user.username
fill_in "password", with: user.password
click_on "sign in"
current_user.username.should == user.username
end
end
这是 factory.rb:
factory :layout do
name "layout1"
end
factory :club do
sequence(:name) { |i| "Club #{i}" }
contact_name "John Doe"
phone "+358401231234"
email "#{name}@example.com"
association :layout
end
factory :user do
sequence(:username) { |i| "user#{i}" }
password 'password'
email "test@example.com"
club
end
当我尝试运行 RSpec 时,会出现以下错误:
trait not registered: name
#C: in 'object'
#.spec/features/sign_in_spec.rb:11:in 'block (2 levels) in (top(required))
我究竟做错了什么?