|
951 | 951 | context 'with response assertions' do |
952 | 952 | it 'registers an offense when using `assert_response`' do |
953 | 953 | expect_offense(<<~RUBY) |
954 | | - assert_response :ok |
955 | | - ^^^^^^^^^^^^^^^^^^^ Use `expect(response).to have_http_status(:ok)`. |
| 954 | + assert_response :redirect |
| 955 | + ^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(response).to have_http_status(:redirect)`. |
956 | 956 | RUBY |
957 | 957 |
|
958 | 958 | expect_correction(<<~RUBY) |
959 | | - expect(response).to have_http_status(:ok) |
| 959 | + expect(response).to have_http_status(:redirect) |
| 960 | + RUBY |
| 961 | + end |
| 962 | + |
| 963 | + it 'registers an offense when using `assert_response` with a number' do |
| 964 | + expect_offense(<<~RUBY) |
| 965 | + assert_response 302 |
| 966 | + ^^^^^^^^^^^^^^^^^^^ Use `expect(response).to have_http_status(302)`. |
| 967 | + RUBY |
| 968 | + |
| 969 | + expect_correction(<<~RUBY) |
| 970 | + expect(response).to have_http_status(302) |
960 | 971 | RUBY |
961 | 972 | end |
962 | 973 |
|
963 | 974 | it 'registers an offense when using `assert_response` with parentheses' do |
964 | 975 | expect_offense(<<~RUBY) |
965 | | - assert_response(:ok) |
966 | | - ^^^^^^^^^^^^^^^^^^^^ Use `expect(response).to have_http_status(:ok)`. |
| 976 | + assert_response(:success) |
| 977 | + ^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(response).to have_http_status(:success)`. |
967 | 978 | RUBY |
968 | 979 |
|
969 | 980 | expect_correction(<<~RUBY) |
970 | | - expect(response).to have_http_status(:ok) |
| 981 | + expect(response).to have_http_status(:success) |
971 | 982 | RUBY |
972 | 983 | end |
973 | 984 |
|
974 | 985 | it 'registers an offense when using `assert_response` with ' \ |
975 | 986 | 'failure message' do |
976 | 987 | expect_offense(<<~RUBY) |
977 | | - assert_response :ok, "expected OK status" |
978 | | - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(response).to(have_http_status(:ok), "expected OK status")`. |
| 988 | + assert_response :success, "expected success status" |
| 989 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(response).to(have_http_status(:success), "expected success status")`. |
979 | 990 | RUBY |
980 | 991 |
|
981 | 992 | expect_correction(<<~RUBY) |
982 | | - expect(response).to(have_http_status(:ok), "expected OK status") |
| 993 | + expect(response).to(have_http_status(:success), "expected success status") |
983 | 994 | RUBY |
984 | 995 | end |
985 | 996 |
|
986 | 997 | it 'registers an offense when using `assert_response` with ' \ |
987 | 998 | 'multi-line arguments' do |
988 | 999 | expect_offense(<<~RUBY) |
989 | | - assert_response(:ok, |
990 | | - ^^^^^^^^^^^^^^^^^^^^ Use `expect(response).to(have_http_status(:ok), "expected OK status")`. |
991 | | - "expected OK status") |
| 1000 | + assert_response(:redirect, |
| 1001 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(response).to(have_http_status(:redirect), "expected redirect status")`. |
| 1002 | + "expected redirect status") |
992 | 1003 | RUBY |
993 | 1004 |
|
994 | 1005 | expect_correction(<<~RUBY) |
995 | | - expect(response).to(have_http_status(:ok), "expected OK status") |
| 1006 | + expect(response).to(have_http_status(:redirect), "expected redirect status") |
996 | 1007 | RUBY |
997 | 1008 | end |
998 | 1009 |
|
|
1011 | 1022 | it 'does not register an offense when using ' \ |
1012 | 1023 | '`expect(response).to have_http_status`' do |
1013 | 1024 | expect_no_offenses(<<~RUBY) |
1014 | | - expect(response).to have_http_status(:ok) |
| 1025 | + expect(response).to have_http_status(:success) |
1015 | 1026 | RUBY |
1016 | 1027 | end |
1017 | 1028 |
|
|
0 commit comments