|
4 | 4 | describe "#calculate_points" do
|
5 | 5 | context "when issue mass exceeds threshold" do
|
6 | 6 | 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) |
12 | 8 | issue = double(:issue, mass: 15)
|
13 | 9 | hashes = []
|
14 | 10 |
|
15 |
| - expected_points = base_points + points_per * (issue.mass - threshold) |
| 11 | + expected_points = 100 + 5 * (issue.mass - 10) |
16 | 12 |
|
17 | 13 | violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes)
|
18 | 14 | points = violation.calculate_points
|
|
23 | 19 |
|
24 | 20 | context "when issue mass is less than threshold" do
|
25 | 21 | 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) |
31 | 23 | issue = double(:issue, mass: 15)
|
32 | 24 | hashes = []
|
33 | 25 |
|
|
42 | 34 |
|
43 | 35 | context "when issue mass equals threshold" do
|
44 | 36 | 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) |
51 | 39 | hashes = []
|
52 | 40 |
|
53 |
| - expected_points = base_points + points_per * (issue.mass - threshold) |
| 41 | + expected_points = 100 + 5 * (issue.mass - language.mass_threshold) |
54 | 42 |
|
55 | 43 | violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes)
|
56 | 44 | points = violation.calculate_points
|
|
59 | 47 | end
|
60 | 48 | end
|
61 | 49 |
|
62 |
| - def stub_language(base_points, per_points, threshold) |
| 50 | + def stub_language(args) |
63 | 51 | 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] |
67 | 55 | )
|
68 | 56 | end
|
69 | 57 | end
|
|
0 commit comments