0
在我的應用程序/控制器/ pet_controller.rb文件我有一些代碼on Rails的RSpec的利用W /水豚4.2
class PetsController < ApplicationController
before_action :set_pet, only: [:show, :edit, :update, :destroy]
before_action :process_params, only: [:create, :edit]
# GET /pets
# GET /pets.json
def index
@pets = Pet.find_by_sql ["SELECT * FROM pets WHERE \"userId\" = ?", params[:userId].to_i]
end
.
.
.
我有我的規格/ pets_spec.rb一些代碼,看起來像
describe PetsController do
describe 'GET #index' do
it { is_expected.to respond_with :ok }
end
end
如果控制器響應正確,可進行簡單測試。 當我調用束EXEC rspec的,我得到一個
/spec/pets_spec.rb:1:in `<top (required)>': uninitialized constant PetsController (NameError)
我很新的使用該測試工具,任何幫助,得到這個開始將不勝感激。
-Otterman