|
84 | 84 | end
|
85 | 85 | end
|
86 | 86 |
|
| 87 | + context 'with kind_of assertions' do |
| 88 | + it 'registers an offense when using `assert_kind_of`' do |
| 89 | + expect_offense(<<~RUBY) |
| 90 | + assert_kind_of(a, b) |
| 91 | + ^^^^^^^^^^^^^^^^^^^^ Use `expect(b).to be_a_kind_of(a)`. |
| 92 | + RUBY |
| 93 | + |
| 94 | + expect_correction(<<~RUBY) |
| 95 | + expect(b).to be_a_kind_of(a) |
| 96 | + RUBY |
| 97 | + end |
| 98 | + |
| 99 | + it 'registers an offense when using `assert_kind_of` with ' \ |
| 100 | + 'no parentheses' do |
| 101 | + expect_offense(<<~RUBY) |
| 102 | + assert_kind_of a, b |
| 103 | + ^^^^^^^^^^^^^^^^^^^ Use `expect(b).to be_a_kind_of(a)`. |
| 104 | + RUBY |
| 105 | + |
| 106 | + expect_correction(<<~RUBY) |
| 107 | + expect(b).to be_a_kind_of(a) |
| 108 | + RUBY |
| 109 | + end |
| 110 | + |
| 111 | + it 'registers an offense when using `assert_kind_of` with ' \ |
| 112 | + 'failure message' do |
| 113 | + expect_offense(<<~RUBY) |
| 114 | + assert_kind_of a, b, "must be kind of" |
| 115 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).to(be_a_kind_of(a), "must be kind of")`. |
| 116 | + RUBY |
| 117 | + |
| 118 | + expect_correction(<<~RUBY) |
| 119 | + expect(b).to(be_a_kind_of(a), "must be kind of") |
| 120 | + RUBY |
| 121 | + end |
| 122 | + |
| 123 | + it 'registers an offense when using `assert_kind_of` with ' \ |
| 124 | + 'multi-line arguments' do |
| 125 | + expect_offense(<<~RUBY) |
| 126 | + assert_kind_of(a, |
| 127 | + ^^^^^^^^^^^^^^^^^ Use `expect(b).to(be_a_kind_of(a), "must be kind of")`. |
| 128 | + b, |
| 129 | + "must be kind of") |
| 130 | + RUBY |
| 131 | + |
| 132 | + expect_correction(<<~RUBY) |
| 133 | + expect(b).to(be_a_kind_of(a), "must be kind of") |
| 134 | + RUBY |
| 135 | + end |
| 136 | + |
| 137 | + it 'registers an offense when using `assert_not_kind_of`' do |
| 138 | + expect_offense(<<~RUBY) |
| 139 | + assert_not_kind_of a, b |
| 140 | + ^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).not_to be_a_kind_of(a)`. |
| 141 | + RUBY |
| 142 | + |
| 143 | + expect_correction(<<~RUBY) |
| 144 | + expect(b).not_to be_a_kind_of(a) |
| 145 | + RUBY |
| 146 | + end |
| 147 | + |
| 148 | + it 'registers an offense when using `refute_kind_of`' do |
| 149 | + expect_offense(<<~RUBY) |
| 150 | + refute_kind_of a, b |
| 151 | + ^^^^^^^^^^^^^^^^^^^ Use `expect(b).not_to be_a_kind_of(a)`. |
| 152 | + RUBY |
| 153 | + |
| 154 | + expect_correction(<<~RUBY) |
| 155 | + expect(b).not_to be_a_kind_of(a) |
| 156 | + RUBY |
| 157 | + end |
| 158 | + |
| 159 | + it 'does not register an offense when ' \ |
| 160 | + 'using `expect(b).to be_a_kind_of(a)`' do |
| 161 | + expect_no_offenses(<<~RUBY) |
| 162 | + expect(b).to be_a_kind_of(a) |
| 163 | + RUBY |
| 164 | + end |
| 165 | + |
| 166 | + it 'does not register an offense when ' \ |
| 167 | + 'using `expect(b).not_to be_a_kind_of(a)`' do |
| 168 | + expect_no_offenses(<<~RUBY) |
| 169 | + expect(b).not_to be_a_kind_of(a) |
| 170 | + RUBY |
| 171 | + end |
| 172 | + |
| 173 | + it 'does not register an offense when ' \ |
| 174 | + 'using `expect(b).to be_kind_of(a)`' do |
| 175 | + expect_no_offenses(<<~RUBY) |
| 176 | + expect(b).to be_kind_of(a) |
| 177 | + RUBY |
| 178 | + end |
| 179 | + |
| 180 | + it 'does not register an offense when ' \ |
| 181 | + 'using `expect(b).not_to be_kind_of(a)`' do |
| 182 | + expect_no_offenses(<<~RUBY) |
| 183 | + expect(b).not_to be_kind_of(a) |
| 184 | + RUBY |
| 185 | + end |
| 186 | + end |
| 187 | + |
87 | 188 | context 'with instance_of assertions' do
|
88 | 189 | it 'registers an offense when using `assert_instance_of`' do
|
89 | 190 | expect_offense(<<~RUBY)
|
|
0 commit comments