2011-07-22 7 views
4

私は継続的に私のテストを実行するためにRSpecのガードを使用して、時にはテストが原因で失敗します。初期化されていない一定のRSpecの::コア:: ExampleGroup :: Nested_1 ::工場

Running: spec/requests/signup_spec.rb 
FF 

Failures: 

    1) Signup does not email confirmation mail after signup 
    Failure/Error: visit new_user_path 
    NameError: 
     undefined local variable or method `new_user_path' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000100ad5fd8> 
    # ./spec/requests/signup_spec.rb:4:in `block (2 levels) in <top (required)>' 

    2) Signup should email confirmation mail after signup 
    Failure/Error: user = Factory.build(:user) 
    NameError: 
     uninitialized constant RSpec::Core::ExampleGroup::Nested_1::Factory 
    # ./spec/requests/signup_spec.rb:15:in `block (2 levels) in <top (required)>' 

時には彼らは仕事、時には彼ら私はなぜ知りません..

私を助けることができますか?

EDIT: は、私が使用して、次のバージョン:

  • ルビー1.9.2-P290
  • レール3.1.rc4
  • RSpecの(2.6.0)
  • RSpecのレール(2.6 .1)
  • factory_girl(2.0.0.rc4)
  • factory_girl_rails(1.1.rc1)

ご覧のとおり、ルートは動作していません:new_user_path not found ...?

そして、これは私の要求仕様である:

# -*- encoding : utf-8 -*- 
describe "Signup" do 
    it "does not email confirmation mail after signup" do 
    visit new_user_path 
    fill_in 'user_unconfirmed_email', :with => '[email protected]' 
    fill_in 'user_password', :with => '' 
    fill_in 'user_password_confirmation', :with => '' 
    click_button "Create User" 
    current_path.should eq(user_path) 
    page.should have_content("is too short") 
    last_email.should be_nil 
    end 

    it "should email confirmation mail after signup" do 
    user = Factory.build(:user) 
    visit root_path 
    fill_in 'user_unconfirmed_email', :with => user.unconfirmed_email 
    fill_in 'user_password', :with => user.unconfirmed_email 
    fill_in 'user_password_confirmation', :with => user.unconfirmed_email 
    click_button "Create User" 
    current_path.should eq(root_path) 
    page.should have_content("You successfully signed up! An email with your activation link was sent to your mail address.") 
    last_email.to.should include(user.unconfirmed_email) 
    last_email.body.should include(user.email_confirmation_key) 
    open_email(user.unconfirmed_email) 
    click_first_link_in_email # email spec 
    current_path.should eq(new_user_path) 
    page.should have_content "Your email was successfully confirmed. You are now able to log in with it!" 
    end 
end 

答えて

19

なんてこった...私が持っていた

+0

これを投稿してくれてありがとう、私にも起こっていた。 – jcollum

2

... ..私は私のスペックで

require 'spec_helper.rb' 

を含めるのを忘れて解決策を見つけましたこのまったく同じ問題ですが、私の場合、私はsporkを再起動するのを忘れました。

spspはrspecを使用してテスト期間を大幅に短縮する宝石です。おすすめ!

+0

sporkも私を得ました...チップのおかげで。 – PeppyHeppy

1

私は同じ問題を抱えていましたが、私のケースでは仕様/モデルの下で仕様が間違っていましたが、仕様/要求の下にあったはずです。

関連する問題