hexx-suit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +71 -0
- data/.yardopts +3 -0
- data/Guardfile +29 -0
- data/LICENSE +21 -0
- data/README.md +164 -0
- data/Rakefile +18 -0
- data/bin/hexx-suit +14 -0
- data/config/initializers/focus.rb +5 -0
- data/config/initializers/garbage_collection.rb +11 -0
- data/config/initializers/i18n.rb +3 -0
- data/config/initializers/metric_fu.rb +0 -0
- data/config/initializers/random_order.rb +4 -0
- data/config/initializers/rspec.rb +11 -0
- data/lib/hexx-suit.rb +16 -0
- data/lib/hexx/suit.rb +101 -0
- data/lib/hexx/suit/install.rb +85 -0
- data/lib/hexx/suit/install/Guardfile +6 -0
- data/lib/hexx/suit/install/Rakefile +17 -0
- data/lib/hexx/suit/install/_metrics +5 -0
- data/lib/hexx/suit/install/_rspec +2 -0
- data/lib/hexx/suit/install/_rubocop.yml +74 -0
- data/lib/hexx/suit/install/_yardopts +2 -0
- data/lib/hexx/suit/install/metrics/STYLEGUIDE +230 -0
- data/lib/hexx/suit/install/metrics/cane.yml +5 -0
- data/lib/hexx/suit/install/metrics/churn.yml +6 -0
- data/lib/hexx/suit/install/metrics/flay.yml +2 -0
- data/lib/hexx/suit/install/metrics/metric_fu.yml +15 -0
- data/lib/hexx/suit/install/metrics/pippi.yml +3 -0
- data/lib/hexx/suit/install/metrics/reek.yml +1 -0
- data/lib/hexx/suit/install/metrics/roodi.yml +24 -0
- data/lib/hexx/suit/install/metrics/rubocop.yml +79 -0
- data/lib/hexx/suit/install/metrics/saikuro.yml +3 -0
- data/lib/hexx/suit/install/metrics/simplecov.yml +8 -0
- data/lib/hexx/suit/install/metrics/yardstick.yml +37 -0
- data/lib/hexx/suit/metrics/base.rb +96 -0
- data/lib/hexx/suit/metrics/metric_fu.rb +165 -0
- data/lib/hexx/suit/metrics/metric_fu/base.rb +59 -0
- data/lib/hexx/suit/metrics/metric_fu/cane.rb +24 -0
- data/lib/hexx/suit/metrics/metric_fu/churn.rb +24 -0
- data/lib/hexx/suit/metrics/metric_fu/flay.rb +24 -0
- data/lib/hexx/suit/metrics/metric_fu/reek.rb +32 -0
- data/lib/hexx/suit/metrics/metric_fu/roodi.rb +32 -0
- data/lib/hexx/suit/metrics/metric_fu/saikuro.rb +24 -0
- data/lib/hexx/suit/metrics/pippi.rb +89 -0
- data/lib/hexx/suit/metrics/rubocop.rb +39 -0
- data/lib/hexx/suit/metrics/simplecov.rb +119 -0
- data/lib/hexx/suit/metrics/yardstick.rb +91 -0
- data/lib/hexx/suit/utils/system.rb +66 -0
- data/lib/hexx/suit/version.rb +7 -0
- data/lib/tasks/check.rake +32 -0
- data/lib/tasks/check/coverage.rake +27 -0
- data/lib/tasks/check/fu.rake +27 -0
- data/lib/tasks/check/inch.rake +11 -0
- data/lib/tasks/check/pippi.rake +31 -0
- data/lib/tasks/check/rubocop.rake +39 -0
- data/lib/tasks/check/yardstick.rake +27 -0
- data/lib/tasks/debug.rake +6 -0
- data/lib/tasks/test.rake +6 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/config/sandbox.rb +16 -0
- data/spec/support/config/tasks.rb +32 -0
- data/spec/support/sandbox/helpers.rb +62 -0
- data/spec/support/sandbox/matchers.rb +21 -0
- data/spec/tests/bin/install_spec.rb +29 -0
- data/spec/tests/lib/install_spec.rb +34 -0
- data/spec/tests/lib/metrics/metric_fu/cane_spec.rb +32 -0
- data/spec/tests/lib/metrics/metric_fu/churn_spec.rb +31 -0
- data/spec/tests/lib/metrics/metric_fu/flay_spec.rb +27 -0
- data/spec/tests/lib/metrics/metric_fu/reek_spec.rb +22 -0
- data/spec/tests/lib/metrics/metric_fu/roodi_spec.rb +22 -0
- data/spec/tests/lib/metrics/metric_fu/saikuro_spec.rb +30 -0
- data/spec/tests/lib/metrics/metric_fu_spec.rb +181 -0
- data/spec/tests/lib/metrics/pippi_spec.rb +102 -0
- data/spec/tests/lib/metrics/rubocop_spec.rb +58 -0
- data/spec/tests/lib/metrics/simplecov_spec.rb +102 -0
- data/spec/tests/lib/metrics/yardstick_spec.rb +110 -0
- data/spec/tests/lib/utils/system_spec.rb +85 -0
- data/spec/tests/suit_spec.rb +96 -0
- data/spec/tests/tasks/check/coverage/display_spec.rb +49 -0
- data/spec/tests/tasks/check/coverage/run_spec.rb +25 -0
- data/spec/tests/tasks/check/coverage_spec.rb +26 -0
- data/spec/tests/tasks/check/display_spec.rb +50 -0
- data/spec/tests/tasks/check/fu/display_spec.rb +42 -0
- data/spec/tests/tasks/check/fu/run_spec.rb +42 -0
- data/spec/tests/tasks/check/fu_spec.rb +18 -0
- data/spec/tests/tasks/check/inch_spec.rb +19 -0
- data/spec/tests/tasks/check/pippi/display_spec.rb +47 -0
- data/spec/tests/tasks/check/pippi/run_spec.rb +25 -0
- data/spec/tests/tasks/check/pippi_spec.rb +26 -0
- data/spec/tests/tasks/check/rubocop/display_spec.rb +61 -0
- data/spec/tests/tasks/check/rubocop/run_spec.rb +78 -0
- data/spec/tests/tasks/check/rubocop_spec.rb +26 -0
- data/spec/tests/tasks/check/run_spec.rb +44 -0
- data/spec/tests/tasks/check/yardstick/display_spec.rb +51 -0
- data/spec/tests/tasks/check/yardstick/run_spec.rb +20 -0
- data/spec/tests/tasks/check/yardstick_spec.rb +26 -0
- data/spec/tests/tasks/check_spec.rb +56 -0
- data/spec/tests/tasks/debug_spec.rb +21 -0
- data/spec/tests/tasks/test_spec.rb +21 -0
- metadata +414 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Hexx::Suit::Metrics::Rubocop, :sandbox do
|
5
|
+
|
6
|
+
shared_context "without rubocop.yml" do
|
7
|
+
|
8
|
+
let(:options) do
|
9
|
+
{ "output" => "tmp/rubocop/index.html", "format" => "html" }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
shared_context "with rubocop.yml" do
|
14
|
+
|
15
|
+
let(:options) do
|
16
|
+
{ "output" => "custom/rubocop.html", "format" => "custom" }
|
17
|
+
end
|
18
|
+
|
19
|
+
before { prepare_settings options, "config/metrics/rubocop.yml" }
|
20
|
+
end
|
21
|
+
|
22
|
+
shared_examples "environments loader" do
|
23
|
+
|
24
|
+
before { ENV["RUBOCOP_OUTPUT"] = nil }
|
25
|
+
before { ENV["RUBOCOP_FORMAT"] = nil }
|
26
|
+
|
27
|
+
it "[sets RUBOCOP_OUTPUT]" do
|
28
|
+
expect { subject }
|
29
|
+
.to change { ENV["RUBOCOP_OUTPUT"] }
|
30
|
+
.to options["output"]
|
31
|
+
end
|
32
|
+
|
33
|
+
it "[sets RUBOCOP_FORMAT]" do
|
34
|
+
expect { subject }
|
35
|
+
.to change { ENV["RUBOCOP_FORMAT"] }
|
36
|
+
.to options["format"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe ".load" do
|
41
|
+
|
42
|
+
subject { try_in_sandbox { described_class.load } }
|
43
|
+
|
44
|
+
context "when rubocop.yml is absent" do
|
45
|
+
|
46
|
+
include_context "without rubocop.yml"
|
47
|
+
|
48
|
+
it_behaves_like "environments loader"
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when rubocop.yml is present" do
|
52
|
+
|
53
|
+
include_context "with rubocop.yml"
|
54
|
+
|
55
|
+
it_behaves_like "environments loader"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require "simplecov"
|
4
|
+
|
5
|
+
describe Hexx::Suit::Metrics::SimpleCov, :sandbox do
|
6
|
+
|
7
|
+
shared_context "without simplecov.yml" do
|
8
|
+
|
9
|
+
let(:options) do
|
10
|
+
{
|
11
|
+
"output" => "tmp/coverage",
|
12
|
+
"filters" => ["spec/", "config/"],
|
13
|
+
"groups" => {
|
14
|
+
"Libraries" => "lib/",
|
15
|
+
"Application" => "app/"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
shared_context "with simplecov.yml" do
|
22
|
+
|
23
|
+
let(:options) do
|
24
|
+
{
|
25
|
+
"output" => "custom",
|
26
|
+
"filters" => ["custom/"],
|
27
|
+
"groups" => { "Custom" => "custom/" }
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
before { prepare_settings options, "config/metrics/simplecov.yml" }
|
32
|
+
end
|
33
|
+
|
34
|
+
shared_examples "environmets setter" do
|
35
|
+
|
36
|
+
before do
|
37
|
+
ENV["USE_SIMPLECOV"] = nil
|
38
|
+
ENV["SIMPLECOV_OUTPUT"] = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "[sets USE_SIMPLECOV]" do
|
42
|
+
expect { subject }
|
43
|
+
.to change { ENV["USE_SIMPLECOV"] }
|
44
|
+
.to "true"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "[sets SIMPLECOV_OUTPUT]" do
|
48
|
+
expect { subject }
|
49
|
+
.to change { ENV["SIMPLECOV_OUTPUT"] }
|
50
|
+
.to "#{ options['output'] }/index.html"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
shared_examples "metric loader" do
|
55
|
+
|
56
|
+
after { subject }
|
57
|
+
|
58
|
+
it "starts the metric" do
|
59
|
+
expect(::SimpleCov).to receive(:start)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".load" do
|
64
|
+
|
65
|
+
subject { try_in_sandbox { described_class.load } }
|
66
|
+
|
67
|
+
context "without simplecov.yml" do
|
68
|
+
|
69
|
+
include_context "without simplecov.yml"
|
70
|
+
|
71
|
+
it_behaves_like "environmets setter"
|
72
|
+
end
|
73
|
+
|
74
|
+
context "with simplecov.yml" do
|
75
|
+
|
76
|
+
include_context "with simplecov.yml"
|
77
|
+
|
78
|
+
it_behaves_like "environmets setter"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ".run" do
|
83
|
+
|
84
|
+
subject { try_in_sandbox { described_class.run } }
|
85
|
+
|
86
|
+
context "without simplecov.yml" do
|
87
|
+
|
88
|
+
include_context "without simplecov.yml"
|
89
|
+
|
90
|
+
it_behaves_like "environmets setter"
|
91
|
+
it_behaves_like "metric loader"
|
92
|
+
end
|
93
|
+
|
94
|
+
context "with simplecov.yml" do
|
95
|
+
|
96
|
+
include_context "without simplecov.yml"
|
97
|
+
|
98
|
+
it_behaves_like "environmets setter"
|
99
|
+
it_behaves_like "metric loader"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require "yardstick/rake/measurement"
|
4
|
+
|
5
|
+
describe Hexx::Suit::Metrics::Yardstick, :sandbox do
|
6
|
+
|
7
|
+
shared_context "without yardstick.yml" do
|
8
|
+
|
9
|
+
let(:options) do
|
10
|
+
{ "output" => "tmp/yardstick/output.log", "path" => "lib/**/*.rb" }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
shared_context "with yardstick.yml" do
|
15
|
+
|
16
|
+
let(:options) do
|
17
|
+
{ "output" => "custom.log", "path" => "app/**/*.rb" }
|
18
|
+
end
|
19
|
+
|
20
|
+
before { prepare_settings options, "config/metrics/yardstick.yml" }
|
21
|
+
end
|
22
|
+
|
23
|
+
shared_examples "dependency loader" do
|
24
|
+
|
25
|
+
after { subject }
|
26
|
+
|
27
|
+
it "[loads yardstick/rake/measurement]" do
|
28
|
+
expect(described_class).to receive(:require)
|
29
|
+
.with("yardstick/rake/measurement")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
shared_examples "file creator" do
|
34
|
+
|
35
|
+
before { subject }
|
36
|
+
|
37
|
+
it "[prepares output file]" do
|
38
|
+
expect(options["output"]).to be_present_in_sandbox
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
shared_examples "environment setter" do
|
43
|
+
|
44
|
+
before { ENV["YARDSTICK_OUTPUT"] = nil }
|
45
|
+
|
46
|
+
it "sets ENV[YARDSTICK_OUTPUT] to default output" do
|
47
|
+
expect { subject }
|
48
|
+
.to change { ENV["YARDSTICK_OUTPUT"] }
|
49
|
+
.to options["output"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
shared_examples "metric runner" do
|
54
|
+
|
55
|
+
after { subject }
|
56
|
+
|
57
|
+
it "[runs yardstick]" do
|
58
|
+
expect(::Yardstick::Rake::Measurement)
|
59
|
+
.to receive_message_chain(:new, :yardstick_measure)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".load" do
|
64
|
+
|
65
|
+
subject { try_in_sandbox { described_class.load } }
|
66
|
+
|
67
|
+
context "when yardstick.yml is absent" do
|
68
|
+
|
69
|
+
include_context "without yardstick.yml"
|
70
|
+
|
71
|
+
it_behaves_like "dependency loader"
|
72
|
+
it_behaves_like "file creator"
|
73
|
+
it_behaves_like "environment setter"
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when yardstick.yml is present" do
|
77
|
+
|
78
|
+
include_context "with yardstick.yml"
|
79
|
+
|
80
|
+
it_behaves_like "dependency loader"
|
81
|
+
it_behaves_like "file creator"
|
82
|
+
it_behaves_like "environment setter"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe ".run" do
|
87
|
+
|
88
|
+
subject { try_in_sandbox { described_class.run } }
|
89
|
+
|
90
|
+
context "when yardstick.yml is absent" do
|
91
|
+
|
92
|
+
include_context "without yardstick.yml"
|
93
|
+
|
94
|
+
it_behaves_like "dependency loader"
|
95
|
+
it_behaves_like "file creator"
|
96
|
+
it_behaves_like "environment setter"
|
97
|
+
it_behaves_like "metric runner"
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when yardstick.yml is present" do
|
101
|
+
|
102
|
+
include_context "with yardstick.yml"
|
103
|
+
|
104
|
+
it_behaves_like "dependency loader"
|
105
|
+
it_behaves_like "file creator"
|
106
|
+
it_behaves_like "environment setter"
|
107
|
+
it_behaves_like "metric runner"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Hexx::Suit::Utils::System do
|
4
|
+
|
5
|
+
it "is a string" do
|
6
|
+
subject = described_class.new ""
|
7
|
+
expect(subject).to be_kind_of String
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".new" do
|
11
|
+
|
12
|
+
it "removes repetitive spaces from source" do
|
13
|
+
subject = described_class.new "foo bar \n baz"
|
14
|
+
|
15
|
+
expect(subject).to eq "foo bar \n baz"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "strips the source" do
|
19
|
+
subject = described_class.new " foo bar \n baz "
|
20
|
+
|
21
|
+
expect(subject).to eq "foo bar \n baz"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#lines" do
|
26
|
+
|
27
|
+
it "strips lines" do
|
28
|
+
subject = described_class.new " foo bar \n baz "
|
29
|
+
|
30
|
+
expect(subject.lines).to eq ["foo bar", "baz"]
|
31
|
+
end
|
32
|
+
|
33
|
+
it "ignores empty lines" do
|
34
|
+
subject = described_class.new " \nfoo bar\n \nbaz\n "
|
35
|
+
|
36
|
+
expect(subject.lines).to eq ["foo bar", "baz"]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns an array of utilities" do
|
40
|
+
subject = described_class.new "foo bar\nbaz"
|
41
|
+
|
42
|
+
subject.lines.each { |line| expect(line).to be_kind_of described_class }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#call" do
|
47
|
+
|
48
|
+
before { allow_any_instance_of(described_class).to receive :system }
|
49
|
+
after { subject.call }
|
50
|
+
|
51
|
+
context "single line" do
|
52
|
+
|
53
|
+
subject { described_class.new "foo bar" }
|
54
|
+
|
55
|
+
it "sends itself to system" do
|
56
|
+
expect(subject).to receive(:system).with(subject)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "multiline string" do
|
61
|
+
|
62
|
+
subject { described_class.new "foo bar\nbaz" }
|
63
|
+
|
64
|
+
it "sends each line to system" do
|
65
|
+
subject.lines.each do |line|
|
66
|
+
expect(subject).to receive(:system).with(line).ordered
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe ".call" do
|
73
|
+
|
74
|
+
let!(:value) { "foo bar\nbaz" }
|
75
|
+
let!(:utility) { described_class.new value }
|
76
|
+
|
77
|
+
before { allow(described_class).to receive(:new) { utility } }
|
78
|
+
|
79
|
+
it "constucts the utility object and calls it" do
|
80
|
+
expect(described_class).to receive(:new).with(value)
|
81
|
+
expect(utility).to receive :call
|
82
|
+
described_class.call value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Hexx::Suit do
|
4
|
+
|
5
|
+
let(:coverage_settings) { described_class::Metrics::SimpleCov }
|
6
|
+
let(:pippi_settings) { described_class::Metrics::Pippi }
|
7
|
+
let(:rake_tasks) { Rake::Task.tasks.map(&:name) }
|
8
|
+
|
9
|
+
describe ".install_tasks" do
|
10
|
+
|
11
|
+
before { described_class.install_tasks }
|
12
|
+
|
13
|
+
it "installs Gem tasks" do
|
14
|
+
expect(rake_tasks).to include("build", "install", "release")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "installs RSpec tasks" do
|
18
|
+
expect(rake_tasks).to include("spec")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "installs described_class tasks" do
|
22
|
+
expect(rake_tasks).to include(*%w(
|
23
|
+
check
|
24
|
+
check:coverage
|
25
|
+
check:coverage:display
|
26
|
+
check:coverage:run
|
27
|
+
check:display
|
28
|
+
check:fu
|
29
|
+
check:fu:display
|
30
|
+
check:fu:run
|
31
|
+
check:inch
|
32
|
+
check:pippi
|
33
|
+
check:pippi:display
|
34
|
+
check:pippi:run
|
35
|
+
check:rubocop
|
36
|
+
check:rubocop:display
|
37
|
+
check:rubocop:run
|
38
|
+
check:run
|
39
|
+
check:yardstick
|
40
|
+
check:yardstick:display
|
41
|
+
check:yardstick:run
|
42
|
+
debug
|
43
|
+
test
|
44
|
+
))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".load_metrics_for" do
|
49
|
+
|
50
|
+
subject { described_class.load_metrics_for(double) }
|
51
|
+
|
52
|
+
it "returns self" do
|
53
|
+
expect(subject).to eq described_class
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when ENV[USE_SIMPLECOV] is set" do
|
57
|
+
|
58
|
+
before { ENV["USE_SIMPLECOV"] = "true" }
|
59
|
+
|
60
|
+
it "initializes and runs a coverage settings" do
|
61
|
+
expect(coverage_settings).to receive(:run)
|
62
|
+
subject
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when ENV[USE_PIPPI] is set" do
|
67
|
+
|
68
|
+
before { ENV["USE_PIPPI"] = "true" }
|
69
|
+
|
70
|
+
it "initializes and runs a pippi settings" do
|
71
|
+
expect(pippi_settings).to receive(:run)
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when ENV[USE_SIMPLECOV] isn't set" do
|
77
|
+
|
78
|
+
before { ENV["USE_SIMPLECOV"] = nil }
|
79
|
+
|
80
|
+
it "doesn't run settings" do
|
81
|
+
expect(coverage_settings).not_to receive(:run)
|
82
|
+
subject
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "when ENV[USE_PIPPI] isn't set" do
|
87
|
+
|
88
|
+
before { ENV["USE_PIPPI"] = nil }
|
89
|
+
|
90
|
+
it "doesn't run settings" do
|
91
|
+
expect(pippi_settings).not_to receive(:run)
|
92
|
+
subject
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|