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.

Files changed (66) hide show
  1. data/.rubocop.yml +6 -0
  2. data/README.md +18 -6
  3. data/VERSION +1 -1
  4. data/bin/rubocop +1 -1
  5. data/lib/rubocop.rb +3 -0
  6. data/lib/rubocop/cli.rb +33 -16
  7. data/lib/rubocop/cop/collection_methods.rb +29 -0
  8. data/lib/rubocop/cop/cop.rb +1 -1
  9. data/lib/rubocop/cop/def_parentheses.rb +4 -1
  10. data/lib/rubocop/cop/encoding.rb +6 -4
  11. data/lib/rubocop/cop/favor_modifier.rb +5 -5
  12. data/lib/rubocop/cop/indentation.rb +1 -1
  13. data/lib/rubocop/cop/syntax.rb +19 -0
  14. data/lib/rubocop/version.rb +1 -1
  15. data/rubocop.gemspec +6 -5
  16. data/spec/rubocop/cli_spec.rb +98 -52
  17. data/spec/rubocop/cops/align_parameters_spec.rb +29 -29
  18. data/spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb +4 -4
  19. data/spec/rubocop/cops/class_and_module_camel_case_spec.rb +4 -4
  20. data/spec/rubocop/cops/collection_methods_spec.rb +39 -0
  21. data/spec/rubocop/cops/cop_spec.rb +5 -5
  22. data/spec/rubocop/cops/def_with_parentheses_spec.rb +5 -5
  23. data/spec/rubocop/cops/def_without_parentheses_spec.rb +4 -4
  24. data/spec/rubocop/cops/empty_lines_spec.rb +8 -8
  25. data/spec/rubocop/cops/encoding_spec.rb +17 -11
  26. data/spec/rubocop/cops/end_of_line_spec.rb +5 -5
  27. data/spec/rubocop/cops/favor_modifier_spec.rb +12 -12
  28. data/spec/rubocop/cops/favor_unless_over_negated_if_spec.rb +8 -8
  29. data/spec/rubocop/cops/favor_until_over_negated_while_spec.rb +7 -7
  30. data/spec/rubocop/cops/grammar_spec.rb +14 -9
  31. data/spec/rubocop/cops/hash_syntax_spec.rb +10 -10
  32. data/spec/rubocop/cops/if_with_semicolon_spec.rb +3 -3
  33. data/spec/rubocop/cops/indentation_spec.rb +7 -7
  34. data/spec/rubocop/cops/line_length_spec.rb +4 -4
  35. data/spec/rubocop/cops/method_and_variable_snake_case_spec.rb +7 -7
  36. data/spec/rubocop/cops/multiline_blocks_spec.rb +4 -4
  37. data/spec/rubocop/cops/multiline_if_then_spec.rb +7 -7
  38. data/spec/rubocop/cops/new_lambda_literal_spec.rb +4 -4
  39. data/spec/rubocop/cops/numeric_literals_spec.rb +10 -10
  40. data/spec/rubocop/cops/offence_spec.rb +4 -4
  41. data/spec/rubocop/cops/one_line_conditional_spec.rb +2 -3
  42. data/spec/rubocop/cops/parameter_lists_spec.rb +4 -4
  43. data/spec/rubocop/cops/parentheses_around_condition_spec.rb +6 -6
  44. data/spec/rubocop/cops/single_line_blocks_spec.rb +4 -4
  45. data/spec/rubocop/cops/space_after_colon_spec.rb +5 -5
  46. data/spec/rubocop/cops/space_after_comma_spec.rb +3 -3
  47. data/spec/rubocop/cops/space_after_semicolon_spec.rb +3 -3
  48. data/spec/rubocop/cops/space_around_braces_spec.rb +6 -6
  49. data/spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb +4 -4
  50. data/spec/rubocop/cops/space_around_operators_spec.rb +28 -28
  51. data/spec/rubocop/cops/space_inside_brackets_spec.rb +8 -8
  52. data/spec/rubocop/cops/space_inside_parens_spec.rb +4 -4
  53. data/spec/rubocop/cops/string_literals_spec.rb +5 -5
  54. data/spec/rubocop/cops/syntax_spec.rb +18 -0
  55. data/spec/rubocop/cops/tab_spec.rb +3 -3
  56. data/spec/rubocop/cops/ternary_operator_spec.rb +8 -8
  57. data/spec/rubocop/cops/trailing_whitespace_spec.rb +4 -4
  58. data/spec/rubocop/cops/unless_else_spec.rb +4 -4
  59. data/spec/rubocop/cops/when_then_spec.rb +5 -5
  60. data/spec/rubocop/reports/emacs_style_spec.rb +3 -3
  61. data/spec/rubocop/reports/report_spec.rb +5 -5
  62. data/spec/spec_helper.rb +6 -0
  63. metadata +7 -6
  64. data/features/rubocop.feature +0 -9
  65. data/features/step_definitions/rubocop_steps.rb +0 -1
  66. data/features/support/env.rb +0 -15
@@ -5,36 +5,42 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe Encoding do
8
- let (:encoding) { Encoding.new }
8
+ let(:encoding) { Encoding.new }
9
9
 
10
- it 'registers an offence when no encoding present' do
10
+ it 'registers an offence when no encoding present', ruby: 1.9 do
11
11
  inspect_source(encoding, 'file.rb', ['def foo() end'])
12
12
 
13
- encoding.offences.map(&:message).should ==
14
- ['Missing encoding comment.']
13
+ expect(encoding.offences.map(&:message)).to eq(
14
+ ['Missing encoding comment.'])
15
15
  end
16
16
 
17
- it 'accepts encoding on first line' do
17
+ it 'accepts encoding on first line', ruby: 1.9 do
18
18
  inspect_source(encoding, 'file.rb', ['# encoding: utf-8',
19
19
  'def foo() end'])
20
20
 
21
- encoding.offences.should == []
21
+ expect(encoding.offences).to be_empty
22
22
  end
23
23
 
24
- it 'accepts encoding on second line when shebang present' do
24
+ it 'accepts encoding on second line when shebang present', ruby: 1.9 do
25
25
  inspect_source(encoding, 'file.rb', ['#!/usr/bin/env ruby',
26
26
  '# encoding: utf-8',
27
27
  'def foo() end'])
28
28
 
29
- encoding.offences.map(&:message).should == []
29
+ expect(encoding.offences.map(&:message)).to be_empty
30
30
  end
31
31
 
32
- it 'registers an offence when encoding is in the wrong place' do
32
+ it 'books an offence when encoding is in the wrong place', ruby: 1.9 do
33
33
  inspect_source(encoding, 'file.rb', ['def foo() end',
34
34
  '# encoding: utf-8'])
35
35
 
36
- encoding.offences.map(&:message).should ==
37
- ['Missing encoding comment.']
36
+ expect(encoding.offences.map(&:message)).to eq(
37
+ ['Missing encoding comment.'])
38
+ end
39
+
40
+ it 'does not register an offence on Ruby 2.0', ruby: 2.0 do
41
+ inspect_source(encoding, 'file.rb', ['def foo() end'])
42
+
43
+ expect(encoding.offences).to be_empty
38
44
  end
39
45
  end
40
46
  end
@@ -5,18 +5,18 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe EndOfLine do
8
- let (:eol) { EndOfLine.new }
8
+ let(:eol) { EndOfLine.new }
9
9
 
10
10
  it 'registers an offence for CR+LF' do
11
11
  inspect_source(eol, 'file.rb', ["x=0\r", ''])
12
- eol.offences.map(&:message).should ==
13
- ['Carriage return character detected.']
12
+ expect(eol.offences.map(&:message)).to eq(
13
+ ['Carriage return character detected.'])
14
14
  end
15
15
 
16
16
  it 'registers an offence for CR at end of file' do
17
17
  inspect_source(eol, 'file.rb', ["x=0\r"])
18
- eol.offences.map(&:message).should ==
19
- ['Carriage return character detected.']
18
+ expect(eol.offences.map(&:message)).to eq(
19
+ ['Carriage return character detected.'])
20
20
  end
21
21
  end
22
22
  end
@@ -5,8 +5,8 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe FavorModifier do
8
- let (:if_until) { IfUnlessModifier.new }
9
- let (:while_until) { WhileUntilModifier.new }
8
+ let(:if_until) { IfUnlessModifier.new }
9
+ let(:while_until) { WhileUntilModifier.new }
10
10
 
11
11
  it 'registers an offence for multiline if that fits on one line' do
12
12
  # This if statement fits exactly on one line if written as a modifier.
@@ -14,9 +14,9 @@ module Rubocop
14
14
  ['if a_condition_that_is_just_short_enough',
15
15
  ' some_long_metod_name(followed_by_args)',
16
16
  'end'])
17
- if_until.offences.map(&:message).should ==
17
+ expect(if_until.offences.map(&:message)).to eq(
18
18
  ['Favor modifier if/unless usage when you have a single-line body.' +
19
- ' Another good alternative is the usage of control flow and/or.']
19
+ ' Another good alternative is the usage of control flow and/or.'])
20
20
  end
21
21
 
22
22
  it "accepts multiline if that doesn't fit on one line" do
@@ -31,23 +31,23 @@ module Rubocop
31
31
  inspect_source(if_until, 'file.rb', ['unless a',
32
32
  ' b',
33
33
  'end'])
34
- if_until.offences.map(&:message).should ==
34
+ expect(if_until.offences.map(&:message)).to eq(
35
35
  ['Favor modifier if/unless usage when you have a single-line body.' +
36
- ' Another good alternative is the usage of control flow and/or.']
36
+ ' Another good alternative is the usage of control flow and/or.'])
37
37
  end
38
38
 
39
39
  it 'accepts code with EOL comment since user might want to keep it' do
40
40
  inspect_source(if_until, 'file.rb', ['unless a',
41
41
  ' b # A comment',
42
42
  'end'])
43
- if_until.offences.map(&:message).should == []
43
+ expect(if_until.offences.map(&:message)).to be_empty
44
44
  end
45
45
 
46
46
  it 'accepts if-else-end' do
47
47
  inspect_source(if_until, 'file.rb',
48
48
  ['if args.last.is_a? Hash then args.pop else ' +
49
49
  'Hash.new end'])
50
- if_until.offences.map(&:message).should == []
50
+ expect(if_until.offences.map(&:message)).to be_empty
51
51
  end
52
52
 
53
53
  it "accepts multiline unless that doesn't fit on one line" do
@@ -86,9 +86,9 @@ module Rubocop
86
86
  inspect_source(cop, 'file.rb', ["#{keyword} a",
87
87
  ' b',
88
88
  'end'])
89
- cop.offences.map(&:message).should ==
89
+ expect(cop.offences.map(&:message)).to eq(
90
90
  ['Favor modifier while/until usage when you have a single-line ' +
91
- 'body.']
91
+ 'body.'])
92
92
  end
93
93
 
94
94
  def check_too_long(cop, keyword)
@@ -96,7 +96,7 @@ module Rubocop
96
96
  [" #{keyword} a_lengthy_condition_that_goes_on_and_on",
97
97
  ' some_long_metod_name(followed_by_args)',
98
98
  ' end'])
99
- cop.offences.map(&:message).should == []
99
+ expect(cop.offences.map(&:message)).to be_empty
100
100
  end
101
101
 
102
102
  def check_short_multiline(cop, keyword)
@@ -105,7 +105,7 @@ module Rubocop
105
105
  " require 'simplecov'",
106
106
  ' SimpleCov.start',
107
107
  'end'])
108
- cop.offences.map(&:message).should == []
108
+ expect(cop.offences.map(&:message)).to be_empty
109
109
  end
110
110
  end
111
111
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe FavorUnlessOverNegatedIf do
8
- let (:fav_unless) { FavorUnlessOverNegatedIf.new }
8
+ let(:fav_unless) { FavorUnlessOverNegatedIf.new }
9
9
 
10
10
  it 'registers an offence for if with exclamation point condition' do
11
11
  inspect_source(fav_unless, 'file.rb',
@@ -14,9 +14,9 @@ module Rubocop
14
14
  'end',
15
15
  'some_method if !a_condition',
16
16
  ])
17
- fav_unless.offences.map(&:message).should ==
17
+ expect(fav_unless.offences.map(&:message)).to eq(
18
18
  ['Favor unless (or control flow or) over if for negative ' +
19
- 'conditions.'] * 2
19
+ 'conditions.'] * 2)
20
20
  end
21
21
 
22
22
  it 'registers an offence for if with "not" condition' do
@@ -25,10 +25,10 @@ module Rubocop
25
25
  ' some_method',
26
26
  'end',
27
27
  'some_method if not a_condition'])
28
- fav_unless.offences.map(&:message).should ==
28
+ expect(fav_unless.offences.map(&:message)).to eq(
29
29
  ['Favor unless (or control flow or) over if for negative ' +
30
- 'conditions.'] * 2
31
- fav_unless.offences.map(&:line_number).should == [1, 4]
30
+ 'conditions.'] * 2)
31
+ expect(fav_unless.offences.map(&:line_number)).to eq([1, 4])
32
32
  end
33
33
 
34
34
  it 'accepts an if/else with negative condition' do
@@ -43,7 +43,7 @@ module Rubocop
43
43
  'elsif other_condition',
44
44
  ' something_else',
45
45
  'end'])
46
- fav_unless.offences.map(&:message).should == []
46
+ expect(fav_unless.offences.map(&:message)).to be_empty
47
47
  end
48
48
 
49
49
  it 'accepts an if where only part of the contition is negated' do
@@ -55,7 +55,7 @@ module Rubocop
55
55
  ' some_method',
56
56
  'end',
57
57
  'some_method if not a_condition or another_condition'])
58
- fav_unless.offences.map(&:message).should == []
58
+ expect(fav_unless.offences.map(&:message)).to be_empty
59
59
  end
60
60
  end
61
61
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe FavorUntilOverNegatedWhile do
8
- let (:fav_until) { FavorUntilOverNegatedWhile.new }
8
+ let(:fav_until) { FavorUntilOverNegatedWhile.new }
9
9
 
10
10
  it 'registers an offence for while with exclamation point condition' do
11
11
  inspect_source(fav_until, 'file.rb',
@@ -14,8 +14,8 @@ module Rubocop
14
14
  'end',
15
15
  'some_method while !a_condition',
16
16
  ])
17
- fav_until.offences.map(&:message).should ==
18
- ['Favor until over while for negative conditions.'] * 2
17
+ expect(fav_until.offences.map(&:message)).to eq(
18
+ ['Favor until over while for negative conditions.'] * 2)
19
19
  end
20
20
 
21
21
  it 'registers an offence for while with "not" condition' do
@@ -24,9 +24,9 @@ module Rubocop
24
24
  ' some_method',
25
25
  'end',
26
26
  'some_method while not a_condition'])
27
- fav_until.offences.map(&:message).should ==
28
- ['Favor until over while for negative conditions.'] * 2
29
- fav_until.offences.map(&:line_number).should == [1, 4]
27
+ expect(fav_until.offences.map(&:message)).to eq(
28
+ ['Favor until over while for negative conditions.'] * 2)
29
+ expect(fav_until.offences.map(&:line_number)).to eq([1, 4])
30
30
  end
31
31
 
32
32
  it 'accepts an while where only part of the contition is negated' do
@@ -38,7 +38,7 @@ module Rubocop
38
38
  ' some_method',
39
39
  'end',
40
40
  'some_method while not a_condition or other_cond'])
41
- fav_until.offences.map(&:message).should == []
41
+ expect(fav_until.offences.map(&:message)).to be_empty
42
42
  end
43
43
  end
44
44
  end
@@ -7,13 +7,12 @@ module Rubocop
7
7
  describe Grammar do
8
8
  EXAMPLE = '3.times { |i| x = "#{y}#{z}}" }'
9
9
  tokens = Ripper.lex(EXAMPLE).map { |t| Token.new(*t) }
10
- let (:grammar) { Grammar.new(tokens) }
10
+ let(:grammar) { Grammar.new(tokens) }
11
11
 
12
- it 'correlates token indices to grammar paths' do
12
+ it 'correlates token indices to grammar paths', ruby: 2.0 do
13
13
  method_block = [:program, :method_add_block]
14
14
  brace_block = method_block + [:brace_block]
15
- Ripper.lex(EXAMPLE).should ==
16
- [[[1, 0], :on_int, '3'],
15
+ test_2_0 = [[[1, 0], :on_int, '3'],
17
16
  [[1, 1], :on_period, '.'],
18
17
  [[1, 2], :on_ident, 'times'],
19
18
  [[1, 7], :on_sp, ' '],
@@ -30,20 +29,21 @@ module Rubocop
30
29
  [[1, 18], :on_tstring_beg, '"'],
31
30
  [[1, 19], :on_embexpr_beg, '#{'], # 15
32
31
  [[1, 21], :on_ident, 'y'],
33
- [[1, 22], :on_rbrace, '}'],
32
+ [[1, 22], :on_embexpr_end, '}'], # [[1, 22], :on_rbrace, '}'],
34
33
  [[1, 23], :on_embexpr_beg, '#{'],
35
34
  [[1, 25], :on_ident, 'z'],
36
- [[1, 26], :on_rbrace, '}'], # 20
35
+ [[1, 26], :on_embexpr_end, '}'], # [[1, 26], :on_rbrace, '}'], # 20
37
36
  [[1, 27], :on_tstring_content, '}'],
38
37
  [[1, 28], :on_tstring_end, '"'],
39
38
  [[1, 29], :on_sp, ' '],
40
39
  [[1, 30], :on_rbrace, '}']]
41
-
40
+ expect(Ripper.lex(EXAMPLE)).to eq(test_2_0) if RUBY_VERSION >= '2.0'
42
41
  sexp = Ripper.sexp(EXAMPLE)
43
42
  Position.make_position_objects(sexp)
44
43
 
45
44
  varref = (RUBY_VERSION == '1.9.2') ? :var_ref : :vcall
46
- grammar.correlate(sexp).should == {
45
+
46
+ test = {
47
47
  0 => method_block + [:call, :@int], # 3
48
48
  2 => method_block + [:call, :@ident], # times
49
49
  4 => brace_block, # {
@@ -58,8 +58,13 @@ module Rubocop
58
58
  :string_embexpr, varref, :@ident], # z
59
59
  21 => brace_block + [:assign, :string_literal, :string_content,
60
60
  :@tstring_content], # }
61
- 24 => brace_block, # }
62
61
  }
62
+ if RUBY_VERSION >= '2.0'
63
+ expect(grammar.correlate(sexp)).to eq(test)
64
+ else
65
+ test = (test[24] = brace_block)
66
+ expect(grammar.correlate(sexp)).to eq(test)
67
+ end
63
68
  end
64
69
  end
65
70
  end
@@ -5,39 +5,39 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe HashSyntax do
8
- let (:hash_syntax) { HashSyntax.new }
8
+ let(:hash_syntax) { HashSyntax.new }
9
9
 
10
10
  it 'registers an offence for hash rocket syntax when new is possible' do
11
11
  inspect_source(hash_syntax, '', ['x = { :a => 0 }'])
12
- hash_syntax.offences.map(&:message).should ==
13
- ['Ruby 1.8 hash syntax detected']
12
+ expect(hash_syntax.offences.map(&:message)).to eq(
13
+ ['Ruby 1.8 hash syntax detected'])
14
14
  end
15
15
 
16
16
  it 'registers an offence for mixed syntax when new is possible' do
17
17
  inspect_source(hash_syntax, '', ['x = { :a => 0, b: 1 }'])
18
- hash_syntax.offences.map(&:message).should ==
19
- ['Ruby 1.8 hash syntax detected']
18
+ expect(hash_syntax.offences.map(&:message)).to eq(
19
+ ['Ruby 1.8 hash syntax detected'])
20
20
  end
21
21
 
22
22
  it 'registers an offence for hash rockets in method calls' do
23
23
  inspect_source(hash_syntax, '', ['func(3, :a => 0)'])
24
- hash_syntax.offences.map(&:message).should ==
25
- ['Ruby 1.8 hash syntax detected']
24
+ expect(hash_syntax.offences.map(&:message)).to eq(
25
+ ['Ruby 1.8 hash syntax detected'])
26
26
  end
27
27
 
28
28
  it 'accepts hash rockets when keys have different types' do
29
29
  inspect_source(hash_syntax, '', ['x = { :a => 0, "b" => 1 }'])
30
- hash_syntax.offences.map(&:message).should == []
30
+ expect(hash_syntax.offences.map(&:message)).to be_empty
31
31
  end
32
32
 
33
33
  it 'accepts new syntax in a hash literal' do
34
34
  inspect_source(hash_syntax, '', ['x = { a: 0, b: 1 }'])
35
- hash_syntax.offences.map(&:message).should == []
35
+ expect(hash_syntax.offences.map(&:message)).to be_empty
36
36
  end
37
37
 
38
38
  it 'accepts new syntax in method calls' do
39
39
  inspect_source(hash_syntax, '', ['func(3, a: 0)'])
40
- hash_syntax.offences.map(&:message).should == []
40
+ expect(hash_syntax.offences.map(&:message)).to be_empty
41
41
  end
42
42
  end
43
43
  end
@@ -5,12 +5,12 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe IfWithSemicolon do
8
- let (:iws) { IfWithSemicolon.new }
8
+ let(:iws) { IfWithSemicolon.new }
9
9
 
10
10
  it 'registers an offence for one line if/;/end' do
11
11
  inspect_source(iws, '', ['if cond; run else dont end'])
12
- iws.offences.map(&:message).should ==
13
- ['Never use if x; Use the ternary operator instead.']
12
+ expect(iws.offences.map(&:message)).to eq(
13
+ ['Never use if x; Use the ternary operator instead.'])
14
14
  end
15
15
  end
16
16
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe Indentation do
8
- let (:ind) { Indentation.new }
8
+ let(:ind) { Indentation.new }
9
9
 
10
10
  it "registers an offence for a when clause that's deeper than case" do
11
11
  source = ['case a',
@@ -15,8 +15,8 @@ module Rubocop
15
15
  ' end',
16
16
  'end']
17
17
  inspect_source(ind, 'file.rb', source)
18
- ind.offences.map(&:message).should ==
19
- ['Indent when as deep as case.'] * 2
18
+ expect(ind.offences.map(&:message)).to eq(
19
+ ['Indent when as deep as case.'] * 2)
20
20
  end
21
21
 
22
22
  it "accepts a when clause that's equally indented with case" do
@@ -33,7 +33,7 @@ module Rubocop
33
33
  'end',
34
34
  '']
35
35
  inspect_source(ind, 'file.rb', source)
36
- ind.offences.size.should == 0
36
+ expect(ind.offences).to be_empty
37
37
  end
38
38
 
39
39
  it "doesn't get confused by strings with case in them" do
@@ -43,7 +43,7 @@ module Rubocop
43
43
  'end',
44
44
  '']
45
45
  inspect_source(ind, 'file.rb', source)
46
- ind.offences.map(&:message).should == []
46
+ expect(ind.offences.map(&:message)).to be_empty
47
47
  end
48
48
 
49
49
  it "doesn't get confused by symbols named case or when" do
@@ -56,7 +56,7 @@ module Rubocop
56
56
  'end',
57
57
  '']
58
58
  inspect_source(ind, 'file.rb', source)
59
- ind.offences.map(&:message).should == []
59
+ expect(ind.offences.map(&:message)).to be_empty
60
60
  end
61
61
 
62
62
  it 'accepts correctly indented whens in complex combinations' do
@@ -79,7 +79,7 @@ module Rubocop
79
79
  'end',
80
80
  '']
81
81
  inspect_source(ind, 'file.rb', source)
82
- ind.offences.map(&:message).should == []
82
+ expect(ind.offences.map(&:message)).to be_empty
83
83
  end
84
84
  end
85
85
  end
@@ -5,17 +5,17 @@ require 'spec_helper'
5
5
  module Rubocop
6
6
  module Cop
7
7
  describe LineLength do
8
- let (:ll) { LineLength.new }
8
+ let(:ll) { LineLength.new }
9
9
 
10
10
  it "registers an offence for a line that's 80 characters wide" do
11
11
  ll.inspect('file.rb', ['#' * 80], nil, nil)
12
- ll.offences.size.should == 1
13
- ll.offences.first.message.should == 'Line is too long. [80/79]'
12
+ expect(ll.offences.size).to eq(1)
13
+ expect(ll.offences.first.message).to eq('Line is too long. [80/79]')
14
14
  end
15
15
 
16
16
  it "accepts a line that's 79 characters wide" do
17
17
  ll.inspect('file.rb', ['#' * 79], nil, nil)
18
- ll.offences.size.should == 0
18
+ expect(ll.offences).to be_empty
19
19
  end
20
20
  end
21
21
  end