|
51 | 51 | RUBY |
52 | 52 | end |
53 | 53 |
|
| 54 | + context 'when argument is a String literal' do |
| 55 | + it 'ignores class without namespace' do |
| 56 | + expect_no_offenses(<<-RUBY) |
| 57 | + describe 'Thing' do |
| 58 | + subject { Object.const_get(self.class.description) } |
| 59 | + end |
| 60 | + RUBY |
| 61 | + end |
| 62 | + |
| 63 | + it 'ignores class with namespace' do |
| 64 | + expect_no_offenses(<<-RUBY) |
| 65 | + describe 'Some::Thing' do |
| 66 | + subject { Object.const_get(self.class.description) } |
| 67 | + end |
| 68 | + RUBY |
| 69 | + end |
| 70 | + |
| 71 | + it 'ignores value constants' do |
| 72 | + expect_no_offenses(<<-RUBY) |
| 73 | + describe 'VERSION' do |
| 74 | + subject { Object.const_get(self.class.description) } |
| 75 | + end |
| 76 | + RUBY |
| 77 | + end |
| 78 | + |
| 79 | + it 'ignores value constants with namespace' do |
| 80 | + expect_no_offenses(<<-RUBY) |
| 81 | + describe 'Some::VERSION' do |
| 82 | + subject { Object.const_get(self.class.description) } |
| 83 | + end |
| 84 | + RUBY |
| 85 | + end |
| 86 | + |
| 87 | + it 'ignores top-level constants with `::` at start' do |
| 88 | + expect_no_offenses(<<-RUBY) |
| 89 | + describe '::Some::VERSION' do |
| 90 | + subject { Object.const_get(self.class.description) } |
| 91 | + end |
| 92 | + RUBY |
| 93 | + end |
| 94 | + |
| 95 | + it 'checks `camelCase`' do |
| 96 | + expect_offense(<<-RUBY) |
| 97 | + describe 'activeRecord' do |
| 98 | + ^^^^^^^^^^^^^^ The first argument to describe should be the class or module being tested. |
| 99 | + subject { Object.const_get(self.class.description) } |
| 100 | + end |
| 101 | + RUBY |
| 102 | + end |
| 103 | + |
| 104 | + it 'checks numbers at start' do |
| 105 | + expect_offense(<<-RUBY) |
| 106 | + describe '2Thing' do |
| 107 | + ^^^^^^^^ The first argument to describe should be the class or module being tested. |
| 108 | + subject { Object.const_get(self.class.description) } |
| 109 | + end |
| 110 | + RUBY |
| 111 | + end |
| 112 | + |
| 113 | + it 'checks empty strings' do |
| 114 | + expect_offense(<<-RUBY) |
| 115 | + describe '' do |
| 116 | + ^^ The first argument to describe should be the class or module being tested. |
| 117 | + subject { Object.const_get(self.class.description) } |
| 118 | + end |
| 119 | + RUBY |
| 120 | + end |
| 121 | + end |
| 122 | + |
54 | 123 | it 'ignores request specs' do |
55 | 124 | expect_no_offenses(<<-RUBY) |
56 | 125 | describe 'my new feature', type: :request do |
|
0 commit comments