rubocop 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- data/.rubocop.yml +6 -0
- data/README.md +18 -6
- data/VERSION +1 -1
- data/bin/rubocop +1 -1
- data/lib/rubocop.rb +3 -0
- data/lib/rubocop/cli.rb +33 -16
- data/lib/rubocop/cop/collection_methods.rb +29 -0
- data/lib/rubocop/cop/cop.rb +1 -1
- data/lib/rubocop/cop/def_parentheses.rb +4 -1
- data/lib/rubocop/cop/encoding.rb +6 -4
- data/lib/rubocop/cop/favor_modifier.rb +5 -5
- data/lib/rubocop/cop/indentation.rb +1 -1
- data/lib/rubocop/cop/syntax.rb +19 -0
- data/lib/rubocop/version.rb +1 -1
- data/rubocop.gemspec +6 -5
- data/spec/rubocop/cli_spec.rb +98 -52
- data/spec/rubocop/cops/align_parameters_spec.rb +29 -29
- data/spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb +4 -4
- data/spec/rubocop/cops/class_and_module_camel_case_spec.rb +4 -4
- data/spec/rubocop/cops/collection_methods_spec.rb +39 -0
- data/spec/rubocop/cops/cop_spec.rb +5 -5
- data/spec/rubocop/cops/def_with_parentheses_spec.rb +5 -5
- data/spec/rubocop/cops/def_without_parentheses_spec.rb +4 -4
- data/spec/rubocop/cops/empty_lines_spec.rb +8 -8
- data/spec/rubocop/cops/encoding_spec.rb +17 -11
- data/spec/rubocop/cops/end_of_line_spec.rb +5 -5
- data/spec/rubocop/cops/favor_modifier_spec.rb +12 -12
- data/spec/rubocop/cops/favor_unless_over_negated_if_spec.rb +8 -8
- data/spec/rubocop/cops/favor_until_over_negated_while_spec.rb +7 -7
- data/spec/rubocop/cops/grammar_spec.rb +14 -9
- data/spec/rubocop/cops/hash_syntax_spec.rb +10 -10
- data/spec/rubocop/cops/if_with_semicolon_spec.rb +3 -3
- data/spec/rubocop/cops/indentation_spec.rb +7 -7
- data/spec/rubocop/cops/line_length_spec.rb +4 -4
- data/spec/rubocop/cops/method_and_variable_snake_case_spec.rb +7 -7
- data/spec/rubocop/cops/multiline_blocks_spec.rb +4 -4
- data/spec/rubocop/cops/multiline_if_then_spec.rb +7 -7
- data/spec/rubocop/cops/new_lambda_literal_spec.rb +4 -4
- data/spec/rubocop/cops/numeric_literals_spec.rb +10 -10
- data/spec/rubocop/cops/offence_spec.rb +4 -4
- data/spec/rubocop/cops/one_line_conditional_spec.rb +2 -3
- data/spec/rubocop/cops/parameter_lists_spec.rb +4 -4
- data/spec/rubocop/cops/parentheses_around_condition_spec.rb +6 -6
- data/spec/rubocop/cops/single_line_blocks_spec.rb +4 -4
- data/spec/rubocop/cops/space_after_colon_spec.rb +5 -5
- data/spec/rubocop/cops/space_after_comma_spec.rb +3 -3
- data/spec/rubocop/cops/space_after_semicolon_spec.rb +3 -3
- data/spec/rubocop/cops/space_around_braces_spec.rb +6 -6
- data/spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb +4 -4
- data/spec/rubocop/cops/space_around_operators_spec.rb +28 -28
- data/spec/rubocop/cops/space_inside_brackets_spec.rb +8 -8
- data/spec/rubocop/cops/space_inside_parens_spec.rb +4 -4
- data/spec/rubocop/cops/string_literals_spec.rb +5 -5
- data/spec/rubocop/cops/syntax_spec.rb +18 -0
- data/spec/rubocop/cops/tab_spec.rb +3 -3
- data/spec/rubocop/cops/ternary_operator_spec.rb +8 -8
- data/spec/rubocop/cops/trailing_whitespace_spec.rb +4 -4
- data/spec/rubocop/cops/unless_else_spec.rb +4 -4
- data/spec/rubocop/cops/when_then_spec.rb +5 -5
- data/spec/rubocop/reports/emacs_style_spec.rb +3 -3
- data/spec/rubocop/reports/report_spec.rb +5 -5
- data/spec/spec_helper.rb +6 -0
- metadata +7 -6
- data/features/rubocop.feature +0 -9
- data/features/step_definitions/rubocop_steps.rb +0 -1
- data/features/support/env.rb +0 -15
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe MethodAndVariableSnakeCase do
|
8
|
-
let
|
8
|
+
let(:snake_case) { MethodAndVariableSnakeCase.new }
|
9
9
|
|
10
10
|
it 'registers an offence for camel case in names' do
|
11
11
|
inspect_source(snake_case, 'file.rb',
|
@@ -15,8 +15,8 @@ module Rubocop
|
|
15
15
|
' @myAttribute = 3',
|
16
16
|
'end',
|
17
17
|
])
|
18
|
-
snake_case.offences.map(&:message).
|
19
|
-
['Use snake_case for methods and variables.'] * 4
|
18
|
+
expect(snake_case.offences.map(&:message)).to eq(
|
19
|
+
['Use snake_case for methods and variables.'] * 4)
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'accepts snake case in names' do
|
@@ -27,20 +27,20 @@ module Rubocop
|
|
27
27
|
' @my_attribute = 3',
|
28
28
|
'end',
|
29
29
|
])
|
30
|
-
snake_case.offences.map(&:message).
|
30
|
+
expect(snake_case.offences.map(&:message)).to be_empty
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'registers an offence for mixed snake case and camel case' do
|
34
34
|
inspect_source(snake_case, 'file.rb',
|
35
35
|
['def visit_Arel_Nodes_SelectStatement',
|
36
36
|
'end'])
|
37
|
-
snake_case.offences.map(&:message).
|
38
|
-
['Use snake_case for methods and variables.']
|
37
|
+
expect(snake_case.offences.map(&:message)).to eq(
|
38
|
+
['Use snake_case for methods and variables.'])
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'accepts screaming snake case globals' do
|
42
42
|
inspect_source(snake_case, 'file.rb', ['$MY_GLOBAL = 0'])
|
43
|
-
snake_case.offences.map(&:message).
|
43
|
+
expect(snake_case.offences.map(&:message)).to be_empty
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -5,19 +5,19 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe MultilineBlocks do
|
8
|
-
let
|
8
|
+
let(:blocks) { MultilineBlocks.new }
|
9
9
|
|
10
10
|
it 'registers an offence for a multiline block with braces' do
|
11
11
|
inspect_source(blocks, '', ['each { |x|',
|
12
12
|
'}'])
|
13
|
-
blocks.offences.map(&:message).
|
14
|
-
['Avoid using {...} for multi-line blocks.']
|
13
|
+
expect(blocks.offences.map(&:message)).to eq(
|
14
|
+
['Avoid using {...} for multi-line blocks.'])
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'accepts a multiline block with do-end' do
|
18
18
|
inspect_source(blocks, '', ['each do |x|',
|
19
19
|
'end'])
|
20
|
-
blocks.offences.map(&:message).
|
20
|
+
expect(blocks.offences.map(&:message)).to be_empty
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe MultilineIfThen do
|
8
|
-
let
|
8
|
+
let(:mit) { MultilineIfThen.new }
|
9
9
|
|
10
10
|
# if
|
11
11
|
|
@@ -18,13 +18,13 @@ module Rubocop
|
|
18
18
|
'end',
|
19
19
|
'if cond then # bad',
|
20
20
|
'end'])
|
21
|
-
mit.offences.map(&:line_number).
|
21
|
+
expect(mit.offences.map(&:line_number)).to eq([1, 3, 5, 7])
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'accepts multiline if without then' do
|
25
25
|
inspect_source(mit, '', ['if cond',
|
26
26
|
'end'])
|
27
|
-
mit.offences.map(&:message).
|
27
|
+
expect(mit.offences.map(&:message)).to be_empty
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'accepts table style if/then/elsif/ends' do
|
@@ -34,7 +34,7 @@ module Rubocop
|
|
34
34
|
'elsif @io == $stderr then str << "$stderr"',
|
35
35
|
'else str << @io.class.to_s',
|
36
36
|
'end'])
|
37
|
-
mit.offences.map(&:message).
|
37
|
+
expect(mit.offences.map(&:message)).to be_empty
|
38
38
|
end
|
39
39
|
|
40
40
|
# unless
|
@@ -42,14 +42,14 @@ module Rubocop
|
|
42
42
|
it 'registers an offence for then in multiline unless' do
|
43
43
|
inspect_source(mit, '', ['unless cond then',
|
44
44
|
'end'])
|
45
|
-
mit.offences.map(&:message).
|
46
|
-
['Never use then for multi-line if/unless.']
|
45
|
+
expect(mit.offences.map(&:message)).to eq(
|
46
|
+
['Never use then for multi-line if/unless.'])
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'accepts multiline unless without then' do
|
50
50
|
inspect_source(mit, '', ['unless cond',
|
51
51
|
'end'])
|
52
|
-
mit.offences.map(&:message).
|
52
|
+
expect(mit.offences.map(&:message)).to be_empty
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -5,18 +5,18 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe NewLambdaLiteral do
|
8
|
-
let
|
8
|
+
let(:lambda_literal) { NewLambdaLiteral.new }
|
9
9
|
|
10
10
|
it 'registers an offence for an old lambda call' do
|
11
11
|
inspect_source(lambda_literal, 'file.rb', ['f = lambda { |x| x }'])
|
12
|
-
lambda_literal.offences.map(&:message).
|
13
|
-
['The new lambda literal syntax is preferred in Ruby 1.9.']
|
12
|
+
expect(lambda_literal.offences.map(&:message)).to eq(
|
13
|
+
['The new lambda literal syntax is preferred in Ruby 1.9.'])
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'accepts the new lambda literal' do
|
17
17
|
inspect_source(lambda_literal, 'file.rb', ['lambda = ->(x) { x }',
|
18
18
|
'lambda.(1)'])
|
19
|
-
lambda_literal.offences.map(&:message).
|
19
|
+
expect(lambda_literal.offences.map(&:message)).to be_empty
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -5,44 +5,44 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe NumericLiterals do
|
8
|
-
let
|
8
|
+
let(:num) { NumericLiterals.new }
|
9
9
|
|
10
10
|
it 'registers an offence for a long integer without underscores' do
|
11
11
|
inspect_source(num, 'file.rb', ['a = 123456'])
|
12
|
-
num.offences.map(&:message).
|
12
|
+
expect(num.offences.map(&:message)).to eq(
|
13
13
|
['Add underscores to large numeric literals to improve their ' +
|
14
|
-
'readability.']
|
14
|
+
'readability.'])
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'registers an offence for an integer with not enough underscores' do
|
18
18
|
inspect_source(num, 'file.rb', ['a = 123456_789000'])
|
19
|
-
num.offences.map(&:message).
|
19
|
+
expect(num.offences.map(&:message)).to eq(
|
20
20
|
['Add underscores to large numeric literals to improve their ' +
|
21
|
-
'readability.']
|
21
|
+
'readability.'])
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'registers an offence for a long float without underscores' do
|
25
25
|
inspect_source(num, 'file.rb', ['a = 1.234567'])
|
26
|
-
num.offences.map(&:message).
|
26
|
+
expect(num.offences.map(&:message)).to eq(
|
27
27
|
['Add underscores to large numeric literals to improve their ' +
|
28
|
-
'readability.']
|
28
|
+
'readability.'])
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'accepts long numbers with underscore' do
|
32
32
|
inspect_source(num, 'file.rb', ['a = 123_456',
|
33
33
|
'b = 1.234_56'])
|
34
|
-
num.offences.map(&:message).
|
34
|
+
expect(num.offences.map(&:message)).to be_empty
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'accepts a short integer without underscore' do
|
38
38
|
inspect_source(num, 'file.rb', ['a = 123'])
|
39
|
-
num.offences.map(&:message).
|
39
|
+
expect(num.offences.map(&:message)).to be_empty
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'accepts short numbers without underscore' do
|
43
43
|
inspect_source(num, 'file.rb', ['a = 123',
|
44
44
|
'b = 123.456'])
|
45
|
-
num.offences.map(&:message).
|
45
|
+
expect(num.offences.map(&:message)).to be_empty
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -8,15 +8,15 @@ module Rubocop
|
|
8
8
|
it 'has a few required attributes' do
|
9
9
|
offence = Offence.new(:convention, 1, 'message')
|
10
10
|
|
11
|
-
offence.severity.
|
12
|
-
offence.line_number.
|
13
|
-
offence.message.
|
11
|
+
expect(offence.severity).to eq(:convention)
|
12
|
+
expect(offence.line_number).to eq(1)
|
13
|
+
expect(offence.message).to eq('message')
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'overrides #to_s' do
|
17
17
|
offence = Offence.new(:convention, 1, 'message')
|
18
18
|
|
19
|
-
offence.to_s.
|
19
|
+
expect(offence.to_s).to eq('C: 1: message')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -5,12 +5,11 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe OneLineConditional do
|
8
|
-
let
|
8
|
+
let(:olc) { OneLineConditional.new }
|
9
9
|
|
10
10
|
it 'registers an offence for one line if/then/end' do
|
11
11
|
inspect_source(olc, '', ['if cond then run else dont end'])
|
12
|
-
olc.offences.map(&:message).
|
13
|
-
['Favor the ternary operator (?:) over if/then/else/end constructs.']
|
12
|
+
expect(olc.offences.map(&:message)).to eq([olc.error_message])
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
@@ -5,19 +5,19 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe ParameterLists do
|
8
|
-
let
|
8
|
+
let(:list) { ParameterLists.new }
|
9
9
|
|
10
10
|
it 'registers an offence for a method def with 5 parameters' do
|
11
11
|
inspect_source(list, 'file.rb', ['def meth(a, b, c, d, e)',
|
12
12
|
'end'])
|
13
|
-
list.offences.map(&:message).
|
14
|
-
['Avoid parameter lists longer than four parameters.']
|
13
|
+
expect(list.offences.map(&:message)).to eq(
|
14
|
+
['Avoid parameter lists longer than four parameters.'])
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'accepts a method def with 4 parameters' do
|
18
18
|
inspect_source(list, 'file.rb', ['def meth(a, b, c, d)',
|
19
19
|
'end'])
|
20
|
-
list.offences.map(&:message).
|
20
|
+
expect(list.offences.map(&:message)).to be_empty
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe ParenthesesAroundCondition do
|
8
|
-
let
|
8
|
+
let(:pac) { ParenthesesAroundCondition.new }
|
9
9
|
|
10
10
|
it 'registers an offence for parentheses around condition' do
|
11
11
|
inspect_source(pac, 'file.rb', ['if (x > 10)',
|
@@ -22,9 +22,9 @@ module Rubocop
|
|
22
22
|
'x += 1 while (x < 10)',
|
23
23
|
'x += 1 until (x < 10)',
|
24
24
|
])
|
25
|
-
pac.offences.map(&:message).
|
25
|
+
expect(pac.offences.map(&:message)).to eq(
|
26
26
|
["Don't use parentheses around the condition of an if/unless/" +
|
27
|
-
'while/until, unless the condition contains an assignment.'] * 9
|
27
|
+
'while/until, unless the condition contains an assignment.'] * 9)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'accepts condition without parentheses' do
|
@@ -41,7 +41,7 @@ module Rubocop
|
|
41
41
|
'x += 1 while x < 10',
|
42
42
|
'x += 1 until x < 10',
|
43
43
|
])
|
44
|
-
pac.offences.map(&:message).
|
44
|
+
expect(pac.offences.map(&:message)).to be_empty
|
45
45
|
end
|
46
46
|
|
47
47
|
# Parentheses are sometimes used to help the editor make nice
|
@@ -51,13 +51,13 @@ module Rubocop
|
|
51
51
|
' @lex_state != EXPR_FNAME &&',
|
52
52
|
' trans[1])',
|
53
53
|
'end'])
|
54
|
-
pac.offences.map(&:message).
|
54
|
+
expect(pac.offences.map(&:message)).to be_empty
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'accepts parentheses around assignment' do
|
58
58
|
inspect_source(pac, 'file.rb', ['if (x = self.next_value)',
|
59
59
|
'end'])
|
60
|
-
pac.offences.map(&:message).
|
60
|
+
expect(pac.offences.map(&:message)).to be_empty
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -5,17 +5,17 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe SingleLineBlocks do
|
8
|
-
let
|
8
|
+
let(:blocks) { SingleLineBlocks.new }
|
9
9
|
|
10
10
|
it 'registers an offence for a single line block with do-end' do
|
11
11
|
inspect_source(blocks, '', ['each do |x| end'])
|
12
|
-
blocks.offences.map(&:message).
|
13
|
-
['Prefer {...} over do...end for single-line blocks.']
|
12
|
+
expect(blocks.offences.map(&:message)).to eq(
|
13
|
+
['Prefer {...} over do...end for single-line blocks.'])
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'accepts a single line block with braces' do
|
17
17
|
inspect_source(blocks, '', ['each { |x| }'])
|
18
|
-
blocks.offences.map(&:message).
|
18
|
+
expect(blocks.offences.map(&:message)).to be_empty
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -5,22 +5,22 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe SpaceAfterColon do
|
8
|
-
let
|
8
|
+
let(:space) { SpaceAfterColon.new }
|
9
9
|
|
10
10
|
it 'registers an offence for colon without space after it' do
|
11
11
|
inspect_source(space, 'file.rb', ['x = w ? {a:3}:4'])
|
12
|
-
space.offences.map(&:message).
|
13
|
-
['Space missing after colon.'] * 2
|
12
|
+
expect(space.offences.map(&:message)).to eq(
|
13
|
+
['Space missing after colon.'] * 2)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'allows the colons in symbols' do
|
17
17
|
inspect_source(space, 'file.rb', ['x = :a'])
|
18
|
-
space.offences.map(&:message).
|
18
|
+
expect(space.offences.map(&:message)).to be_empty
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'allows colons in strings' do
|
22
22
|
inspect_source(space, 'file.rb', ["str << ':'"])
|
23
|
-
space.offences.map(&:message).
|
23
|
+
expect(space.offences.map(&:message)).to be_empty
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -5,12 +5,12 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe SpaceAfterComma do
|
8
|
-
let
|
8
|
+
let(:space) { SpaceAfterComma.new }
|
9
9
|
|
10
10
|
it 'registers an offence for block argument commas' do
|
11
11
|
inspect_source(space, 'file.rb', ['each { |s,t| }'])
|
12
|
-
space.offences.map(&:message).
|
13
|
-
['Space missing after comma.']
|
12
|
+
expect(space.offences.map(&:message)).to eq(
|
13
|
+
['Space missing after comma.'])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,12 +5,12 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe SpaceAfterSemicolon do
|
8
|
-
let
|
8
|
+
let(:space) { SpaceAfterSemicolon.new }
|
9
9
|
|
10
10
|
it 'registers an offence for semicolon without space after it' do
|
11
11
|
inspect_source(space, 'file.rb', ['x = 1;y = 2'])
|
12
|
-
space.offences.map(&:message).
|
13
|
-
['Space missing after semicolon.']
|
12
|
+
expect(space.offences.map(&:message)).to eq(
|
13
|
+
['Space missing after semicolon.'])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,18 +5,18 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe SpaceAroundBraces do
|
8
|
-
let
|
8
|
+
let(:space) { SpaceAroundBraces.new }
|
9
9
|
|
10
10
|
it 'registers an offence for left brace without spaces' do
|
11
11
|
inspect_source(space, 'file.rb', ['each{ puts }'])
|
12
|
-
space.offences.map(&:message).
|
13
|
-
["Surrounding space missing for '{'."]
|
12
|
+
expect(space.offences.map(&:message)).to eq(
|
13
|
+
["Surrounding space missing for '{'."])
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'registers an offence for right brace without inner space' do
|
17
17
|
inspect_source(space, 'file.rb', ['each { puts}'])
|
18
|
-
space.offences.map(&:message).
|
19
|
-
["Space missing to the left of '}'."]
|
18
|
+
expect(space.offences.map(&:message)).to eq(
|
19
|
+
["Space missing to the left of '}'."])
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'accepts an empty hash literal with no space inside' do
|
@@ -25,7 +25,7 @@ module Rubocop
|
|
25
25
|
'end',
|
26
26
|
'@views = {}',
|
27
27
|
''])
|
28
|
-
space.offences.map(&:message).
|
28
|
+
expect(space.offences.map(&:message)).to be_empty
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -5,17 +5,17 @@ require 'spec_helper'
|
|
5
5
|
module Rubocop
|
6
6
|
module Cop
|
7
7
|
describe SpaceAroundEqualsInParameterDefault do
|
8
|
-
let
|
8
|
+
let(:space) { SpaceAroundEqualsInParameterDefault.new }
|
9
9
|
|
10
10
|
it 'registers an offence for default value assignment without space' do
|
11
11
|
inspect_source(space, 'file.rb', ['def f(x, y=0, z=1)', 'end'])
|
12
|
-
space.offences.map(&:message).
|
13
|
-
['Surrounding space missing in default value assignment.'] * 2
|
12
|
+
expect(space.offences.map(&:message)).to eq(
|
13
|
+
['Surrounding space missing in default value assignment.'] * 2)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'accepts default value assignment with space' do
|
17
17
|
inspect_source(space, 'file.rb', ['def f(x, y = 0, z = 1)', 'end'])
|
18
|
-
space.offences.map(&:message).
|
18
|
+
expect(space.offences.map(&:message)).to be_empty
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|