RSpec + Spork on Win没有输出

时间:2014-01-11 11:39:50

标签: ruby-on-rails rspec spork

人。

Rails 3.2.12

我有一个示例测试 spec / models / user_spec.rb

require 'spec_helper'

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

spec / 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

当我使用 Spork运行测试时,我得到:

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

在Spork窗口:

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

当我使用Spork时,为什么Rspec没有提供有关待处理,失败等测试的信息?

1 个答案:

答案 0 :(得分: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

我遇到了和你一样的问题,一旦我加入了这个问题,我又得到了正常的输出。