-
-
Notifications
You must be signed in to change notification settings - Fork 269
/
not_to_not_spec.rb
75 lines (63 loc) · 1.8 KB
/
not_to_not_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
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::RSpec::NotToNot, :config do
context 'when EnforcedStyle is `not_to`' do
let(:cop_config) { { 'EnforcedStyle' => 'not_to' } }
it 'detects the `to_not` offense' do
expect_offense(<<-RUBY)
it { expect(false).to_not be_true }
^^^^^^ Prefer `not_to` over `to_not`.
RUBY
expect_correction(<<-RUBY)
it { expect(false).not_to be_true }
RUBY
end
it 'detects the `to_not` offense on an expect block' do
expect_offense(<<-RUBY)
expect {
2 + 2
}.to_not raise_error
^^^^^^ Prefer `not_to` over `to_not`.
RUBY
expect_correction(<<-RUBY)
expect {
2 + 2
}.not_to raise_error
RUBY
end
it 'detects no offense when using `not_to`' do
expect_no_offenses(<<-RUBY)
it { expect(false).not_to be_true }
RUBY
end
end
context 'when AcceptedMethod is `to_not`' do
let(:cop_config) { { 'EnforcedStyle' => 'to_not' } }
it 'detects the `not_to` offense' do
expect_offense(<<-RUBY)
it { expect(false).not_to be_true }
^^^^^^ Prefer `to_not` over `not_to`.
RUBY
expect_correction(<<-RUBY)
it { expect(false).to_not be_true }
RUBY
end
it 'detects the `not_to` offense on an expect block' do
expect_offense(<<-RUBY)
expect {
2 + 2
}.not_to raise_error
^^^^^^ Prefer `to_not` over `not_to`.
RUBY
expect_correction(<<-RUBY)
expect {
2 + 2
}.to_not raise_error
RUBY
end
it 'detects no offense when using `to_not`' do
expect_no_offenses(<<-RUBY)
it { expect(false).to_not be_true }
RUBY
end
end
end