在Rails 3,Ruby 1.9和Test :: Unit中,在功能测试中调用调试器的正确方法是什么?我已经尝试添加“调试”,然后运行耙:测试:泛函:如何在Rails功能测试中调用调试器?
class AdminControllerTest < ActionController::TestCase
test "should get index" do
debugger
get :index
assert_redirected_to welcome_url
end
end
但是Ruby似乎忽视了调用调试器(测试继续并正常运行)。如果我尝试直接运行测试:
ruby -r debug test/functional/admin_controller_test.rb
然后Ruby找不到test_helper.rb。如果按照下面的答案,我运行:
ruby -I "lib:test" test/functional/admin_controller_test.rb
然后它找到test_helper,但再次运行测试完成而无需调用调试器。我的Gemfile确实有:
gem 'ruby-debug19', :require => 'ruby-debug', :group => :development
不,这不是推出为我调试;即使在将这些行添加到.rdebugrc之后,测试仍会完成。 – 2011-04-12 15:44:13
但是你可以调试你的应用程序,而不是测试?你的“gem'ruby-debug19',:require =>'ruby-debug'”包含在你的测试组中,还有:development? – njorden 2011-04-12 15:55:09
冰冰冰冰!我只在开发组中拥有ruby-debug19。 – 2011-04-12 16:07:29