【问题标题】:RSpec + Spork on Win give no outputRSpec + Spork on Win 没有输出
【发布时间】:2014-01-11 11:39:50
【问题描述】:

伙计们。

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 没有提供有关未决、失败等测试的信息?

【问题讨论】:

    标签: ruby-on-rails 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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-30
      • 1970-01-01
      • 2012-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多