I am trying to follow at railstutorial.org, and I am currently in chapter 7, where you start using plants: http://railstutorial.org/chapters/modeling-and-viewing-users-two#sec:tests_with_factories
I am using Rails 3.0.1 and ruby-1.9.2-p0
I can't get my rspec tests for life, though, I get an error
Failures: 1) UsersController GET 'show' should be successful Failure/Error: @user = Factory(:user) undefined method `Factory' for #<RSpec::Core::ExampleGroup::Nested_2::Nested_1:0x00000101cc5608> # ./spec/controllers/users_controller_spec.rb:9:in `block (3 levels) in <top (required)>'
my factories.rb look like this:
# By using the symbol ':user', we get Factory Girl to simulate the User model. Factory.define :user do |user| user.name "Michael Hartl" user.email "mhartl@example.com" user.password "foobar" user.password_confirmation "foobar" end
and this is my users_controller_spec.rb file:
require 'spec_helper' describe UsersController do render_views 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
here is my gemfile if it helps:
source 'http://rubygems.org' gem 'rails', '3.0.1'
ruby-on-rails factory-bot
bobaboba
source share