2011-11-07 91 views
0

這裏有不少精彩的教程,過去我也沒有太多的麻煩。但是,經過數小時的努力,我一定會錯過一些東西。讓spork與Ruby 1.9.2/3 + Rails 3.1 + Rspec一起工作?

我已經完成了標準的安裝說明,並啓動了叉勺服務器:

Using RSpec 
Preloading Rails environment 
Loading Spork.prefork block... 
Spork is ready and listening on 8989! 

看起來不錯。

然後,我跳了一個新的標籤,並運行我的規格:

$ rspec spec 

此命令只在一剎那運行後沒有返回。所以我跳回到叉勺服務器,看看發生了什麼,得到:

Using RSpec 
Preloading Rails environment 
Loading Spork.prefork block... 
Spork is ready and listening on 8989! 
Running tests with args ["--color", "spec"]... 
Exception encountered: #<DRb::DRbConnError: druby://localhost:56736 - #<Errno::ECONNREFUSED: Connection refused - connect(2)>> 
backtrace: 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:730:in `block in open' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:729:in `each' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:729:in `open' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1191:in `initialize' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1171:in `new' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1171:in `open' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1074:in `respond_to?' 
/Users/briancody/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/run_strategy/forking.rb:10:in `block in run' 
/Users/briancody/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/forker.rb:21:in `block in initialize' 
/Users/briancody/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/forker.rb:18:in `fork' 
/Users/briancody/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/forker.rb:18:in `initialize' 
/Users/briancody/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/run_strategy/forking.rb:9:in `new' 
/Users/briancody/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/run_strategy/forking.rb:9:in `run' 
/Users/briancody/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/server.rb:48:in `run' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop' 
/Users/briancody/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop' 
Done. 

出於某種原因,drb是無法連接?我瘋狂搜索,但那裏似乎沒有任何幫助。

一些可能的線索

  • 端口(在這種情況下56736)改變每次我試圖在這兩個紅寶石1.9.2運行套件
  • 我得到相同的結果和Ruby 1.9的時間。 3
  • 我使用mac(雪豹)和防火牆被禁用
  • 我試過它在一個完全不同的mac(也是雪豹),結果相同。
  • 我正在使用最新版本的黃瓜,rspec和spork。
  • 我也設置了黃瓜spork,它失敗了相同的方式。

正如你所看到的,我一直在抨擊它一段時間。我的項目使用了很多寶石,沒有spork使得測試真的非常糟糕。請幫助...

UPDATE

這裏是我的spec_helper

require 'spork' 

Spork.prefork do 
    ENV["RAILS_ENV"] ||= 'test' 
    require File.expand_path("../../config/environment", __FILE__) 
    require 'rspec/rails' 
    require "email_spec" 
    require 'webmock/rspec' 
    require 'vcr' 
    require 'database_cleaner' 

    include Devise::TestHelpers 
    include EmailSpec::Helpers 
    include EmailSpec::Matchers 

    # Stub all updates to search indexes 
    class Profile 
    def update_tank_indexes ; end 
    def delete_tank_indexes ; end 
    end 
    class Journal 
    def update_tank_indexes ; end 
    end 

    # Apparently rspec doesn't understand <tt>main_app</tt> so stub it out. 
    def main_app ; self ; end 


    # Requires supporting ruby files with custom matchers and macros, etc, 
    # in spec/support/ and its subdirectories. 
    Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} 

    RSpec.configure do |config| 

    config.mock_with :rspec 

    # If you're not using ActiveRecord, or you'd prefer not to run each of your 
    # examples within a transaction, remove the following line or assign false 
    # instead of true. 
    config.use_transactional_fixtures = true 
    config.extend VCR::RSpec::Macros 

    # Always clean the database after running describe/context blocks to ensure a 
    # consistent state. This is especially important when using the <tt>rspec-set</tt> 
    # method. This method creates setup object once -- and only once -- proir to 
    # running an entire describe/context block. In this way, it's similar to using 
    # <tt>before(:all)</tt> except that <tt>set</tt> is better because: 
    # 
    # * It automatically reloads the object before each example, making it much 
    #  safer than before(:all) which can cause bugs if you're not careful. 
    # * It's lazily evaluated. 
    # 
    # You can read more at: 
    # 
    # * eggsonbread.com/2010/05/25/speed-up-your-specs-with-set/ 
    # * github.com/pcreux/rspec-set 
    # 
    # Note: This is not part of default configuration. Be sure to retain this snippet 
    # when upgrading. 
    # 
    DatabaseCleaner.strategy = :truncation 
    config.before(:all) do 
     DatabaseCleaner.clean 
    end 
    config.after(:suite) do 
     DatabaseCleaner.clean 
    end 
    end 

end 

Spork.each_run do 
    # This code will be run each time you run your specs. 
end 
+0

你好,也許你的spec_helper文件可以幫助我們在正確的方向嗎? – Rasmus

回答

3

我開了一張票這個問題,但沒有在過去3.5個月已經到來的那樣:https://github.com/sporkrb/spork/issues/133

更新:我找到了解決辦法,並報告一切船票。 tl; dr:將「always_validate_ssl_certifitcates」的Gemfile條目更改爲包含:require => false

+0

Heyyyyy,我花了很長時間調試,而且我真的明白了!您可以在上面鏈接的票上閱讀完整故事,但簡短版本是:從您的Gemfile中刪除「always_verify_ssl_certificates」。固定。 – indirect

+1

間接做了一些很好的工作,弄清楚這一點。我還在他上面提到的同一張票上發佈了我的想法/修復。如果您遇到此錯誤,請檢出該票。你很可能會找到解決方案。 –

1

你可以回滾到叉勺0.8.5,看看它是否起作用?我剛剛證實工作。

+0

有趣,你會回答。在尋找替代解決方案時,我正在觀看你的演講(「spork是一個bandaid」)。我試着回滾到0.8.5,沒有運氣。我一定做了一些事情來搞砸,因爲這看起來不是一個普遍的問題。無論如何,升級到1.9.3的確有助於縮短啓動時間。 向前推進,一定會考慮按照您的建議混入PORO。在此期間你有什麼建議:specjour? parallel_test?還有別的嗎? –