无法让 rspec、spork 和调试器发挥良好的作用 [英] Can't get rspec, spork and debugger to play nice

查看:42
本文介绍了无法让 rspec、spork 和调试器发挥良好的作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Given I am a dumb programmer
  and I am using rspec
  and I am using spork
  and I want to debug ...mmm...let's saaay, a spec for Phone. 

那么,我应该将require 'ruby-debug'"行放在哪里,以便在 phone_spec.rb 中的特定点停止处理?(我所要求的只是一个大箭头,即使是有挑战的程序员也能看到:-3)

Then, where should I put the "require 'ruby-debug'" line in order to halt processing at a particular point in the phone_spec.rb? (All I'm asking for is a big fat arrow that even a challenged programmer could see :-3 )

我尝试了很多地方,除非我没有正确测试它们,否则会发生一些奇怪的事情:

I've tried many locations, and unless I didn't test them correctly, there's something weird going on:

在以下位置的 spec_helper.rb 中:

In spec_helper.rb at the following locations:

require 'rubygems'
require 'spork'
                                            <= TRIED IT HERE
ENV["RAILS_ENV"] ||= 'test'

Spork.prefork do
  require File.dirname(__FILE__) + "/../config/environment" #unless defined?(RAILS_ROOT)
  require 'spec/autorun'
  require 'spec/rails'
  require 'machinist/active_record'
  require 'faker'
  require 'sham'
                                            <= TRIED IT HERE
end

Spork.each_run do
  require File.expand_path(File.dirname(__FILE__) + "/blueprints")

                                            <= TRIED IT HERE
end

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

Spec::Runner.configure do |config|
  config.use_transactional_fixtures = true
  config.use_instantiated_fixtures  = false
  config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
  config.before(:all)    { Sham.reset(:before_all)  }
  config.before(:each)   { Sham.reset(:before_each) }

                                            <= TRIED IT HERE

end

推荐答案

我一直把它放在 config/environments/test.rbdebugger在我的应用代码中的断点处(与规范相反).

I've always put it in config/environments/test.rb and the put the debugger at the breakpoint in my app code (as opposed to the spec).

这篇关于无法让 rspec、spork 和调试器发挥良好的作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆