File tree 3 files changed +19
-11
lines changed
3 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class Result
18
18
# A YAML object containing the results of the result generation
19
19
# process
20
20
def as_yaml
21
- result_hash . to_yaml
21
+ YAML . to_json ( result_hash )
22
22
end
23
23
24
24
def per_file_data
Original file line number Diff line number Diff line change 50
50
out = MetricFu ::Utility . capture_output {
51
51
MetricFu ::Formatter ::YAML . new ( output : @output ) . finish
52
52
}
53
- expect ( out ) . to include ":#{ @metric1 } :"
54
- expect ( out ) . to include ":#{ @metric2 } :"
53
+ expected_output = YAML . to_json (
54
+ "#{ @metric1 } " => {
55
+ "total_violations" => 0 ,
56
+ "violations" => { } ,
57
+ } ,
58
+ "#{ @metric2 } " => {
59
+ "files" => [ ] ,
60
+ "classes" => [ ] ,
61
+ "methods" => [ ] ,
62
+ }
63
+ )
64
+ expect ( out ) . to eq ( expected_output )
55
65
end
56
66
end
57
67
Original file line number Diff line number Diff line change 16
16
17
17
describe "#as_yaml" do
18
18
it "should call #result_hash" do
19
- result_hash = double ( "result_hash" )
20
- expect ( result_hash ) . to receive ( :to_yaml )
21
-
22
- expect ( @result ) . to receive ( :result_hash ) . and_return ( result_hash )
23
- @result . as_yaml
19
+ result_hash = { "hi" => "there" }
20
+ @result . result_hash . update ( result_hash )
21
+ yaml = @result . as_yaml
22
+ expected_yaml = '{"hi": "there"}' << "\n "
23
+ expect ( yaml ) . to eq ( expected_yaml )
24
+ expect ( JSON . load ( yaml ) ) . to eq ( result_hash )
24
25
end
25
26
end
26
27
27
- describe "#result_hash" do
28
- end
29
-
30
28
describe "#add" do
31
29
it "should add a passed hash to the result_hash instance variable" do
32
30
result_type = double ( "result_type" )
You can’t perform that action at this time.
0 commit comments