1
    require 'spec_helper'

describe PagesController do
  render_views

  describe "GET 'home'" do
    it "should be successful" do
      get 'home'
      response.should be_success
    end
  end

  describe "GET 'about'" do
    it "should be successful" do
      get 'about'
      response.should be_success
    end
  end

  describe "GET 'contact'" do
    it "should be successful" do
      response.should be_success
    end
  end




end

上記は、Ruby on Rails でのテストの基本を学びながら書いた非常に単純なテストです。問題は、app/controllers/pages_controller.rb にこれがないため、「接触」テストに失敗するはずです。 .

以下を返します

   Finished in 0.04558 seconds
3 examples, 0 failures

したがって、テストは正常にカウントされますが、いずれかが間違っていても失敗しません。

4

1 に答える 1

2

既に連絡先のビュー ファイルがある場合は、それが連絡先を渡す理由である可能性があります。これらのファイルを削除するか、ファイルの名前を変更して、もう一度確認してください。

(また)

テスト環境でキャッシュをオフにしないと、同じ問題が発生する可能性があります。に移動してconfig/environments/test.rb変更config.cache_classes = trueconfig.cache_classes = false

知らなければ、それが理由かもしれません。

于 2013-01-28T17:01:06.650 に答える