我有一些控制器位于控制器文件夹的子域中。
例如,我有一个控制器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
,这个测试根本不会运行。我也试过把它放在spec/controllers
名为 api_v1_offers_controller.rb 的目录下,测试仍然没有运行。
如何为这些类型的控制器编写 RSpec 测试?