|
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 = 50 |
| 7 | + base_points = 100 |
| 8 | + points_per = 5 |
9 | 9 | threshold = 10
|
| 10 | + |
| 11 | + language = stub_language(base_points, points_per, threshold) |
10 | 12 | issue = double(:issue, mass: 15)
|
11 | 13 | hashes = []
|
12 | 14 |
|
13 | 15 | expected_points = base_points + points_per * (issue.mass - threshold)
|
14 | 16 |
|
15 |
| - violation = CC::Engine::Analyzers::Violation.new(base_points, points_per, threshold, issue, hashes) |
| 17 | + violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes) |
16 | 18 | points = violation.calculate_points
|
17 | 19 |
|
18 | 20 | expect(points).to eq(expected_points)
|
|
22 | 24 | context "when issue mass is less than threshold" do
|
23 | 25 | it "uses default" do
|
24 | 26 | base_points = 100
|
25 |
| - points_per = 50 |
| 27 | + points_per = 5 |
26 | 28 | threshold = 18
|
| 29 | + |
| 30 | + language = stub_language(base_points, points_per, threshold) |
27 | 31 | issue = double(:issue, mass: 15)
|
28 | 32 | hashes = []
|
29 | 33 |
|
30 | 34 | expected_points = CC::Engine::Analyzers::Violation::DEFAULT_POINTS
|
31 | 35 |
|
32 |
| - violation = CC::Engine::Analyzers::Violation.new(base_points, points_per, threshold, issue, hashes) |
| 36 | + violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes) |
33 | 37 | points = violation.calculate_points
|
34 | 38 |
|
35 | 39 | expect(points).to eq(CC::Engine::Analyzers::Violation::DEFAULT_POINTS)
|
|
39 | 43 | context "when issue mass equals threshold" do
|
40 | 44 | it "calculates remediation points" do
|
41 | 45 | base_points = 100
|
42 |
| - points_per = 50 |
| 46 | + points_per = 5 |
43 | 47 | threshold = 15
|
| 48 | + |
| 49 | + language = stub_language(base_points, points_per, threshold) |
44 | 50 | issue = double(:issue, mass: 15)
|
45 | 51 | hashes = []
|
46 | 52 |
|
47 | 53 | expected_points = base_points + points_per * (issue.mass - threshold)
|
48 | 54 |
|
49 |
| - violation = CC::Engine::Analyzers::Violation.new(base_points, points_per, threshold, issue, hashes) |
| 55 | + violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes) |
50 | 56 | points = violation.calculate_points
|
51 | 57 |
|
52 | 58 | expect(points).to eq(expected_points)
|
53 | 59 | end
|
54 | 60 | end
|
| 61 | + |
| 62 | + def stub_language(base_points, per_points, threshold) |
| 63 | + double(:language, |
| 64 | + base_points: base_points, |
| 65 | + points_per: per_points, |
| 66 | + mass_threshold: threshold |
| 67 | + ) |
| 68 | + end |
55 | 69 | end
|
56 | 70 | end
|
0 commit comments