2012-03-22 40 views
4

我接管了一個代碼庫並嘗試運行測試。我是 RSpec有點新,所以這可能是一個微不足道的問題。RSpec賽程未加載

基本上我可以告訴燈具沒有被加載。所有100 測試失敗並出現類似錯誤。

但我不知道爲什麼。以下是代碼。你能看到什麼,或給我一個線索在哪裏看。到目前爲止我已經空了...

謝謝!

皮託·薩拉斯

在spec_helper.rb,我知道正在運行,我看到:

Spec::Runner.configure do |config| 
    config.global_fixtures = :all 
end 

在一個投機/控制器/ downloads_controller_spec.rb 測試的是下面。我知道它正在運行,我知道在'描述'之前, Partner.count == 0,所以沒有夾具。

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') 

describe DownloadsController do 
    integrate_views 

    describe "when PDF is ready" do 
    before(:each) do 
     @registrant = Factory.create(:step_5_registrant) 
     stub(@registrant).merge_pdf { `touch #{@registrant.pdf_file_path}` 
} 
     @registrant.generate_pdf 
     @registrant.save! 
    end 

    it "provides a link to download the PDF" do 
     get :show, :registrant_id => @registrant.to_param 
     assert_not_nil assigns[:registrant] 
     assert_response :success 
     assert_template "show" 
     assert_select "span.button a[target=_blank]" 
     assert_select "span.button a[onclick]" 
    end 

    after(:each) do 
     `rm #{@registrant.pdf_file_path}` 
    end 
    end 

而且這裏是在不同的目錄:你的「投機/ spec_helper.rb」包含

spec/fixtures/partners.yml - which contains 2 yaml records: 

sponsor: 
    id: 1 
    username: rtv 
    email: [email protected] 
    crypted_password: 
"c8e5b51b237344fe0e72539af0cac7197f094a5e933ffacf6e7fa612363c5933f520710c6427ac31fc4c68a2d7bb48eae601c74b96e7838f9ca1a0740b67576a" 
    password_salt: "Y4PPzYx2ert3vC0OhEMo" 
    name: Rocky 
    organization: Rock The Vote 
    url: http://rockthevote.com 
    address: 123 Wherever 
    city: Washington 
    state_id: 9 
    zip_code: 20001 
    phone: 555-555-1234 
    survey_question_1_en: "What school did you go to?" 
    survey_question_2_en: "What is your favorite musical group?" 
    created_at: <%= Time.now %> 
    updated_at: <%= Time.now %> 
# TODO: remove partner 2 in production 
partner: 
    id: 2 
    username: bull_winkle 
    email: [email protected] 
    crypted_password: 
"c8e5b51b237344fe0e72539af0cac7197f094a5e933ffacf6e7fa612363c5933f520710c6427ac31fc4c68a2d7bb48eae601c74b96e7838f9ca1a0740b67576a" 
    password_salt: "Y4PPzYx2ert3vC0OhEMo" 
    name: Bullwinkle 
    organization: Bullwinkle, Inc. 
    url: http://example.com 
    address: 123 Wherever 
    city: Washington 
    state_id: 9 
    zip_code: 20001 
    phone: 555-555-1234 
    survey_question_1_en: "What school did you go to?" 
    survey_question_2_en: "What is your favorite musical group?" 
    created_at: <%= Time.now %> 
    updated_at: <%= Time.now %> 

回答

4

也許這是自動完成的,現在,你已經解決了,但你檢查:

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 
config.fixture_path = "#{::Rails.root}/spec/fixtures" 

Cheers