Я использую rails 3.0.9 и ruby 1.9.2 и работаю с учебником Hartl ruby on rails Я также бегу Spork. Использование factory_girl_rails v. 1.1.0
Failures:
1) UsersController GET 'show' should be successful
Failure/Error: @user = Factory(:user)
ActiveRecord::RecordInvalid:
Validation failed: Name can't be blank
# ./spec/controllers/users_controller_spec.rb:9:in `block (3 levels) in <top (required)>'
Finished in 0.38122 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/users_controller_spec.rb:12 # UsersController GET 'show' should be successful
Mr factories.rb file
Factory.define :user do |user|
user.name "Michael Hartl"
user.email "mhartl@example.com"
user.password "foobar"
user.password_confirmation "foobar"
end
User_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
# it "show the right user" do
# get :show, :id => @user
# assigns(:user).should == @user
# end
end
describe "GET 'new'" do
it "should be successful" do
get 'new'
response.should be_success
end
it "should have the right title" do
get :new
response.should have_selector('title', :content => "Sign up")
end
end
end
show.html.rb file
<%= @user.name %>, <%= @user.email %>