0

我在 ruby​​ 1.9.2 之上的 rails 3.1 应用程序中运行以下 gem:

group :test, :development do
gem 'turn', '<0.8.3'
gem 'rspec-rails'
gem 'capybara'
gem 'guard-rspec'
gem 'minitest'
gem 'ruby_gntp'
gem "win32console", "~> 1.3.0"
end

我只通过运行

rails g integration_test MyApp

命令。

所以,我只有一个由命令生成的示例测试。它看起来像这样:

 require 'spec_helper'

describe "Tasks" do
  describe "GET /tasks" do
    it "works! (now write some real specs)" do
      # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
      get tasks_index_path
      response.status.should be(200)
    end
  end
end

出于某种原因,当我运行警卫时,它需要 3.5 到 5 秒之间的警卫和 rspec 只是在小测试中失败。在我看到的 tuts 中,他们的机器在 Mac 上运行这个精确的测试大约需要 0.0159 秒。我可以做些什么来提高这些测试的性能?

我在 Windows 7 机器上运行它。

有没有人处理过这种情况?

4

1 回答 1

1

正如上面@jstim 建议的那样,这个问题的一个词答案是Spork。

至少,您需要将以下内容添加到您的:test, :development块中:

gem 'spork', '~> 1.0rc'
gem 'guard-spork'

这是Spork README的链接。

What it does is sets up a preload block that you can put as much or as little of your app in as you like. The benefit, of course, is faster tests because of all that stuff that doesn't need to be run each time. The drawback is if you make changes to the stuff that's preloaded, it will not be tested. You need to restart Spork after such changes.

于 2012-06-10T00:45:26.910 回答