私のコントローラー仕様の1つで本当に奇妙なrspecの動作を取得しています。
説明するのが最善です。ルビミンでは、ブレークポイントを設定すると、次のようになります。
#rspec test
describe Api::V1::UsersController do
let(:user) { FactoryGirl.create(:user) }
describe "#show" do
it "responds successfully" do
get 'show', id: user.id
response.should be_success
end
end
#controller
class Api::V1::UsersController < AuthenticatedController
def show # !!! RubyMine breakpoint will stop execution here !!!
user = User.find(params[:id])
user_hash = User.information(user, current_user)
respond_to do |format|
format.json { render json: user_hash.to_json }
end
end
したがって、上記は期待どおりに機能します。
しかし、今ではこのテストは失敗します。
#rspec test
describe UsersController do
let(:user) { FactoryGirl.create(:user, is_admin: false) }
describe "#show" do
it "redirects non-admin" do
get 'index'
response.should redirect_to user_path(user)
end
end
#controller
class UsersController < AuthenticatedController
def index # !!! Breakpoint is never hit !!!
@users = User.all
respond_to do |format|
if current_user.is_admin
format.html
format.json { render json: @users }
else
redirect_to user_path(current_user) and return
end
end
end
By the way, this is the result:
Expected response to be a redirect to <http://test.host/users/625> but was a redirect to <https://test.host/users>
UsersControllerのコントローラーメソッドのブレークポイントはどれもヒットしません。しかし、API :: V1 :: UsersControllerでブレークポイントを設定すると、すべてのコントローラーメソッドがヒットします。
どんなガイダンスでも大歓迎です。私はこれをデバッグする方法が本当に途方に暮れています。