2016-07-22 21 views
0

我使用minitest 5.8.4和rspec-rails 3.5.1。我們有一個使用minitest的當前測試套件,但我會慢慢遷移到rspec。Rspec-rails超載描述,打破現有minitests

我現在有很多的測試中發現的結構如下所示:

class UserTest < ActiveSupport::TestCase 
    describe "a_method" do 
    it "should return the results" do 
     assert_a_thing 
    end 
    end 
end 

只要我包括我的Gemfile rspec-rails,看來該describe方法再全局重載/採取RSpec的,當我運行rake test時,它會簡單地跳過所有這些測試。

不在跳過結構爲test 'foo' {it 'works' {}}的測試。

我該如何輕鬆做到這一點,以便我的新RSpec測試和使用describe的現有微型項目平安共存?

回答

1

我認爲這是因爲rspec's monkey patching。在你的spec_helper禁用猴子補丁。

RSpec.configure do |c| 
    c.disable_monkey_patching! 
end 

你會那麼就需要在你的規格

RSpec.describe "whatever" do 
    # any describe, scenario, it blocks here don't need the RSpec. prefix 
end 
+0

這似乎幫助下,但現在'describe'是未知的MINITEST。 – tibbon

+0

'當我刪除rspec時'describe'在'minitest-5.8.4/lib/minitest/spec.rb:71'中定義。試圖找出我什麼時候停止猴子補丁(我實際上把它放在'test/test_helper.rb'的頂部,然後描述是完全未定義的。嗯 – tibbon

+0

看來問題的一部分是minitest rails是試圖刪除描述,並有調用超類,等 – tibbon