forked from rubocop/rubocop
/
space_around_singleton_class_operator_spec.rb
65 lines (56 loc) · 1.67 KB
/
space_around_singleton_class_operator_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::Layout::SpaceAroundSingletonClassOperator, :config do
context 'when EnforcedStyle is space' do
let(:cop_config) { { 'EnforcedStyle' => 'space' } }
it 'registers an offense for no space to the left`' do
expect_offense(<<~RUBY)
class<< self
^^^ Use a single space around the singleton class operator.
end
RUBY
end
it 'registers an offense for no space to the right`' do
expect_offense(<<~RUBY)
class <<Other
^^^ Use a single space around the singleton class operator.
end
RUBY
end
it 'registers an offense for no space at all`' do
expect_offense(<<~RUBY)
class<<self
^^ Use a single space around the singleton class operator.
end
RUBY
end
it 'does not register an offense for << surrounded by single spaces' do
expect_no_offenses(<<~RUBY)
class << self
end
RUBY
end
end
context 'when EnforcedStyle is no_space' do
let(:cop_config) { { 'EnforcedStyle' => 'no_space' } }
it 'registers an offense for space to the left`' do
expect_offense(<<~RUBY)
class <<self
^^^ Use no space around the singleton class operator.
end
RUBY
end
it 'registers an offense for space to the right`' do
expect_offense(<<~RUBY)
class<< self
^^^ Use no space around the singleton class operator.
end
RUBY
end
it 'does not register an offense for << surrounded by no space' do
expect_no_offenses(<<~RUBY)
class<<self
end
RUBY
end
end
end