rubycritic 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -585
- data/.rubocop_todo.yml +36 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Rakefile +9 -9
- data/bin/rubycritic +2 -2
- data/features/command_line_interface/options.feature +1 -0
- data/features/step_definitions/rubycritic_steps.rb +1 -1
- data/features/step_definitions/sample_file_steps.rb +3 -3
- data/features/support/env.rb +6 -6
- data/lib/rubycritic.rb +1 -1
- data/lib/rubycritic/analysers/attributes.rb +6 -7
- data/lib/rubycritic/analysers/churn.rb +4 -6
- data/lib/rubycritic/analysers/complexity.rb +5 -7
- data/lib/rubycritic/analysers/helpers/ast_node.rb +4 -6
- data/lib/rubycritic/analysers/helpers/flay.rb +1 -3
- data/lib/rubycritic/analysers/helpers/flog.rb +5 -7
- data/lib/rubycritic/analysers/helpers/methods_counter.rb +1 -3
- data/lib/rubycritic/analysers/helpers/modules_locator.rb +3 -5
- data/lib/rubycritic/analysers/helpers/parser.rb +2 -2
- data/lib/rubycritic/analysers/helpers/reek.rb +1 -1
- data/lib/rubycritic/analysers/smells/flay.rb +14 -16
- data/lib/rubycritic/analysers/smells/flog.rb +15 -17
- data/lib/rubycritic/analysers/smells/reek.rb +11 -13
- data/lib/rubycritic/analysers_runner.rb +8 -10
- data/lib/rubycritic/browser.rb +17 -0
- data/lib/rubycritic/cli/application.rb +3 -3
- data/lib/rubycritic/cli/options.rb +29 -23
- data/lib/rubycritic/command_factory.rb +5 -5
- data/lib/rubycritic/commands/base.rb +2 -2
- data/lib/rubycritic/commands/ci.rb +4 -4
- data/lib/rubycritic/commands/default.rb +5 -5
- data/lib/rubycritic/commands/help.rb +1 -1
- data/lib/rubycritic/commands/status_reporter.rb +1 -1
- data/lib/rubycritic/commands/version.rb +2 -2
- data/lib/rubycritic/configuration.rb +4 -2
- data/lib/rubycritic/core/analysed_module.rb +15 -17
- data/lib/rubycritic/core/analysed_modules_collection.rb +3 -3
- data/lib/rubycritic/core/location.rb +4 -6
- data/lib/rubycritic/core/rating.rb +5 -7
- data/lib/rubycritic/core/smell.rb +11 -13
- data/lib/rubycritic/generators/console_report.rb +1 -1
- data/lib/rubycritic/generators/html/base.rb +9 -9
- data/lib/rubycritic/generators/html/code_file.rb +5 -7
- data/lib/rubycritic/generators/html/code_index.rb +3 -5
- data/lib/rubycritic/generators/html/line.rb +4 -6
- data/lib/rubycritic/generators/html/overview.rb +4 -6
- data/lib/rubycritic/generators/html/smells_index.rb +3 -5
- data/lib/rubycritic/generators/html/turbulence.rb +4 -6
- data/lib/rubycritic/generators/html/view_helpers.rb +4 -4
- data/lib/rubycritic/generators/html_report.rb +13 -9
- data/lib/rubycritic/generators/json/simple.rb +7 -9
- data/lib/rubycritic/generators/json_report.rb +1 -3
- data/lib/rubycritic/generators/text/list.rb +9 -9
- data/lib/rubycritic/reporter.rb +3 -5
- data/lib/rubycritic/revision_comparator.rb +6 -8
- data/lib/rubycritic/serializer.rb +2 -4
- data/lib/rubycritic/smells_status_setter.rb +2 -4
- data/lib/rubycritic/source_control_systems/base.rb +4 -6
- data/lib/rubycritic/source_control_systems/double.rb +1 -2
- data/lib/rubycritic/source_control_systems/git.rb +1 -3
- data/lib/rubycritic/source_control_systems/mercurial.rb +1 -3
- data/lib/rubycritic/source_locator.rb +5 -6
- data/lib/rubycritic/version.rb +1 -1
- data/rubycritic.gemspec +26 -25
- data/test/analysers_test_helper.rb +1 -1
- data/test/lib/rubycritic/analysers/churn_test.rb +9 -9
- data/test/lib/rubycritic/analysers/complexity_test.rb +5 -5
- data/test/lib/rubycritic/analysers/helpers/methods_counter_test.rb +12 -12
- data/test/lib/rubycritic/analysers/helpers/modules_locator_test.rb +25 -25
- data/test/lib/rubycritic/analysers/smells/flay_test.rb +12 -12
- data/test/lib/rubycritic/analysers/smells/flog_test.rb +7 -7
- data/test/lib/rubycritic/analysers/smells/reek_test.rb +8 -8
- data/test/lib/rubycritic/browser_test.rb +16 -0
- data/test/lib/rubycritic/commands/status_reporter_test.rb +31 -19
- data/test/lib/rubycritic/configuration_test.rb +10 -10
- data/test/lib/rubycritic/core/analysed_module_test.rb +37 -37
- data/test/lib/rubycritic/core/analysed_modules_collection_test.rb +32 -32
- data/test/lib/rubycritic/core/location_test.rb +16 -16
- data/test/lib/rubycritic/core/smell_test.rb +31 -31
- data/test/lib/rubycritic/core/smells_array_test.rb +18 -18
- data/test/lib/rubycritic/generators/console_report_test.rb +26 -26
- data/test/lib/rubycritic/generators/turbulence_test.rb +8 -8
- data/test/lib/rubycritic/generators/view_helpers_test.rb +36 -36
- data/test/lib/rubycritic/smells_status_setter_test.rb +7 -7
- data/test/lib/rubycritic/source_control_systems/base_test.rb +7 -7
- data/test/lib/rubycritic/source_control_systems/double_test.rb +3 -3
- data/test/lib/rubycritic/source_control_systems/git_test.rb +4 -4
- data/test/lib/rubycritic/source_control_systems/mercurial_test.rb +3 -3
- data/test/lib/rubycritic/source_locator_test.rb +30 -30
- data/test/lib/rubycritic/version_test.rb +4 -4
- data/test/test_helper.rb +4 -4
- metadata +30 -17
@@ -1,37 +1,37 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rubycritic/core/location'
|
3
3
|
|
4
4
|
describe Rubycritic::Location do
|
5
|
-
describe
|
5
|
+
describe 'attribute readers' do
|
6
6
|
before do
|
7
|
-
@path =
|
8
|
-
@line =
|
7
|
+
@path = './foo.rb'
|
8
|
+
@line = '42'
|
9
9
|
@location = Rubycritic::Location.new(@path, @line)
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'has a pathname' do
|
13
13
|
@location.pathname.must_equal Pathname.new(@path)
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'has a line number' do
|
17
17
|
@location.line.must_equal @line.to_i
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
@location.file_name.must_equal
|
20
|
+
it 'has a file name' do
|
21
|
+
@location.file_name.must_equal 'foo'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
location1 = Rubycritic::Location.new(
|
27
|
-
location2 = Rubycritic::Location.new(
|
25
|
+
it 'is comparable' do
|
26
|
+
location1 = Rubycritic::Location.new('./foo', 42)
|
27
|
+
location2 = Rubycritic::Location.new('./foo', 42)
|
28
28
|
location1.must_equal location2
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
location1 = Rubycritic::Location.new(
|
33
|
-
location2 = Rubycritic::Location.new(
|
34
|
-
location3 = Rubycritic::Location.new(
|
31
|
+
it 'is sortable' do
|
32
|
+
location1 = Rubycritic::Location.new('./foo', 42)
|
33
|
+
location2 = Rubycritic::Location.new('./bar', 23)
|
34
|
+
location3 = Rubycritic::Location.new('./bar', 16)
|
35
35
|
[location1, location2, location3].sort.must_equal [location3, location2, location1]
|
36
36
|
end
|
37
37
|
end
|
@@ -1,68 +1,68 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rubycritic/core/smell'
|
3
3
|
|
4
4
|
describe Rubycritic::Smell do
|
5
|
-
describe
|
5
|
+
describe 'attribute readers' do
|
6
6
|
before do
|
7
|
-
@locations = [Rubycritic::Location.new(
|
8
|
-
@context =
|
9
|
-
@message =
|
7
|
+
@locations = [Rubycritic::Location.new('./foo', '42')]
|
8
|
+
@context = '#bar'
|
9
|
+
@message = 'This smells'
|
10
10
|
@score = 0
|
11
11
|
@type = :complexity
|
12
12
|
@smell = Rubycritic::Smell.new(
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
13
|
+
locations: @locations,
|
14
|
+
context: @context,
|
15
|
+
message: @message,
|
16
|
+
score: @score,
|
17
|
+
type: @type
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
21
|
+
it 'has a context reader' do
|
22
22
|
@smell.context.must_equal @context
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it 'has a locations reader' do
|
26
26
|
@smell.locations.must_equal @locations
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'has a message reader' do
|
30
30
|
@smell.message.must_equal @message
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'has a score reader' do
|
34
34
|
@smell.score.must_equal @score
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it 'has a type reader' do
|
38
38
|
@smell.type.must_equal @type
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
43
|
-
it
|
44
|
-
location = Rubycritic::Location.new(
|
45
|
-
smell = Rubycritic::Smell.new(:
|
42
|
+
describe '#at_location?' do
|
43
|
+
it 'returns true if the smell has a location that matches the location passed as argument' do
|
44
|
+
location = Rubycritic::Location.new('./foo', '42')
|
45
|
+
smell = Rubycritic::Smell.new(locations: [location])
|
46
46
|
smell.at_location?(location).must_equal true
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
it
|
52
|
-
location1 = Rubycritic::Location.new(
|
53
|
-
location2 = Rubycritic::Location.new(
|
54
|
-
smell = Rubycritic::Smell.new(:
|
50
|
+
describe '#multiple_locations?' do
|
51
|
+
it 'returns true if the smell has more than one location' do
|
52
|
+
location1 = Rubycritic::Location.new('./foo', '42')
|
53
|
+
location2 = Rubycritic::Location.new('./foo', '23')
|
54
|
+
smell = Rubycritic::Smell.new(locations: [location1, location2])
|
55
55
|
smell.multiple_locations?.must_equal true
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
60
|
-
it
|
59
|
+
describe '#==' do
|
60
|
+
it 'returns true if two smells have the same base attributes' do
|
61
61
|
attributes = {
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
62
|
+
context: '#bar',
|
63
|
+
message: 'This smells',
|
64
|
+
score: 0,
|
65
|
+
type: :complexity
|
66
66
|
}
|
67
67
|
smell1 = Rubycritic::Smell.new(attributes)
|
68
68
|
smell2 = Rubycritic::Smell.new(attributes)
|
@@ -1,28 +1,28 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rubycritic/core/smell'
|
3
3
|
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
location1 = Rubycritic::Location.new(
|
7
|
-
location2 = Rubycritic::Location.new(
|
8
|
-
location3 = Rubycritic::Location.new(
|
9
|
-
smell1 = Rubycritic::Smell.new(:
|
10
|
-
smell2 = Rubycritic::Smell.new(:
|
11
|
-
smell3 = Rubycritic::Smell.new(:
|
4
|
+
describe 'Array of Smells' do
|
5
|
+
it 'is sortable' do
|
6
|
+
location1 = Rubycritic::Location.new('./foo', 42)
|
7
|
+
location2 = Rubycritic::Location.new('./bar', 23)
|
8
|
+
location3 = Rubycritic::Location.new('./bar', 16)
|
9
|
+
smell1 = Rubycritic::Smell.new(locations: [location1])
|
10
|
+
smell2 = Rubycritic::Smell.new(locations: [location2])
|
11
|
+
smell3 = Rubycritic::Smell.new(locations: [location3])
|
12
12
|
[smell1, smell2, smell3].sort.must_equal [smell3, smell2, smell1]
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
smell1 = Rubycritic::Smell.new(:
|
17
|
-
smell2 = Rubycritic::Smell.new(:
|
18
|
-
smell3 = Rubycritic::Smell.new(:
|
15
|
+
it 'implements set intersection' do
|
16
|
+
smell1 = Rubycritic::Smell.new(context: '#bar')
|
17
|
+
smell2 = Rubycritic::Smell.new(context: '#bar')
|
18
|
+
smell3 = Rubycritic::Smell.new(context: '#foo')
|
19
19
|
([smell1, smell3] & [smell2]).must_equal [smell1]
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
smell1 = Rubycritic::Smell.new(:
|
24
|
-
smell2 = Rubycritic::Smell.new(:
|
25
|
-
smell3 = Rubycritic::Smell.new(:
|
22
|
+
it 'implements set union' do
|
23
|
+
smell1 = Rubycritic::Smell.new(context: '#bar')
|
24
|
+
smell2 = Rubycritic::Smell.new(context: '#bar')
|
25
|
+
smell3 = Rubycritic::Smell.new(context: '#foo')
|
26
26
|
([smell1, smell3] | [smell2]).must_equal [smell1, smell3]
|
27
27
|
end
|
28
28
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rubycritic/generators/console_report'
|
3
|
+
require 'rubycritic/core/rating'
|
4
|
+
require 'rubycritic/core/smell'
|
5
5
|
|
6
6
|
describe Rubycritic::Generator::ConsoleReport do
|
7
|
-
describe
|
7
|
+
describe '#generate_report' do
|
8
8
|
before do
|
9
9
|
@mock_analysed_module = mock_analysed_module
|
10
10
|
capture_output_streams do
|
@@ -14,8 +14,8 @@ describe Rubycritic::Generator::ConsoleReport do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
assert @output.size > 0,
|
17
|
+
it 'outputs the report to the stdout' do
|
18
|
+
assert @output.size > 0, 'expected report to be output to stdout'
|
19
19
|
end
|
20
20
|
|
21
21
|
it "starts the report with the module's name" do
|
@@ -24,57 +24,57 @@ describe Rubycritic::Generator::ConsoleReport do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "includes the module's rating in the report" do
|
27
|
-
assert output_contains?(
|
27
|
+
assert output_contains?('Rating', @mock_analysed_module.rating)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "includes the module's rating in the report" do
|
31
|
-
assert output_contains?(
|
31
|
+
assert output_contains?('Churn', @mock_analysed_module.churn)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "includes the module's rating in the report" do
|
35
|
-
assert output_contains?(
|
35
|
+
assert output_contains?('Complexity', @mock_analysed_module.complexity)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "includes the module's rating in the report" do
|
39
|
-
assert output_contains?(
|
39
|
+
assert output_contains?('Duplication', @mock_analysed_module.duplication)
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
assert output_contains?(
|
42
|
+
it 'includes the number of smells in the report' do
|
43
|
+
assert output_contains?('Smells', @mock_analysed_module.smells.count)
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it 'includes the smell and its attributes in the report' do
|
47
47
|
@mock_analysed_module.smells.each do |smell|
|
48
|
-
assert output_contains?(smell),
|
48
|
+
assert output_contains?(smell), 'expected smell type and context to be reported'
|
49
49
|
smell.locations.each do |location|
|
50
|
-
assert output_contains?(location),
|
50
|
+
assert output_contains?(location), 'expected all smell locations to be reported'
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
def output_contains?(*strs)
|
56
56
|
@lines ||= @output.split("\n")
|
57
|
-
expr = strs.map(&:to_s).map! { |s| Regexp.escape(s) }.join(
|
57
|
+
expr = strs.map(&:to_s).map! { |s| Regexp.escape(s) }.join('.*')
|
58
58
|
@lines.any? { |l| l[/#{expr}/] }
|
59
59
|
end
|
60
60
|
|
61
61
|
def mock_analysed_module
|
62
62
|
OpenStruct.new(
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
63
|
+
name: 'TestModule',
|
64
|
+
rating: Rubycritic::Rating.from_cost(3),
|
65
|
+
churn: 10,
|
66
|
+
complexity: 0,
|
67
|
+
duplication: 20,
|
68
|
+
smells: [mock_smell]
|
69
69
|
)
|
70
70
|
end
|
71
71
|
|
72
72
|
def mock_smell
|
73
73
|
smell = Rubycritic::Smell.new
|
74
74
|
smell.locations << Rubycritic::Location.new(__FILE__, 3)
|
75
|
-
smell.type =
|
76
|
-
smell.context =
|
77
|
-
smell.message =
|
75
|
+
smell.type = 'SmellySmell'
|
76
|
+
smell.context = 'You'
|
77
|
+
smell.message = 'Seriously, take a shower or something'
|
78
78
|
smell
|
79
79
|
end
|
80
80
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rubycritic/generators/html/turbulence'
|
3
3
|
|
4
4
|
describe Rubycritic::Turbulence do
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
files = [AnalysedModuleDouble.new(:
|
5
|
+
describe '::data' do
|
6
|
+
it 'returns json data that maps pathname, churn and complexity to name, x and y' do
|
7
|
+
files = [AnalysedModuleDouble.new(name: 'Foo', churn: 1, complexity: 2)]
|
8
8
|
turbulence_data = Rubycritic::Turbulence.data(files)
|
9
9
|
instance_parsed_json = JSON.parse(turbulence_data).first
|
10
|
-
instance_parsed_json[
|
11
|
-
instance_parsed_json[
|
12
|
-
instance_parsed_json[
|
10
|
+
instance_parsed_json['name'].must_equal 'Foo'
|
11
|
+
instance_parsed_json['x'].must_equal 1
|
12
|
+
instance_parsed_json['y'].must_equal 2
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,66 +1,66 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rubycritic/generators/html/view_helpers'
|
3
|
+
require 'pathname'
|
4
4
|
|
5
5
|
describe Rubycritic::ViewHelpers do
|
6
|
-
context
|
7
|
-
let(:generator) { GeneratorDouble.new(
|
6
|
+
context 'when the file is in the root directory' do
|
7
|
+
let(:generator) { GeneratorDouble.new('foo.html') }
|
8
8
|
|
9
|
-
describe
|
10
|
-
context
|
11
|
-
it
|
12
|
-
generator.file_path(
|
9
|
+
describe '#file_path' do
|
10
|
+
context 'when the other file is in the same directory' do
|
11
|
+
it 'creates a relative path to a file' do
|
12
|
+
generator.file_path('bar.html').to_s.must_equal 'bar.html'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
context
|
17
|
-
it
|
18
|
-
generator.file_path(
|
16
|
+
context 'when the other file is in a subdirectory' do
|
17
|
+
it 'creates a relative path to a file' do
|
18
|
+
generator.file_path('subdirectory/bar.html').to_s.must_equal 'subdirectory/bar.html'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it
|
25
|
-
generator.asset_path(
|
26
|
-
|
23
|
+
describe '#asset_path' do
|
24
|
+
it 'creates a relative path to an asset' do
|
25
|
+
generator.asset_path('stylesheets/application.css').to_s
|
26
|
+
.must_equal 'assets/stylesheets/application.css'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
32
|
-
let(:generator) { GeneratorDouble.new(
|
31
|
+
context 'when the file is n directories deep' do
|
32
|
+
let(:generator) { GeneratorDouble.new('lets/go/crazy/foo.html') }
|
33
33
|
|
34
|
-
describe
|
35
|
-
context
|
36
|
-
it
|
37
|
-
generator.file_path(
|
34
|
+
describe '#file_path' do
|
35
|
+
context 'when the other file is in the same directory' do
|
36
|
+
it 'creates a relative path to a file' do
|
37
|
+
generator.file_path('lets/go/crazy/bar.html').to_s.must_equal 'bar.html'
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
context
|
42
|
-
it
|
43
|
-
generator.file_path(
|
41
|
+
context 'when the other file is in the root directory' do
|
42
|
+
it 'creates a relative path to a file' do
|
43
|
+
generator.file_path('bar.html').to_s.must_equal '../../../bar.html'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context
|
48
|
-
it
|
49
|
-
generator.file_path(
|
47
|
+
context 'when the other file has n-1 directories in common' do
|
48
|
+
it 'creates a relative path to a file' do
|
49
|
+
generator.file_path('lets/go/home/bar.html').to_s.must_equal '../home/bar.html'
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
context
|
54
|
-
it
|
55
|
-
generator.file_path(
|
53
|
+
context 'when the other file is one directory deeper' do
|
54
|
+
it 'creates a relative path to a file' do
|
55
|
+
generator.file_path('lets/go/crazy/everybody/bar.html').to_s.must_equal 'everybody/bar.html'
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
61
|
-
it
|
62
|
-
generator.asset_path(
|
63
|
-
|
60
|
+
describe '#asset_path' do
|
61
|
+
it 'creates a relative path to an asset' do
|
62
|
+
generator.asset_path('stylesheets/application.css').to_s
|
63
|
+
.must_equal '../../../assets/stylesheets/application.css'
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -78,6 +78,6 @@ class GeneratorDouble
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def root_directory
|
81
|
-
Pathname.new(
|
81
|
+
Pathname.new('root_directory')
|
82
82
|
end
|
83
83
|
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rubycritic/core/smell'
|
3
|
+
require 'rubycritic/smells_status_setter'
|
4
4
|
|
5
5
|
describe Rubycritic::SmellsStatusSetter do
|
6
|
-
describe
|
6
|
+
describe '::smells' do
|
7
7
|
before do
|
8
|
-
@smell = Rubycritic::Smell.new(:
|
8
|
+
@smell = Rubycritic::Smell.new(context: '#bar')
|
9
9
|
@smells = [@smell]
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'marks old smells' do
|
13
13
|
Rubycritic::SmellsStatusSetter.set(@smells, @smells)
|
14
14
|
@smell.status.must_equal :old
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'marks new smells' do
|
18
18
|
Rubycritic::SmellsStatusSetter.set([], @smells)
|
19
19
|
@smell.status.must_equal :new
|
20
20
|
end
|