Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Committeeを導入してみた

yuki21
August 14, 2020

 Committeeを導入してみた

5分間社内LT資料

yuki21

August 14, 2020
Tweet

More Decks by yuki21

Other Decks in Programming

Transcript

  1. 設定 # rails_helper.rb RSpec.configure do |config| config.add_setting :committee_options config.committee_options =

    { schema_path: Rails.root.join("docs", "openapi.v1.yaml").to_s } config.include Committee::Rails::Test::Methods end 他にも細かい設定が可能ですが、デフォルトの設定を利⽤しています。 https://github.com/interagent/committee
  2. 使い⽅ describe "GET /" do it "conforms to request schema"

    do assert_request_schema_confirm end it "conforms to response schema" do assert_response_schema_confirm end end
  3. 注意点1 このようにレスポンスステータスを確認しないと、意図していないレスポンスのテストをして いる可能性がある。 RSpec.describe "V1::UsersInformation", type: :request do let(:user) {

    create(:user) } describe "GET /v1/users/me" do it "conforms to response schema of success" do get v1_user_information_index_path, headers: @headers assert_response_schema_confirm expect(response).to have_http_status 200 end it "conforms to response schema of failure" do get v1_user_information_index_path assert_response_schema_confirm expect(response).to have_http_status 401 end end end