使用带有Rails3的spring

时间:2014-09-05 10:17:29

标签: ruby-on-rails ruby-on-rails-3 rspec guard spring-gem

我正在使用Ruby on Rails 3.2.15,我想使用spring来加速我的开发。我正在使用guard 1.7.0和rspec 2.13.1。

这是我的Guardfile

guard 'rspec', cmd: 'bundle exec spring rspec --color --fail-fast', all_on_start: false, keep_failed: false, all_after_pass: false, rubygems: false, bundler: false do
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{app/(.+)/(.+)\.rb})                  { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
  watch(%r{spec/(.+)/(.+)_spec\.rb})
end

我在我的Gemfile上添加了spring-commands-rspec gem:

group :development, :test do
  ...
  gem 'spring-commands-rspec'
end

bundle install编辑并创建了binstub(bundle exec spring binstub --all),运行guard并保存了测试,以便guard运行它。完成后,我检查了spring status,但它说 Spring没有运行

我修改了Guardfile以删除rubygemsbundler选项,甚至删除了bundle exec选项中的cmd调用,但没有任何内容弹出。

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

首先,您可以将RSpec选项放在.rspec文件或.rspec-local文件中,如下所示:

--color
--fail-fast

无论在何处调用rspec,都会使用它们。

其次,使用Guard和Spring的最佳方法是确保弹簧首先正常外面保护,例如。

spring stop
bin/rspec # if it was generated with spring binstub
spring status

如果这不起作用 - 也许它没有得到正确的binstub。 RSpec是单独工作的吗? (没有春天)。

如果不起作用,请尝试以下步骤:https://github.com/rails/spring#troubleshooting

(如果弹簧由于其他原因没有启动)