|
14 | 14 | end
|
15 | 15 |
|
16 | 16 | describe 'format' do
|
17 |
| - context 'whit line coverage' do |
| 17 | + context 'with line coverage' do |
18 | 18 | it 'works' do
|
19 | 19 | subject.format(result)
|
20 | 20 | expect(json_ouput).to eq(json_result('sample'))
|
21 | 21 | end
|
22 | 22 | end
|
23 | 23 |
|
24 |
| - context 'whit branch coverage' do |
| 24 | + context 'with branch coverage' do |
25 | 25 | let(:original_lines) do
|
26 | 26 | [nil, 1, 1, 1, 1, nil, nil, 1, 1,
|
27 | 27 | nil, nil, 1, 1, 0, nil, 1, nil,
|
|
55 | 55 | expect(json_ouput).to eq(json_result('sample_with_branch'))
|
56 | 56 | end
|
57 | 57 | end
|
| 58 | + |
| 59 | + context 'with groups' do |
| 60 | + let(:result) do |
| 61 | + res = SimpleCov::Result.new({ |
| 62 | + source_fixture('sample.rb') => { 'lines' => [ |
| 63 | + nil, 1, 1, 1, 1, nil, nil, 1, 1, nil, nil, |
| 64 | + 1, 1, 0, nil, 1, nil, nil, nil, nil, 1, 0, nil, nil, nil |
| 65 | + ] } |
| 66 | + }) |
| 67 | + |
| 68 | + # right now SimpleCov works mostly on global state, hence setting the groups that way |
| 69 | + # would be global state --> Mocking is better here |
| 70 | + allow(res).to receive_messages(groups: { 'My Group' => double('File List', covered_percent: 80.0) }) |
| 71 | + res |
| 72 | + end |
| 73 | + |
| 74 | + it 'displays groups correctly in the JSON' do |
| 75 | + subject.format(result) |
| 76 | + expect(json_ouput).to eq(json_result('sample_groups')) |
| 77 | + end |
| 78 | + end |
58 | 79 | end
|
59 | 80 | end
|
0 commit comments