2011-08-11 3 views
3

私はレール3.0.9とルビ1.9.2を実行しており、Hartl ruby​​ on railチュートリアルから作業しています。私はまた、スポークを実行しています。使用factory_girl_rails V。1.1.0レール3の工場の女の子がエラーメッセージを出します: '検証に失敗しました:名前は空白にできません'

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 

氏のfactories.rbファイル

Factory.define :user do |user| 

    user.name "Michael Hartl" 
    user.email "[email protected]" 
    user.password "foobar" 
    user.password_confirmation "foobar" 

end 

User_controller_spec.rbファイル

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ファイル

<%= @user.name %>, <%= @user.email %> 
+0

1.1.0を削除せずにfactory_girl_rails 1.0を戻しました(以前は1.1.0を使用していたため、1.0は動作しませんでした)。なぜ私は理解できないのか分かりませんが... – WillLA

答えて

関連する問題