0
我有一些代碼增加了rspec-rails默認添加到setup and teardown fixtures的回調。如何添加到rspec-rails回調
我的代碼看起來是這樣的:
module Test
module Unit
class TestCase
append_before(:each) do
Test::Unit::AfterFixturesLoaded.custom_stuff1
end
append_after(:each) do
Test::Unit::AfterFixturesLoaded.custom_stuff2
end
end
class AfterFixturesLoaded
def self.custom_stuff1
#do some stuff here
end
def self.custom_stuff2
#do some other stuff here
end
end
end
end
此代碼工作正常,如果我把它在Rails應用程序中的config \ initializers目錄,但隨後運行的應用程序失敗,因爲它不會加載試驗裝置。所以我的問題是我可以在哪裏放置這些代碼,以便在運行rspec時始終包含它?