forked from rubocop/rubocop-rspec
/
align_left_let_brace_spec.rb
57 lines (48 loc) · 1.29 KB
/
align_left_let_brace_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
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::RSpec::AlignLeftLetBrace do
subject(:cop) { described_class.new }
# rubocop:disable RSpec/ExampleLength
it 'registers offense for unaligned braces' do
expect_offense(<<-RUBY)
let(:foo) { bar }
^ Align left let brace
let(:hi) { baz }
^ Align left let brace
let(:blahblah) { baz }
let(:thing) { ignore_this }
let(:other) {
ignore_this_too
}
describe 'blah' do
let(:long_name) { thing }
let(:blah) { thing }
^ Align left let brace
let(:a) { thing }
^ Align left let brace
end
RUBY
expect_correction(<<-RUBY)
let(:foo) { bar }
let(:hi) { baz }
let(:blahblah) { baz }
let(:thing) { ignore_this }
let(:other) {
ignore_this_too
}
describe 'blah' do
let(:long_name) { thing }
let(:blah) { thing }
let(:a) { thing }
end
RUBY
end
# rubocop:enable RSpec/ExampleLength
it 'does not register offense for let with proc argument' do
expect_no_offenses(<<-RUBY)
let(:user, &args[:build_user])
RUBY
end
it 'works with empty file' do
expect_no_offenses('')
end
end