我已經看到了很多這些問題,但他們的解決方案都不適合我。我有這樣一個單一的測試:堆棧太深 - Rspec
describe RolesController do
describe "#delet" do
context "When the user is logged in" do
let(:user) {FactoryGirl.create(:user)}
let(:admin) {FactoryGirl.create(:admin)}
let(:adminRole) {FactoryGirl.create(:adminRole)}
it "Should allow admins to delete roles" do
sign_in admin
put :destroy, :id => adminRole.id
end
end
end
end
簡單,簡單,簡單。但我得到的典型錯誤:
1) RolesController#delet When the user is logged in Should allow admins to delete roles
Failure/Error: Unable to find matching line from backtrace
SystemStackError:
stack level too deep
# /home/adam/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:23
我都喜歡......什麼?我再次讀過幾十個關於這個問題的問題,這似乎與工廠女孩有些關係,但我不明白這裏會遇到什麼問題。我有大量的其他測試,沒有問題實例化工廠女孩爲基礎的對象。
你的堆棧跟蹤是什麼樣的?無論如何,您需要分享您的工廠,以獲得比相關問題更具體的幫助。 –
小心'let' - 這很懶。當您的測試運行'sign_in admin'時,它會在運行測試之前實例化'admin',但不會執行'user'或'adminRole'。 – zetetic
它似乎與Rspec沒有關係。我在ActiveSupport instrumenter的同一行中得到了同樣的錯誤,只是在生產模式下運行腳本,並且在該環境中排除了Rspec。我也在運行Ruby 2.0.0-p247和Rails 4. –