|
5 | 5 | describe RailsStats::CodeStatistics do
|
6 | 6 | describe "#to_s" do
|
7 | 7 | TABLE = <<~EOS
|
8 |
| -+----------------------+---------+---------+---------+---------+-----+-------+ |
| 8 | ++-----------------------|------------|----------------+ |
| 9 | +| Name | Total Deps | 1st Level Deps | |
| 10 | ++-----------------------|------------|----------------+ |
| 11 | +| simplecov-console | 7 | 3 | |
| 12 | +| codecov | 4 | 1 | |
| 13 | +| rails_stats | 4 | 2 | |
| 14 | +| simplecov | 3 | 3 | |
| 15 | +| minitest-around | 1 | 1 | |
| 16 | +| bundler | 0 | 0 | |
| 17 | +| byebug | 0 | 0 | |
| 18 | +| minitest | 0 | 0 | |
| 19 | +| minitest-spec-context | 0 | 0 | |
| 20 | ++-----------------------|------------|----------------+ |
| 21 | + \n Declared Gems 9 \n Total Gems 17 \n Unpinned Versions 8 \n Github Refs 0 \n \n+----------------------+---------+---------+---------+---------+-----+-------+ |
9 | 22 | | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
|
10 | 23 | +----------------------+---------+---------+---------+---------+-----+-------+
|
11 | 24 | | Channels | 8 | 8 | 2 | 0 | 0 | 0 |
|
|
14 | 27 | | Helpers | 3 | 3 | 0 | 0 | 0 | 0 |
|
15 | 28 | | Javascripts | 27 | 7 | 0 | 0 | 0 | 0 |
|
16 | 29 | | Jobs | 7 | 2 | 1 | 0 | 0 | 0 |
|
| 30 | +| Libraries | 1 | 1 | 0 | 0 | 0 | 0 | |
17 | 31 | | Mailers | 4 | 4 | 1 | 0 | 0 | 0 |
|
| 32 | +| Model Tests | 5 | 4 | 2 | 0 | 0 | 0 | |
18 | 33 | | Models | 3 | 3 | 1 | 0 | 0 | 0 |
|
| 34 | +| Spec Support | 1 | 1 | 0 | 0 | 0 | 0 | |
| 35 | +| Test Support | 1 | 1 | 0 | 0 | 0 | 0 | |
19 | 36 | +----------------------+---------+---------+---------+---------+-----+-------+
|
20 |
| -| Code | 476 | 144 | 7 | 1 | 0 | 142 | |
21 |
| -| Tests | 0 | 0 | 0 | 0 | 0 | 0 | |
22 |
| -| Total | 476 | 144 | 7 | 1 | 0 | 142 | |
| 37 | +| Code | 477 | 145 | 7 | 1 | 0 | 143 | |
| 38 | +| Tests | 7 | 6 | 2 | 0 | 0 | 0 | |
| 39 | +| Total | 484 | 151 | 9 | 1 | 0 | 149 | |
23 | 40 | +----------------------+---------+---------+---------+---------+-----+-------+
|
24 |
| - Code LOC: 144 Test LOC: 0 Code to Test Ratio: 1:0.0 |
| 41 | + Code LOC: 145 Test LOC: 6 Code to Test Ratio: 1:0.0 |
25 | 42 |
|
26 | 43 | EOS
|
27 | 44 |
|
| 45 | + TABLE_RUBY_2_4 = <<~EOS |
| 46 | ++-----------------------|------------|----------------+ |
| 47 | +| Name | Total Deps | 1st Level Deps | |
| 48 | ++-----------------------|------------|----------------+ |
| 49 | +| simplecov-console | 6 | 3 | |
| 50 | +| rails_stats | 4 | 2 | |
| 51 | +| codecov | 3 | 1 | |
| 52 | +| simplecov | 2 | 2 | |
| 53 | +| minitest-around | 1 | 1 | |
| 54 | +| bundler | 0 | 0 | |
| 55 | +| byebug | 0 | 0 | |
| 56 | +| minitest | 0 | 0 | |
| 57 | +| minitest-spec-context | 0 | 0 | |
| 58 | ++-----------------------|------------|----------------+ |
| 59 | + \n Declared Gems 9 \n Total Gems 16 \n Unpinned Versions 8 \n Github Refs 0 \n \n+----------------------+---------+---------+---------+---------+-----+-------+ |
| 60 | +| Name | Lines | LOC | Classes | Methods | M/C | LOC/M | |
| 61 | ++----------------------+---------+---------+---------+---------+-----+-------+ |
| 62 | +| Channels | 8 | 8 | 2 | 0 | 0 | 0 | |
| 63 | +| Configuration | 417 | 111 | 1 | 0 | 0 | 0 | |
| 64 | +| Controllers | 7 | 6 | 1 | 1 | 1 | 4 | |
| 65 | +| Helpers | 3 | 3 | 0 | 0 | 0 | 0 | |
| 66 | +| Javascripts | 27 | 7 | 0 | 0 | 0 | 0 | |
| 67 | +| Jobs | 7 | 2 | 1 | 0 | 0 | 0 | |
| 68 | +| Libraries | 1 | 1 | 0 | 0 | 0 | 0 | |
| 69 | +| Mailers | 4 | 4 | 1 | 0 | 0 | 0 | |
| 70 | +| Model Tests | 5 | 4 | 2 | 0 | 0 | 0 | |
| 71 | +| Models | 3 | 3 | 1 | 0 | 0 | 0 | |
| 72 | +| Spec Support | 1 | 1 | 0 | 0 | 0 | 0 | |
| 73 | +| Test Support | 1 | 1 | 0 | 0 | 0 | 0 | |
| 74 | ++----------------------+---------+---------+---------+---------+-----+-------+ |
| 75 | +| Code | 477 | 145 | 7 | 1 | 0 | 143 | |
| 76 | +| Tests | 7 | 6 | 2 | 0 | 0 | 0 | |
| 77 | +| Total | 484 | 151 | 9 | 1 | 0 | 149 | |
| 78 | ++----------------------+---------+---------+---------+---------+-----+-------+ |
| 79 | + Code LOC: 145 Test LOC: 6 Code to Test Ratio: 1:0.0 |
| 80 | +
|
| 81 | +EOS |
| 82 | + |
28 | 83 | it "outputs useful stats for a Rails project" do
|
29 | 84 | root_directory = File.expand_path('../../../test/dummy', File.dirname(__FILE__))
|
30 | 85 |
|
31 |
| - assert_output(TABLE) do |
| 86 | + out, err = capture_io do |
32 | 87 | RailsStats::CodeStatistics.new(root_directory).to_s
|
33 | 88 | end
|
| 89 | + |
| 90 | + expectation = if RUBY_VERSION < "2.5.0" |
| 91 | + TABLE_RUBY_2_4 |
| 92 | + else |
| 93 | + TABLE |
| 94 | + end |
| 95 | + |
| 96 | + assert_equal expectation, out |
34 | 97 | end
|
35 | 98 | end
|
36 | 99 | end
|
0 commit comments