【问题标题】:First call to skip() in minitest throws error (undefined method `split' for nil:NilClass)在 minitest 中首次调用 skip() 会引发错误(nil:NilClass 的未定义方法“split”)
【发布时间】:2012-06-11 20:44:10
【问题描述】:

在 rails 3.2/minitest 项目中第一次调用“skip”时出现未定义的错误。

require "test_helper"

describe "Test Integration Test" do
  describe "area1" do
    it "must do X" do
      assert true
    end
    it "must do Y" do
      assert true
    end
  end
end

这很好用,但如果我修改为跳过 Y...

    it "must do Y" do
      skip "need to rewrite"
      assert true
    end

...它错误:

$ rake test:integration
Run options: --seed 49388

.E

Finished tests in 2.109235s, 6.6375 tests/s, 12.8008 assertions/s.
# Running tests:

  1) Error:
test_0003_must_do_y(Test Integration Test::area1):
NoMethodError: undefined method `split' for nil:NilClass
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/testing/setup_and_teardown.rb:35:in `block in run'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:425:in `_run__858522010476008514__setup__95624718422814153__callbacks'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

如果我添加第三个测试,也跳过,它只会在第一个跳过时报告错误:

require "test_helper"

describe "Test Integration Test" do
  describe "area1" do
    it "must do X" do
      assert true
    end
    it "must do Y" do
      skip "rewrite me"
      assert true
    end
    it "must do Z" do
      skip "rewrite me"
      assert true
    end
  end
end


$ rake test:integration
Run options: --seed 43718

# Running tests:

ES.

Finished tests in 2.236945s, 6.2585 tests/s, 11.6230 assertions/s.

  1) Error:
test_0003_must_do_z(Test Integration Test::area1):
NoMethodError: undefined method `split' for nil:NilClass
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/testing/setup_and_teardown.rb:35:in `block in run'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:425:in `_run__2453774402805069296__setup__401473829290905838__callbacks'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/drew/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

任何人都可以就第一次遇到的跳过错误的原因提出建议吗?或者,也许,我应该在哪个问题跟踪器中提交这个问题?

【问题讨论】:

    标签: ruby-on-rails minitest


    【解决方案1】:

    我对此进行了调试,发现错误来自我正在使用的 minitest-rg gem。万一其他人遇到这个问题,我patched it in a fork 并发送pull request to the maintainer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-27
      • 2015-10-18
      相关资源
      最近更新 更多