3

controllers フォルダーのサブドメインにいくつかのコントローラーがあります。

app/controllers/api/v1/offers_controller.rbたとえば、次のようなコントローラーがあります。

class Api::V1::OffersController < ApplicationController
  respond_to :json

  def index
   ...some code here
  end
end

spec/controllers/api/v1/offers_controller.rb次のようなコントローラーを入れてみました。

「spec_helper」が必要

descripe Api::V1::OffersController do
  describe "GET 'index'" do
    it "returns http success" do
      get 'index'
      response.should be_success
    end
  end
end

ただし、実行するrspec specと、このテストはまったく実行されません。また、api_v1_offers_controller.rb という名前のディレクトリに配置しようとしましたがspec/controllers、テストはまだ実行されていません。

これらのタイプのコントローラーの RSpec テストを作成するにはどうすればよいですか?

4

1 に答える 1

4

実際、ファイルの名前の付け方が間違っていたようです。すべての RSpec テストを終了する必要があるようです_spec

于 2013-02-06T20:45:41.700 に答える