Skip to content

Commit e476954

Browse files
author
ABaldwinHunter
committed
refactor specs
1 parent cb193cc commit e476954

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

spec/cc/engine/analyzers/violation_spec.rb

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
describe "#calculate_points" do
55
context "when issue mass exceeds threshold" do
66
it "calculates mass overage points" do
7-
base_points = 100
8-
points_per = 5
9-
threshold = 10
10-
11-
language = stub_language(base_points, points_per, threshold)
7+
language = stub_language(base_points: 100, points_per: 5, mass_threshold: 10)
128
issue = double(:issue, mass: 15)
139
hashes = []
1410

15-
expected_points = base_points + points_per * (issue.mass - threshold)
11+
expected_points = 100 + 5 * (issue.mass - 10)
1612

1713
violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes)
1814
points = violation.calculate_points
@@ -23,11 +19,7 @@
2319

2420
context "when issue mass is less than threshold" do
2521
it "uses default" do
26-
base_points = 100
27-
points_per = 5
28-
threshold = 18
29-
30-
language = stub_language(base_points, points_per, threshold)
22+
language = stub_language(base_points: 100, points_per: 5, mass_threshold: 18)
3123
issue = double(:issue, mass: 15)
3224
hashes = []
3325

@@ -42,15 +34,11 @@
4234

4335
context "when issue mass equals threshold" do
4436
it "calculates remediation points" do
45-
base_points = 100
46-
points_per = 5
47-
threshold = 15
48-
49-
language = stub_language(base_points, points_per, threshold)
50-
issue = double(:issue, mass: 15)
37+
language = stub_language(base_points: 100, points_per: 5, mass_threshold: 18)
38+
issue = double(:issue, mass: language.mass_threshold)
5139
hashes = []
5240

53-
expected_points = base_points + points_per * (issue.mass - threshold)
41+
expected_points = 100 + 5 * (issue.mass - language.mass_threshold)
5442

5543
violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes)
5644
points = violation.calculate_points
@@ -59,11 +47,11 @@
5947
end
6048
end
6149

62-
def stub_language(base_points, per_points, threshold)
50+
def stub_language(args)
6351
double(:language,
64-
base_points: base_points,
65-
points_per: per_points,
66-
mass_threshold: threshold
52+
base_points: args[:base_points],
53+
points_per: args[:points_per],
54+
mass_threshold: args[:mass_threshold]
6755
)
6856
end
6957
end

0 commit comments

Comments
 (0)