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