【发布时间】:2011-02-26 19:30:51
【问题描述】:
当我运行bundle exec rspec spec/ 时,我的一个测试失败了,应该通过了。这是错误:
Failure/Error: @user = Factory(:user)
NoMethodError:
undefined method `Factory' for #<RSpec::Core::ExampleGroup::Nested_2::Nested_2:0x1037c0a70>
# ./spec/controllers/users_controller_spec.rb:21
这是测试代码:
describe "GET 'show'" do
before(:each) do
@user = Factory(:user)
end
it "should be successful" do
get :show, :id => @user
response.should be_success
end
it "should find the right user" do
get :show, :id => @user
assigns(:user).should == @user
end
end
我安装了 Factory Girl gem,所以我不确定是什么问题。
【问题讨论】:
-
您的
Gemfile中是否包含工厂女孩?
标签: ruby-on-rails rspec gem factory-bot