自由帳

既に知っていることも含めて再アウトプット用に書きます✍️

[RuboCop RSpec]Rails

RSpec/Rails/HttpStatus

HTTPステータスを説明するためにシンボルまたは数値の使用を強制します

シンボルの場合(EnforcedStyle: symbolic (default))

# bad
it { is_expected.to have_http_status 200 }
it { is_expected.to have_http_status 404 }

# good
it { is_expected.to have_http_status :ok }
it { is_expected.to have_http_status :not_found }
it { is_expected.to have_http_status :success }
it { is_expected.to have_http_status :error }

数値の場合(EnforcedStyle: numeric)

# bad
it { is_expected.to have_http_status :ok }
it { is_expected.to have_http_status :not_found }

# good
it { is_expected.to have_http_status 200 }
it { is_expected.to have_http_status 404 }
it { is_expected.to have_http_status :success }
it { is_expected.to have_http_status :error }

関連URL

docs.rubocop.org