coverband 2.0.3 → 3.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +73 -0
  4. data/.travis.yml +0 -3
  5. data/README.md +3 -3
  6. data/changes.md +65 -49
  7. data/coverband.gemspec +1 -1
  8. data/lib/coverband.rb +9 -6
  9. data/lib/coverband/adapters/base.rb +22 -2
  10. data/lib/coverband/adapters/file_store.rb +11 -11
  11. data/lib/coverband/adapters/redis_store.rb +22 -57
  12. data/lib/coverband/collectors/coverage.rb +57 -53
  13. data/lib/coverband/configuration.rb +6 -14
  14. data/lib/coverband/integrations/background.rb +7 -0
  15. data/lib/coverband/{middleware.rb → integrations/middleware.rb} +1 -3
  16. data/lib/coverband/reporters/base.rb +37 -82
  17. data/lib/coverband/reporters/console_report.rb +3 -0
  18. data/lib/coverband/reporters/simple_cov_report.rb +4 -3
  19. data/lib/coverband/reporters/web.rb +38 -35
  20. data/lib/coverband/utils/s3_report_writer.rb +59 -0
  21. data/lib/coverband/{tasks.rb → utils/tasks.rb} +0 -0
  22. data/lib/coverband/version.rb +1 -1
  23. data/test/benchmarks/benchmark.rake +3 -3
  24. data/test/test_helper.rb +18 -17
  25. data/test/unit/adapters_base_test.rb +29 -0
  26. data/test/unit/adapters_file_store_test.rb +2 -2
  27. data/test/unit/adapters_redis_store_test.rb +14 -51
  28. data/test/unit/collectors_coverage_test.rb +3 -107
  29. data/test/unit/configuration_test.rb +2 -9
  30. data/test/unit/full_stack_test.rb +47 -0
  31. data/test/unit/middleware_test.rb +21 -57
  32. data/test/unit/reports_base_test.rb +12 -71
  33. data/test/unit/reports_console_test.rb +9 -22
  34. data/test/unit/reports_simple_cov_test.rb +3 -37
  35. data/test/unit/reports_web_test.rb +4 -0
  36. data/test/unit/{s3_report_writer_test.rb → utils_s3_report_writer_test.rb} +1 -1
  37. metadata +29 -18
  38. data/lib/coverband/adapters/memory_cache_store.rb +0 -53
  39. data/lib/coverband/collectors/base.rb +0 -126
  40. data/lib/coverband/collectors/trace.rb +0 -122
  41. data/lib/coverband/s3_report_writer.rb +0 -49
  42. data/test/unit/adapters_memory_cache_store_test.rb +0 -66
  43. data/test/unit/collectors_base_test.rb +0 -104
  44. data/test/unit/collectors_trace_test.rb +0 -106
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../test_helper', File.dirname(__FILE__))
4
- require File.expand_path('./dog', File.dirname(__FILE__))
5
-
6
- class CollectorsTraceTest < Test::Unit::TestCase
7
- def setup
8
- Coverband.configure do |config|
9
- config.collector = 'trace'
10
- end
11
- end
12
-
13
- test 'defaults to a redis store' do
14
- coverband = Coverband::Collectors::Base.instance.reset_instance
15
- assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get('@store').class
16
- end
17
-
18
- test 'configure memory caching' do
19
- Coverband.configuration.memory_caching = true
20
- coverband = Coverband::Collectors::Base.instance.reset_instance
21
- assert_equal Coverband::Adapters::MemoryCacheStore, coverband.instance_variable_get('@store').class
22
- Coverband.configuration.memory_caching = false
23
- end
24
-
25
- test 'start should enable coverage' do
26
- coverband = Coverband::Collectors::Base.instance.reset_instance
27
- assert_equal false, coverband.instance_variable_get('@enabled')
28
- coverband.expects(:record_coverage).once
29
- coverband.start
30
- assert_equal true, coverband.instance_variable_get('@enabled')
31
- end
32
-
33
- test 'stop should disable coverage' do
34
- coverband = Coverband::Collectors::Base.instance.reset_instance
35
- assert_equal false, coverband.instance_variable_get('@enabled')
36
- coverband.expects(:record_coverage).once
37
- coverband.start
38
- assert_equal true, coverband.instance_variable_get('@enabled')
39
- coverband.stop
40
- assert_equal false, coverband.instance_variable_get('@enabled')
41
- assert_equal false, coverband.instance_variable_get('@tracer_set')
42
- end
43
-
44
- test 'allow for sampling with a block and enable when 100 percent sample' do
45
- logger = Logger.new(STDOUT)
46
- coverband = Coverband::Collectors::Base.instance.reset_instance
47
- coverband.instance_variable_set('@sample_percentage', 100.0)
48
- coverband.instance_variable_set('@verbose', true)
49
- coverband.instance_variable_set('@logger', logger)
50
- coverband.instance_variable_set('@store', nil)
51
- assert_equal false, coverband.instance_variable_get('@enabled')
52
- logger.expects(:info).at_least_once
53
- logger.stubs('debug')
54
- coverband.sample { 1 + 1 }
55
- assert_equal true, coverband.instance_variable_get('@enabled')
56
- end
57
-
58
- test 'allow reporting with start stop save' do
59
- logger = Logger.new(STDOUT)
60
- coverband = Coverband::Collectors::Base.instance.reset_instance
61
- coverband.instance_variable_set('@sample_percentage', 100.0)
62
- coverband.instance_variable_set('@verbose', true)
63
- coverband.instance_variable_set('@logger', logger)
64
- coverband.instance_variable_set('@store', nil)
65
- assert_equal false, coverband.instance_variable_get('@enabled')
66
- logger.expects(:info).at_least_once
67
- logger.stubs('debug')
68
- coverband.start
69
- coverband.stop
70
- coverband.save
71
- end
72
-
73
- test 'allow reporting to redis start stop save' do
74
- dog_file = File.expand_path('./dog.rb', File.dirname(__FILE__))
75
- coverband = Coverband::Collectors::Base.instance.reset_instance
76
- coverband.instance_variable_set('@sample_percentage', 100.0)
77
- coverband.instance_variable_set('@verbose', true)
78
- Coverband.configuration.logger.stubs('info')
79
- Coverband.configuration.logger.stubs('debug')
80
- store = Coverband::Adapters::RedisStore.new(Redis.new)
81
- coverband.instance_variable_set('@store', store)
82
- store.expects(:save_report).once.with(has_entries(dog_file => { 5 => 5 }))
83
- assert_equal false, coverband.instance_variable_get('@enabled')
84
- coverband.start
85
- 5.times { Dog.new.bark }
86
- coverband.stop
87
- coverband.save
88
- end
89
-
90
- test 'tracer should count line numbers' do
91
- dog_file = File.expand_path('./dog.rb', File.dirname(__FILE__))
92
- coverband = Coverband::Collectors::Base.instance.reset_instance
93
- store = Coverband::Adapters::RedisStore.new(Redis.new)
94
- coverband.instance_variable_set('@store', store)
95
- coverband.start
96
- 100.times { Dog.new.bark }
97
- assert_equal 100, coverband.instance_variable_get('@file_line_usage')[dog_file][5]
98
- coverband.stop
99
- coverband.save
100
- end
101
-
102
- test 'sample should return the result of the block' do
103
- coverband = Coverband::Collectors::Base.instance.reset_instance
104
- assert_equal 2, coverband.sample { 1 + 1 }
105
- end
106
- end