あるapiに書いてある、以下のコードをテストしたい
code.rb
fail ActionController::BadRequest unless params[:application_token].in?(Settings.access_grants)
方法1: status codeで400が返ってくることをテスト
api_spec.rb
context 'when the application token is wrong' do
let(:application_token) { 'wrong_token' }
it { expect(response).to have_http_status(400) }
end
方法2: errorのkeyがあることをテスト
work in progress