RoR 2.3.11和Rspec 1.2.9 ...在现有项目中添加测试:测试存在,但忽略了它们

时间:2012-10-22 01:33:40

标签: ruby-on-rails rspec rspec-rails

嘿,这就是我所在的地方:

$ spec spec/

Finished in 0.002031 seconds

0 examples, 0 failures

但是。我已经编写了我的前几个测试并将它们放在/spec/controllers/citations_controller_spec.rb

并在上面的规范中添加了一个put来验证它实际上是在使用:

时执行的
spec spec/

这里是citations_controller_spec.rb的内容(它有现有的测试):

require 'spec_helper'

describe CitationsController do
  describe "GET 'home'" do
    it "should be successful" do
      get 'home'
      response.should be_success
    end
    it "should have the right title" do
      get 'home'
      response.should have_tag("title",
                               "Ruby on Rails Tutorial Sample App | Home")
    end
  end

  describe "GET 'contact'" do
    it "should be successful" do
      get 'contact'
      response.should be_success
    end
    it "should have the right title" do
      get 'contact'
      response.should have_tag("title",
                               "Ruby on Rails Tutorial Sample App | Contact")
    end
  end

  describe "GET 'about'" do
    it "should be successful" do
      get 'about'
      response.should be_success
    end
    it "should have the right title" do
      get 'about'
      response.should have_tag("title",
                               "Ruby on Rails Tutorial Sample App | About")
    end
  end
end

但如第一个代码位所示......

0 examples, 0 failures

..所以有人碰巧知道这里发生了什么?

1 个答案:

答案 0 :(得分:1)

尝试

spec spec/controllers/citations_controller_spec.rb

运行一个测试文件。或

rake test

运行所有测试。你现在看到任何测试点或例子吗?