2012-05-19 73 views
2

我是Ruby on Rails的新手,我正在关注Michael Hartl的Ruby on rails教程。我在测试驱动开发的第3章。当我运行命令Michael Hartl的RoR教程第3章rails生成integration_test什么也不做

轨产生integration_test static_pages

它什么都不做。没有错误,没有规范文件被创建。我已经使用railsinstaller安装了rails。

接下来要做什么?

+0

这是/不是“过于本地化”! – Phlip

回答

1

我不知道为什么它不为您生成文件。它在我尝试它时起作用。只有

一个文件被生成:

require 'test_helper' 

class StaticPagesTest < ActionDispatch::IntegrationTest 
    # test "the truth" do 
    # assert true 
    # end 
end 

它出现在test/integration/static_pages_test.rb

+0

我可以手动添加此文件并继续吗? – dnisha

+1

是的。这是唯一生成的文件,没有其他文件被更改。 – x1a4

+2

Brian Dear在下面给出了正确的解决方法,将gem'rspec-rails'添加到开发中(或者在我的情况下,在拼写开发时修复拼写错误)。 – DavidG

1

不知道为什么你会得到任何错误。我必须使用

bundle exec rails generate integration_test static_pages 

它的工作。

0

我有同样的问题(即没有错误,没有规范文件创建)和EricM的解决方案不适合我。我手动创建的投机/请求/ static_pages_spec.rb以下文件,它似乎已经奏效(我不得不创建规范的要求目录):

require 'spec_helper' 

describe "Static pages" do 

    describe "Home page" do 

    it "should have the content 'Sample App'" do 
     visit '/static_pages/home' 
     page.should have_content('Sample App') 
    end 
    end 
end 

这是清单3.9中使用相同的代码这本书:http://ruby.railstutorial.org/chapters/static-pages#sec:TDD

11

这是一个简单的问题。将rspec-rails放入您的gemfile的开发和测试组中:

group :development, :test do 
    gem 'rspec-rails' 
end 

然后绑定,您将被设置。当您运行rails g integration_test时,它现在会生成测试文件。原因是rspec生成器仅在开发组(也就是测试组相对)时才被暴露。

+0

这对我有用。谢谢! –

+0

这应该是正确的答案。选定的答案只能绕过这个问题。 – DavidG

+0

这也适用于我。 – kengo

相关问题