2014-01-11 101 views
1

夥計們。RSpec + Spork on Win不輸出

Rails 3.2.12 

我有一個樣本測試規格/型號/ user_spec.rb

require 'spec_helper' 

describe User do 
    pending "add some examples to (or delete) #{__FILE__}" 
end 

規格/ spec_helper.rb

require 'spork' 

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

    Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } 

    RSpec.configure do |config| 
    config.fixture_path = "#{::Rails.root}/spec/fixtures" 
    config.use_transactional_fixtures = true 
    config.infer_base_class_for_anonymous_controllers = false 
    config.order = "random" 
    config.color_enabled = true 
    config.tty = true 
    config.formatter = :documentation # :progress, :html, :textmate 
    end 
end 

Spork.each_run do 
end 

當我運行測試沒有 Spork我得到:

$ rspec 
c:/ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support 
/dependencies.rb:251:in `block in require': iconv will be deprecated in the futu 
re, use String#encode instead. 

User 
    add some examples to (or delete) d:/sites/efiling/spec/models/user_spec.rb (PE 
NDING: No reason given) 

Pending: 
    User add some examples to (or delete) d:/sites/efiling/spec/models/user_spec.r 
b 
    # No reason given 
    # ./spec/models/user_spec.rb:4 

Finished in 0.31249 seconds 
1 example, 0 failures, 1 pending 

Randomized with seed 10437 

當我與叉勺運行測試我得到:

$ rspec . --drb 
    <-- Slave(1) run done! 

在叉勺窗口:

Loading Spork.prefork block... 
    --> DRb magazine_slave_service: 1 provided... 
Running tests with args ["--color", "."]... 
    <-- take tuple(1); slave.run... 
    -- (1);run done 
Done. 

    -- build slave 1... 
Preloading Rails environment 

爲什麼Rspec的提供有關未決沒有資料,失敗等測試時,我將它與Spork一起使用?

回答

1

我發現一個回答你的問題:How can I configure rspec to show output with spork?

爲了您的方便,貼規避這個錯誤是把它添加到Spork.each_run塊的方式:

if Spork.using_spork? 
    RSpec.configure do |config| 
     config.reset 
     config.output_stream = $stdout 
    end 
end 

我有和你一樣的問題,一旦我添加了這個,我又得到了正常的輸出。