【问题标题】:Using spring with Rails3在 Rails3 中使用 spring
【发布时间】:2014-09-05 10:17:29
【问题描述】:

我正在使用 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 installed 并创建了 binstubs (bundle exec spring binstub --all),运行 guard 并保存了一个测试,以便 guard 运行它。完成后,我检查了spring status,但它说Spring 没有运行。

我修改了 Guardfile 以删除 rubygems 和 bundler 选项,甚至删除了 cmd 选项中的 bundle exec 调用,但没有任何东西使 spring 运行。

有什么想法吗?谢谢!

【问题讨论】:

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


    【解决方案1】:

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

    --color
    --fail-fast
    

    这样,无论从哪里调用 rspec,它们都会被使用。

    其次,使用 Guard 和 Spring 的最佳方式是确保 spring 首先在 outside Guard 中正常工作,例如

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

    如果这不起作用 - 也许它没有被正确地存根。 RSpec 自己工作吗? (没有弹簧)。

    如果这不起作用,请尝试此处的步骤:https://github.com/rails/spring#troubleshooting

    (万一春天因为其他原因没有开始)

    【讨论】:

      猜你喜欢
      • 2011-04-19
      • 2014-05-22
      • 2012-12-25
      • 2011-09-15
      • 2011-05-31
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多