reek 1.3.8 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +11 -0
  3. data/README.md +22 -14
  4. data/Rakefile +2 -15
  5. data/assets/html_output.html.erb +103 -0
  6. data/features/command_line_interface/options.feature +3 -0
  7. data/features/command_line_interface/smell_selection.feature +19 -0
  8. data/features/rake_task/rake_task.feature +1 -1
  9. data/features/reports/reports.feature +16 -0
  10. data/features/reports/yaml.feature +26 -23
  11. data/features/samples.feature +2 -1
  12. data/features/step_definitions/reek_steps.rb +15 -15
  13. data/features/support/env.rb +7 -9
  14. data/lib/reek/cli/application.rb +2 -4
  15. data/lib/reek/cli/command.rb +12 -0
  16. data/lib/reek/cli/help_command.rb +3 -6
  17. data/lib/reek/cli/options.rb +147 -0
  18. data/lib/reek/cli/reek_command.rb +18 -14
  19. data/lib/reek/cli/report/formatter.rb +56 -0
  20. data/lib/reek/cli/report/report.rb +106 -0
  21. data/lib/reek/cli/report/strategy.rb +63 -0
  22. data/lib/reek/cli/version_command.rb +3 -6
  23. data/lib/reek/config_file_exception.rb +0 -1
  24. data/lib/reek/core/code_context.rb +1 -3
  25. data/lib/reek/core/code_parser.rb +13 -12
  26. data/lib/reek/core/method_context.rb +13 -2
  27. data/lib/reek/core/module_context.rb +0 -4
  28. data/lib/reek/core/object_refs.rb +2 -3
  29. data/lib/reek/core/singleton_method_context.rb +0 -2
  30. data/lib/reek/core/smell_configuration.rb +3 -5
  31. data/lib/reek/core/smell_repository.rb +7 -8
  32. data/lib/reek/core/sniffer.rb +4 -10
  33. data/lib/reek/core/stop_context.rb +2 -4
  34. data/lib/reek/core/warning_collector.rb +0 -1
  35. data/lib/reek/examiner.rb +19 -17
  36. data/lib/reek/rake/task.rb +7 -10
  37. data/lib/reek/smell_warning.rb +4 -8
  38. data/lib/reek/smells.rb +0 -1
  39. data/lib/reek/smells/attribute.rb +8 -11
  40. data/lib/reek/smells/boolean_parameter.rb +5 -7
  41. data/lib/reek/smells/class_variable.rb +6 -7
  42. data/lib/reek/smells/control_parameter.rb +78 -45
  43. data/lib/reek/smells/data_clump.rb +13 -16
  44. data/lib/reek/smells/duplicate_method_call.rb +13 -11
  45. data/lib/reek/smells/feature_envy.rb +6 -7
  46. data/lib/reek/smells/irresponsible_module.rb +4 -6
  47. data/lib/reek/smells/long_parameter_list.rb +5 -7
  48. data/lib/reek/smells/long_yield_list.rb +2 -4
  49. data/lib/reek/smells/nested_iterators.rb +12 -22
  50. data/lib/reek/smells/nil_check.rb +35 -46
  51. data/lib/reek/smells/prima_donna_method.rb +24 -16
  52. data/lib/reek/smells/repeated_conditional.rb +8 -10
  53. data/lib/reek/smells/smell_detector.rb +9 -7
  54. data/lib/reek/smells/too_many_instance_variables.rb +7 -9
  55. data/lib/reek/smells/too_many_methods.rb +6 -8
  56. data/lib/reek/smells/too_many_statements.rb +4 -6
  57. data/lib/reek/smells/uncommunicative_method_name.rb +5 -7
  58. data/lib/reek/smells/uncommunicative_module_name.rb +5 -7
  59. data/lib/reek/smells/uncommunicative_parameter_name.rb +7 -9
  60. data/lib/reek/smells/uncommunicative_variable_name.rb +15 -18
  61. data/lib/reek/smells/unused_parameters.rb +5 -45
  62. data/lib/reek/smells/utility_function.rb +9 -10
  63. data/lib/reek/source.rb +0 -1
  64. data/lib/reek/source/code_comment.rb +7 -8
  65. data/lib/reek/source/config_file.rb +2 -4
  66. data/lib/reek/source/core_extras.rb +1 -1
  67. data/lib/reek/source/reference_collector.rb +1 -2
  68. data/lib/reek/source/sexp_extensions.rb +93 -10
  69. data/lib/reek/source/sexp_formatter.rb +2 -3
  70. data/lib/reek/source/sexp_node.rb +19 -15
  71. data/lib/reek/source/source_code.rb +4 -14
  72. data/lib/reek/source/source_file.rb +3 -5
  73. data/lib/reek/source/source_locator.rb +5 -6
  74. data/lib/reek/source/source_repository.rb +3 -3
  75. data/lib/reek/source/tree_dresser.rb +2 -2
  76. data/lib/reek/spec.rb +1 -2
  77. data/lib/reek/spec/should_reek.rb +8 -5
  78. data/lib/reek/spec/should_reek_of.rb +6 -4
  79. data/lib/reek/spec/should_reek_only_of.rb +10 -6
  80. data/lib/reek/version.rb +1 -1
  81. data/reek.gemspec +34 -30
  82. data/spec/gem/updates_spec.rb +3 -4
  83. data/spec/gem/yard_spec.rb +1 -2
  84. data/spec/matchers/smell_of_matcher.rb +12 -14
  85. data/spec/quality/reek_source_spec.rb +42 -0
  86. data/spec/reek/cli/help_command_spec.rb +7 -5
  87. data/spec/reek/cli/report_spec.rb +89 -22
  88. data/spec/reek/cli/version_command_spec.rb +8 -6
  89. data/spec/reek/core/code_context_spec.rb +25 -26
  90. data/spec/reek/core/code_parser_spec.rb +6 -6
  91. data/spec/reek/core/method_context_spec.rb +18 -18
  92. data/spec/reek/core/module_context_spec.rb +5 -5
  93. data/spec/reek/core/object_refs_spec.rb +21 -22
  94. data/spec/reek/core/smell_configuration_spec.rb +22 -21
  95. data/spec/reek/core/stop_context_spec.rb +2 -2
  96. data/spec/reek/core/warning_collector_spec.rb +3 -3
  97. data/spec/reek/examiner_spec.rb +9 -9
  98. data/spec/reek/smell_warning_spec.rb +29 -29
  99. data/spec/reek/smells/attribute_spec.rb +6 -6
  100. data/spec/reek/smells/behaves_like_variable_detector.rb +6 -6
  101. data/spec/reek/smells/boolean_parameter_spec.rb +17 -17
  102. data/spec/reek/smells/class_variable_spec.rb +9 -9
  103. data/spec/reek/smells/control_parameter_spec.rb +161 -137
  104. data/spec/reek/smells/data_clump_spec.rb +22 -19
  105. data/spec/reek/smells/duplicate_method_call_spec.rb +71 -27
  106. data/spec/reek/smells/feature_envy_spec.rb +32 -32
  107. data/spec/reek/smells/irresponsible_module_spec.rb +21 -21
  108. data/spec/reek/smells/long_parameter_list_spec.rb +14 -14
  109. data/spec/reek/smells/long_yield_list_spec.rb +6 -6
  110. data/spec/reek/smells/nested_iterators_spec.rb +21 -21
  111. data/spec/reek/smells/nil_check_spec.rb +23 -15
  112. data/spec/reek/smells/prima_donna_method_spec.rb +5 -5
  113. data/spec/reek/smells/repeated_conditional_spec.rb +14 -14
  114. data/spec/reek/smells/smell_detector_shared.rb +9 -9
  115. data/spec/reek/smells/too_many_instance_variables_spec.rb +12 -12
  116. data/spec/reek/smells/too_many_methods_spec.rb +10 -10
  117. data/spec/reek/smells/too_many_statements_spec.rb +41 -41
  118. data/spec/reek/smells/uncommunicative_method_name_spec.rb +4 -4
  119. data/spec/reek/smells/uncommunicative_module_name_spec.rb +12 -12
  120. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +21 -21
  121. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +49 -49
  122. data/spec/reek/smells/unused_parameters_spec.rb +26 -16
  123. data/spec/reek/smells/utility_function_spec.rb +20 -20
  124. data/spec/reek/source/code_comment_spec.rb +37 -37
  125. data/spec/reek/source/object_source_spec.rb +5 -5
  126. data/spec/reek/source/reference_collector_spec.rb +9 -9
  127. data/spec/reek/source/sexp_extensions_spec.rb +73 -52
  128. data/spec/reek/source/sexp_formatter_spec.rb +3 -4
  129. data/spec/reek/source/sexp_node_spec.rb +3 -3
  130. data/spec/reek/source/source_code_spec.rb +16 -15
  131. data/spec/reek/source/tree_dresser_spec.rb +2 -2
  132. data/spec/reek/spec/should_reek_of_spec.rb +11 -11
  133. data/spec/reek/spec/should_reek_only_of_spec.rb +11 -11
  134. data/spec/reek/spec/should_reek_spec.rb +11 -11
  135. data/spec/samples/one_smelly_file/dirty.rb +3 -0
  136. data/spec/spec_helper.rb +0 -6
  137. data/tasks/develop.rake +8 -16
  138. data/tasks/reek.rake +5 -13
  139. data/tasks/test.rake +5 -22
  140. metadata +56 -34
  141. data/lib/reek/cli/command_line.rb +0 -126
  142. data/lib/reek/cli/report.rb +0 -138
@@ -9,74 +9,74 @@ describe CodeComment do
9
9
  @comment = CodeComment.new('')
10
10
  end
11
11
  it 'is not descriptive' do
12
- @comment.is_descriptive?.should be_false
12
+ expect(@comment).not_to be_descriptive
13
13
  end
14
14
  it 'has an empty config' do
15
- @comment.config.should be_empty
15
+ expect(@comment.config).to be_empty
16
16
  end
17
17
  end
18
18
 
19
19
  context 'comment checks' do
20
20
  it 'rejects an empty comment' do
21
- CodeComment.new('#').is_descriptive?.should be_false
21
+ expect(CodeComment.new('#')).not_to be_descriptive
22
22
  end
23
23
  it 'rejects a 1-word comment' do
24
- CodeComment.new("# fred\n# ").is_descriptive?.should be_false
24
+ expect(CodeComment.new("# fred\n# ")).not_to be_descriptive
25
25
  end
26
26
  it 'accepts a 2-word comment' do
27
- CodeComment.new('# fred here ').is_descriptive?.should be_true
27
+ expect(CodeComment.new('# fred here ')).to be_descriptive
28
28
  end
29
29
  it 'accepts a multi-word comment' do
30
- CodeComment.new("# fred here \n# with \n # biscuits ").is_descriptive?.should be_true
30
+ expect(CodeComment.new("# fred here \n# with \n # biscuits ")).to be_descriptive
31
31
  end
32
32
  end
33
33
 
34
34
  context 'comment config' do
35
35
  it 'parses hashed options' do
36
- config = CodeComment.new("# :reek:Duplication: { enabled: false }").config
37
- config.should include('Duplication')
38
- config['Duplication'].should include('enabled')
39
- config['Duplication']['enabled'].should be_false
36
+ config = CodeComment.new('# :reek:Duplication: { enabled: false }').config
37
+ expect(config).to include('Duplication')
38
+ expect(config['Duplication']).to include('enabled')
39
+ expect(config['Duplication']['enabled']).to be_falsey
40
40
  end
41
41
  it 'parses hashed options with ruby names' do
42
- config = CodeComment.new("# :reek:nested_iterators: { enabled: true }").config
43
- config.should include('NestedIterators')
44
- config['NestedIterators'].should include('enabled')
45
- config['NestedIterators']['enabled'].should be_true
42
+ config = CodeComment.new('# :reek:nested_iterators: { enabled: true }').config
43
+ expect(config).to include('NestedIterators')
44
+ expect(config['NestedIterators']).to include('enabled')
45
+ expect(config['NestedIterators']['enabled']).to be_truthy
46
46
  end
47
47
  it 'parses multiple hashed options' do
48
48
  config = CodeComment.new("# :reek:Duplication: { enabled: false }\n:reek:nested_iterators: { enabled: true }").config
49
- config.should include('Duplication','NestedIterators')
50
- config['Duplication'].should include('enabled')
51
- config['Duplication']['enabled'].should be_false
52
- config['NestedIterators'].should include('enabled')
53
- config['NestedIterators']['enabled'].should be_true
49
+ expect(config).to include('Duplication', 'NestedIterators')
50
+ expect(config['Duplication']).to include('enabled')
51
+ expect(config['Duplication']['enabled']).to be_falsey
52
+ expect(config['NestedIterators']).to include('enabled')
53
+ expect(config['NestedIterators']['enabled']).to be_truthy
54
54
  end
55
55
  it 'parses multiple hashed options on the same line' do
56
- config = CodeComment.new("# :reek:Duplication: { enabled: false } and :reek:nested_iterators: { enabled: true }").config
57
- config.should include('Duplication','NestedIterators')
58
- config['Duplication'].should include('enabled')
59
- config['Duplication']['enabled'].should be_false
60
- config['NestedIterators'].should include('enabled')
61
- config['NestedIterators']['enabled'].should be_true
56
+ config = CodeComment.new('# :reek:Duplication: { enabled: false } and :reek:nested_iterators: { enabled: true }').config
57
+ expect(config).to include('Duplication', 'NestedIterators')
58
+ expect(config['Duplication']).to include('enabled')
59
+ expect(config['Duplication']['enabled']).to be_falsey
60
+ expect(config['NestedIterators']).to include('enabled')
61
+ expect(config['NestedIterators']['enabled']).to be_truthy
62
62
  end
63
63
  it 'parses multiple unhashed options on the same line' do
64
- config = CodeComment.new("# :reek:Duplication and :reek:nested_iterators").config
65
- config.should include('Duplication','NestedIterators')
66
- config['Duplication'].should include('enabled')
67
- config['Duplication']['enabled'].should be_false
68
- config['NestedIterators'].should include('enabled')
69
- config['NestedIterators']['enabled'].should be_false
64
+ config = CodeComment.new('# :reek:Duplication and :reek:nested_iterators').config
65
+ expect(config).to include('Duplication', 'NestedIterators')
66
+ expect(config['Duplication']).to include('enabled')
67
+ expect(config['Duplication']['enabled']).to be_falsey
68
+ expect(config['NestedIterators']).to include('enabled')
69
+ expect(config['NestedIterators']['enabled']).to be_falsey
70
70
  end
71
71
  it 'disables the smell if no options are specifed' do
72
- config = CodeComment.new("# :reek:Duplication").config
73
- config.should include('Duplication')
74
- config['Duplication'].should include('enabled')
75
- config['Duplication']['enabled'].should be_false
72
+ config = CodeComment.new('# :reek:Duplication').config
73
+ expect(config).to include('Duplication')
74
+ expect(config['Duplication']).to include('enabled')
75
+ expect(config['Duplication']['enabled']).to be_falsey
76
76
  end
77
77
  it 'ignores smells after a space' do
78
- config = CodeComment.new("# :reek: Duplication").config
79
- config.should_not include('Duplication')
78
+ config = CodeComment.new('# :reek: Duplication').config
79
+ expect(config).not_to include('Duplication')
80
80
  end
81
81
  end
82
82
  end
@@ -5,16 +5,16 @@ include Reek
5
5
  describe Dir do
6
6
  it 'reports correct smells via the Dir matcher' do
7
7
  files = Dir['spec/samples/two_smelly_files/*.rb']
8
- files.should reek
9
- files.should reek_of(:UncommunicativeVariableName)
10
- files.should_not reek_of(:LargeClass)
8
+ expect(files).to reek
9
+ expect(files).to reek_of(:UncommunicativeVariableName)
10
+ expect(files).not_to reek_of(:LargeClass)
11
11
  end
12
12
 
13
13
  it 'copes with daft file specs' do
14
- Dir["spec/samples/two_smelly_files/*/.rb"].should_not reek
14
+ expect(Dir['spec/samples/two_smelly_files/*/.rb']).not_to reek
15
15
  end
16
16
 
17
17
  it 'copes with empty array' do
18
- [].should_not reek
18
+ expect([]).not_to reek
19
19
  end
20
20
  end
@@ -10,28 +10,28 @@ describe ReferenceCollector do
10
10
  ReferenceCollector.new(src.to_reek_source.syntax_tree).num_refs_to_self
11
11
  end
12
12
  it 'with no refs to self' do
13
- refs_to_self('def no_envy(arga) arga.barg end').should == 0
13
+ expect(refs_to_self('def no_envy(arga) arga.barg end')).to eq(0)
14
14
  end
15
15
  it 'counts a call to super' do
16
- refs_to_self('def simple() super; end').should == 1
16
+ expect(refs_to_self('def simple() super; end')).to eq(1)
17
17
  end
18
18
  it 'counts a local call' do
19
- refs_to_self('def simple() to_s; end').should == 1
19
+ expect(refs_to_self('def simple() to_s; end')).to eq(1)
20
20
  end
21
21
  it 'counts a use of self' do
22
- refs_to_self('def simple() lv = self; end').should == 1
22
+ expect(refs_to_self('def simple() lv = self; end')).to eq(1)
23
23
  end
24
24
  it 'counts a call with self as receiver' do
25
- refs_to_self('def simple() self.to_s; end').should == 1
25
+ expect(refs_to_self('def simple() self.to_s; end')).to eq(1)
26
26
  end
27
27
  it 'counts uses of an ivar' do
28
- refs_to_self('def no_envy() @item.to_a; @item = 4; @item end').should == 3
28
+ expect(refs_to_self('def no_envy() @item.to_a; @item = 4; @item end')).to eq(3)
29
29
  end
30
30
  it 'counts an ivar passed to a method' do
31
- refs_to_self('def no_envy(arga) arga.barg(@item); arga end').should == 1
31
+ expect(refs_to_self('def no_envy(arga) arga.barg(@item); arga end')).to eq(1)
32
32
  end
33
33
  it 'ignores global variables' do
34
- refs_to_self('def no_envy(arga) $s2.to_a; $s2[arga] end').should == 0
34
+ expect(refs_to_self('def no_envy(arga) $s2.to_a; $s2[arga] end')).to eq(0)
35
35
  end
36
36
  it 'ignores global variables' do
37
37
  src = <<EOS
@@ -47,7 +47,7 @@ describe ReferenceCollector do
47
47
  @atype[t] = [pat, block]
48
48
  end
49
49
  EOS
50
- refs_to_self(src).should == 2
50
+ expect(refs_to_self(src)).to eq(2)
51
51
  end
52
52
  end
53
53
  end
@@ -10,16 +10,16 @@ describe SexpExtensions::DefnNode do
10
10
  @node.extend(SexpExtensions::DefnNode)
11
11
  end
12
12
  it 'has no arg names' do
13
- @node.arg_names.should == s()
13
+ expect(@node.arg_names).to eq(s())
14
14
  end
15
15
  it 'has no parameter names' do
16
- @node.parameter_names.should == s()
16
+ expect(@node.parameter_names).to eq(s())
17
17
  end
18
18
  it 'includes outer scope in its full name' do
19
- @node.full_name('Fred').should == 'Fred#hello'
19
+ expect(@node.full_name('Fred')).to eq('Fred#hello')
20
20
  end
21
21
  it 'includes no marker in its full name with empty outer scope' do
22
- @node.full_name('').should == 'hello'
22
+ expect(@node.full_name('')).to eq('hello')
23
23
  end
24
24
  end
25
25
 
@@ -29,16 +29,16 @@ describe SexpExtensions::DefnNode do
29
29
  @node.extend(SexpExtensions::DefnNode)
30
30
  end
31
31
  it 'has 1 arg name' do
32
- @node.arg_names.should == s(:param)
32
+ expect(@node.arg_names).to eq(s(:param))
33
33
  end
34
34
  it 'has 1 parameter name' do
35
- @node.parameter_names.should == s(:param)
35
+ expect(@node.parameter_names).to eq(s(:param))
36
36
  end
37
37
  it 'includes outer scope in its full name' do
38
- @node.full_name('Fred').should == 'Fred#hello'
38
+ expect(@node.full_name('Fred')).to eq('Fred#hello')
39
39
  end
40
40
  it 'includes no marker in its full name with empty outer scope' do
41
- @node.full_name('').should == 'hello'
41
+ expect(@node.full_name('')).to eq('hello')
42
42
  end
43
43
  end
44
44
 
@@ -48,16 +48,16 @@ describe SexpExtensions::DefnNode do
48
48
  @node.extend(SexpExtensions::DefnNode)
49
49
  end
50
50
  it 'has 1 arg name' do
51
- @node.arg_names.should == s(:param)
51
+ expect(@node.arg_names).to eq(s(:param))
52
52
  end
53
53
  it 'has 2 parameter names' do
54
- @node.parameter_names.should == s(:param, :"&blk")
54
+ expect(@node.parameter_names).to eq(s(:param, :"&blk"))
55
55
  end
56
56
  it 'includes outer scope in its full name' do
57
- @node.full_name('Fred').should == 'Fred#hello'
57
+ expect(@node.full_name('Fred')).to eq('Fred#hello')
58
58
  end
59
59
  it 'includes no marker in its full name with empty outer scope' do
60
- @node.full_name('').should == 'hello'
60
+ expect(@node.full_name('')).to eq('hello')
61
61
  end
62
62
  end
63
63
 
@@ -67,16 +67,16 @@ describe SexpExtensions::DefnNode do
67
67
  @node.extend(SexpExtensions::DefnNode)
68
68
  end
69
69
  it 'has 1 arg name' do
70
- @node.arg_names.should == s(:param)
70
+ expect(@node.arg_names).to eq(s(:param))
71
71
  end
72
72
  it 'has 1 parameter name' do
73
- @node.parameter_names.should == s(:param)
73
+ expect(@node.parameter_names).to eq(s(:param))
74
74
  end
75
75
  it 'includes outer scope in its full name' do
76
- @node.full_name('Fred').should == 'Fred#hello'
76
+ expect(@node.full_name('Fred')).to eq('Fred#hello')
77
77
  end
78
78
  it 'includes no marker in its full name with empty outer scope' do
79
- @node.full_name('').should == 'hello'
79
+ expect(@node.full_name('')).to eq('hello')
80
80
  end
81
81
  end
82
82
 
@@ -87,12 +87,12 @@ describe SexpExtensions::DefnNode do
87
87
  end
88
88
 
89
89
  it 'has 2 body statements' do
90
- @node.body.should == s(s(:first), s(:second))
90
+ expect(@node.body).to eq(s(s(:first), s(:second)))
91
91
  end
92
92
 
93
93
  it 'has a body extended with SexpNode' do
94
94
  b = @node.body
95
- (class << b; self; end).included_modules.first.should == SexpNode
95
+ expect((class << b; self; end).included_modules.first).to eq(SexpNode)
96
96
  end
97
97
  end
98
98
  end
@@ -104,16 +104,16 @@ describe SexpExtensions::DefsNode do
104
104
  @node.extend(SexpExtensions::DefsNode)
105
105
  end
106
106
  it 'has no arg names' do
107
- @node.arg_names.should == s()
107
+ expect(@node.arg_names).to eq(s())
108
108
  end
109
109
  it 'has no parameter names' do
110
- @node.parameter_names.should == s()
110
+ expect(@node.parameter_names).to eq(s())
111
111
  end
112
112
  it 'includes outer scope in its full name' do
113
- @node.full_name('Fred').should == 'Fred#obj.hello'
113
+ expect(@node.full_name('Fred')).to eq('Fred#obj.hello')
114
114
  end
115
115
  it 'includes no marker in its full name with empty outer scope' do
116
- @node.full_name('').should == 'obj.hello'
116
+ expect(@node.full_name('')).to eq('obj.hello')
117
117
  end
118
118
  end
119
119
 
@@ -123,16 +123,16 @@ describe SexpExtensions::DefsNode do
123
123
  @node.extend(SexpExtensions::DefsNode)
124
124
  end
125
125
  it 'has 1 arg name' do
126
- @node.arg_names.should == s(:param)
126
+ expect(@node.arg_names).to eq(s(:param))
127
127
  end
128
128
  it 'has 1 parameter name' do
129
- @node.parameter_names.should == s(:param)
129
+ expect(@node.parameter_names).to eq(s(:param))
130
130
  end
131
131
  it 'includes outer scope in its full name' do
132
- @node.full_name('Fred').should == 'Fred#obj.hello'
132
+ expect(@node.full_name('Fred')).to eq('Fred#obj.hello')
133
133
  end
134
134
  it 'includes no marker in its full name with empty outer scope' do
135
- @node.full_name('').should == 'obj.hello'
135
+ expect(@node.full_name('')).to eq('obj.hello')
136
136
  end
137
137
  end
138
138
 
@@ -142,16 +142,16 @@ describe SexpExtensions::DefsNode do
142
142
  @node.extend(SexpExtensions::DefsNode)
143
143
  end
144
144
  it 'has 1 arg name' do
145
- @node.arg_names.should == s(:param)
145
+ expect(@node.arg_names).to eq(s(:param))
146
146
  end
147
147
  it 'has 2 parameter names' do
148
- @node.parameter_names.should == s(:param, :"&blk")
148
+ expect(@node.parameter_names).to eq(s(:param, :"&blk"))
149
149
  end
150
150
  it 'includes outer scope in its full name' do
151
- @node.full_name('Fred').should == 'Fred#obj.hello'
151
+ expect(@node.full_name('Fred')).to eq('Fred#obj.hello')
152
152
  end
153
153
  it 'includes no marker in its full name with empty outer scope' do
154
- @node.full_name('').should == 'obj.hello'
154
+ expect(@node.full_name('')).to eq('obj.hello')
155
155
  end
156
156
  end
157
157
 
@@ -161,16 +161,16 @@ describe SexpExtensions::DefsNode do
161
161
  @node.extend(SexpExtensions::DefsNode)
162
162
  end
163
163
  it 'has 1 arg name' do
164
- @node.arg_names.should == s(:param)
164
+ expect(@node.arg_names).to eq(s(:param))
165
165
  end
166
166
  it 'has 1 parameter name' do
167
- @node.parameter_names.should == s(:param)
167
+ expect(@node.parameter_names).to eq(s(:param))
168
168
  end
169
169
  it 'includes outer scope in its full name' do
170
- @node.full_name('Fred').should == 'Fred#obj.hello'
170
+ expect(@node.full_name('Fred')).to eq('Fred#obj.hello')
171
171
  end
172
172
  it 'includes no marker in its full name with empty outer scope' do
173
- @node.full_name('').should == 'obj.hello'
173
+ expect(@node.full_name('')).to eq('obj.hello')
174
174
  end
175
175
  end
176
176
 
@@ -181,12 +181,12 @@ describe SexpExtensions::DefsNode do
181
181
  end
182
182
 
183
183
  it 'has 2 body statements' do
184
- @node.body.should == s(s(:first), s(:second))
184
+ expect(@node.body).to eq(s(s(:first), s(:second)))
185
185
  end
186
186
 
187
187
  it 'has a body extended with SexpNode' do
188
188
  b = @node.body
189
- (class << b; self; end).included_modules.first.should == SexpNode
189
+ expect((class << b; self; end).included_modules.first).to eq(SexpNode)
190
190
  end
191
191
  end
192
192
  end
@@ -198,7 +198,7 @@ describe SexpExtensions::CallNode do
198
198
  @node.extend(SexpExtensions::CallNode)
199
199
  end
200
200
  it 'has no parameter names' do
201
- @node.parameter_names.should == nil
201
+ expect(@node.parameter_names).to eq(nil)
202
202
  end
203
203
  end
204
204
 
@@ -208,7 +208,7 @@ describe SexpExtensions::CallNode do
208
208
  @node.extend(SexpExtensions::CallNode)
209
209
  end
210
210
  it 'has 1 argument name' do
211
- @node.arg_names.should == [:param]
211
+ expect(@node.arg_names).to eq([:param])
212
212
  end
213
213
  end
214
214
 
@@ -218,7 +218,7 @@ describe SexpExtensions::CallNode do
218
218
  @node.extend(SexpExtensions::CallNode)
219
219
  end
220
220
  it 'has 2 argument names' do
221
- @node.arg_names.should == [:x, :y]
221
+ expect(@node.arg_names).to eq([:x, :y])
222
222
  end
223
223
  end
224
224
  end
@@ -230,7 +230,7 @@ describe SexpExtensions::IterNode do
230
230
  @node.extend(SexpExtensions::IterNode)
231
231
  end
232
232
  it 'has no parameter names' do
233
- @node.parameter_names.should == []
233
+ expect(@node.parameter_names).to eq([])
234
234
  end
235
235
  end
236
236
 
@@ -240,7 +240,7 @@ describe SexpExtensions::IterNode do
240
240
  @node.extend(SexpExtensions::IterNode)
241
241
  end
242
242
  it 'has 1 parameter name' do
243
- @node.parameter_names.should == s(:param)
243
+ expect(@node.parameter_names).to eq(s(:param))
244
244
  end
245
245
  end
246
246
 
@@ -250,7 +250,7 @@ describe SexpExtensions::IterNode do
250
250
  @node.extend(SexpExtensions::IterNode)
251
251
  end
252
252
  it 'has 2 parameter names' do
253
- @node.parameter_names.should == [:x, :y]
253
+ expect(@node.parameter_names).to eq([:x, :y])
254
254
  end
255
255
  end
256
256
  end
@@ -261,14 +261,24 @@ describe SexpExtensions::ModuleNode do
261
261
  mod = ast(:module, :Fred, nil)
262
262
  mod
263
263
  end
264
- its(:name) { should == :Fred }
265
- its(:simple_name) { should == :Fred }
266
- its(:text_name) { should == 'Fred' }
264
+
265
+ it 'has the correct #name' do
266
+ expect(subject.name).to eq(:Fred)
267
+ end
268
+
269
+ it 'has the correct #simple_name' do
270
+ expect(subject.simple_name).to eq(:Fred)
271
+ end
272
+
273
+ it 'has the correct #text_name' do
274
+ expect(subject.text_name).to eq('Fred')
275
+ end
276
+
267
277
  it 'has a simple full_name' do
268
- subject.full_name('').should == 'Fred'
278
+ expect(subject.full_name('')).to eq('Fred')
269
279
  end
270
280
  it 'has a fq full_name' do
271
- subject.full_name('Blimey::O::Reilly').should == 'Blimey::O::Reilly::Fred'
281
+ expect(subject.full_name('Blimey::O::Reilly')).to eq('Blimey::O::Reilly::Fred')
272
282
  end
273
283
  end
274
284
 
@@ -277,14 +287,25 @@ describe SexpExtensions::ModuleNode do
277
287
  mod = ast(:module, s(:colon2, s(:const, :Foo), :Bar), nil)
278
288
  mod
279
289
  end
280
- its(:name) { should == s(:colon2, s(:const, :Foo), :Bar) }
281
- its(:simple_name) { should == :Bar }
282
- its(:text_name) { should == 'Foo::Bar' }
290
+
291
+ it 'has the correct #name' do
292
+ expect(subject.name).to eq(s(:colon2, s(:const, :Foo), :Bar))
293
+ end
294
+
295
+ it 'has the correct #simple_name' do
296
+ expect(subject.simple_name).to eq(:Bar)
297
+ end
298
+
299
+ it 'has the correct #text_name' do
300
+ expect(subject.text_name).to eq('Foo::Bar')
301
+ end
302
+
283
303
  it 'has a simple full_name' do
284
- subject.full_name('').should == 'Foo::Bar'
304
+ expect(subject.full_name('')).to eq('Foo::Bar')
285
305
  end
306
+
286
307
  it 'has a fq full_name' do
287
- subject.full_name('Blimey::O::Reilly').should == 'Blimey::O::Reilly::Foo::Bar'
308
+ expect(subject.full_name('Blimey::O::Reilly')).to eq('Blimey::O::Reilly::Foo::Bar')
288
309
  end
289
310
  end
290
311
  end