rspec-cover_it 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3efab53f0b9f05be2f5a8ae7f170e4a3a8e886439a751e025926c61bf9ac8f1
4
- data.tar.gz: 569fbdcc5f328d5d0656eb3fe20265c9cd164455cfbf290c7764b92d15454fbf
3
+ metadata.gz: 63e1b79c2f0b0d52869caa48e5d7dcfee100a726f1fb4698bcbef5d228179ec4
4
+ data.tar.gz: 24d36270a6320b920f30134c8bb354b77325b16e4a311b1fb018470c72f0c5a7
5
5
  SHA512:
6
- metadata.gz: e9d198749c87a093cf8cbf5d2e5a4f20bfdb1a4c312579a541d8335fa4ccab88781fdbee073195cf8d5c682d921019c9fb86ede9fe951e57f83df24722934c59
7
- data.tar.gz: 604d4808f4a3d8afacf52cfe0651d4bbae46ee510ca95e123cd14304b071cbf1c726bf37741002efdd0d9dc636625b47d149f0a17226c26f42cdad0ba531be7f
6
+ metadata.gz: 3f8774a17ea6e1170471182cf768cbd7fc0e3f69a8cf2d04445d7a7ae0e7e04947b6a75205aa2d53eaaeef104597447608b3873413b73bfda2d9b83ce015bec6
7
+ data.tar.gz: 3cf13d18a7658e6769d672e1d130ace9e3842ce1e3e7edfdf21e3c64753fb47668da6c7fa16690bc78e6741aa58cd03bdf1344d7c98b50a6fdbf51de03ba5ec1
data/README.md CHANGED
@@ -33,10 +33,7 @@ You set up `RSpec::CoverIt` in your `spec_helper.rb` - require `rspec/cover_it`,
33
33
  and then `RSpec::CoverIt.setup(**config_options)` (before loading your code, as
34
34
  you would with any other coverage library). It's.. _semi_ compatible with other
35
35
  coverage systems - it only starts Coverage if it's not already running, and it
36
- only uses `peek_result`, so it doesn't affect other systems outcomes. But if you
37
- setup SimpleCov to do branch-coverage or something, that will break this gem,
38
- for now (we assume basic line-coverage style results).
39
-
36
+ only uses `peek_result`, so it doesn't affect other systems outcomes.
40
37
  Rough configuration options:
41
38
 
42
39
  * `filter`: Only paths starting with this (matching this regex?) can matter
@@ -64,6 +61,10 @@ In example groups, you can use metadata to control the behavior of
64
61
  the fact that we can't perfectly infer the location of the source code in
65
62
  some cases - in particular, `lib/foo/version.rb` tends to cause a problem
66
63
  for specs on `foo.rb`, since the version file is invariably loaded first.
64
+ Note - in gems, this _frequently_ also happens when you glob-load a directory
65
+ _before_ defining the namespace they are all loading objects into. Then the
66
+ first file in that directory that loads ends up being the one that actually
67
+ creates the namespace.
67
68
  * `covers`: An array of classes and modules that this example groups _thinks
68
69
  it is completely testing_. Ideally, you'd have a separate test file for each,
69
70
  but sometimes that's hard to do - you can let one spec claim responsibility
@@ -57,8 +57,11 @@ module RSpec
57
57
  else
58
58
  "on #{lines.length} lines, including #{lines.first(10).map(&:to_s).join(", ")}"
59
59
  end
60
- message = "Missing coverage in #{context.target_path} #{summary}"
61
- fail(MissingCoverage, message)
60
+
61
+ fail(MissingCoverage, <<~MESSAGE.tr("\n", " "))
62
+ Example group `#{context.scope_name}` is missing coverage on
63
+ `#{context.target_class}` in `#{context.target_path}` #{summary}
64
+ MESSAGE
62
65
  end
63
66
 
64
67
  attr_reader :context, :pretest_results
@@ -16,7 +16,7 @@ module RSpec
16
16
  end
17
17
 
18
18
  def finish_load_tracking
19
- @pretest_results = PretestCoverage.new(filter: filter, results: Coverage.peek_result)
19
+ @pretest_results = PretestCoverage.new(filter: filter, results: get_current_coverage)
20
20
  end
21
21
 
22
22
  def start_tracking_for(scope, rspec_context)
@@ -24,7 +24,7 @@ module RSpec
24
24
  return unless context.cover_it?
25
25
 
26
26
  context_coverage_for(context).tap do |context_coverage|
27
- context_coverage.precontext_coverage = Coverage.peek_result[context.target_path]
27
+ context_coverage.precontext_coverage = get_current_coverage(context.target_path)
28
28
  end
29
29
  end
30
30
 
@@ -33,7 +33,7 @@ module RSpec
33
33
  return unless context.cover_it?
34
34
 
35
35
  context_coverage_for(context).tap do |context_coverage|
36
- context_coverage.postcontext_coverage = Coverage.peek_result[context.target_path]
36
+ context_coverage.postcontext_coverage = get_current_coverage(context.target_path)
37
37
  context_coverage.enforce!(default_threshold: default_threshold_rate)
38
38
  end
39
39
  end
@@ -60,6 +60,21 @@ module RSpec
60
60
  pretest_results: pretest_results
61
61
  )
62
62
  end
63
+
64
+ def get_current_coverage(path = nil)
65
+ result = Coverage.peek_result
66
+
67
+ if path
68
+ value = result[path]
69
+ value.is_a?(Hash) ? value.fetch(:lines) : value
70
+ else
71
+ if result.any? { |_k, v| v.is_a?(Hash) }
72
+ result.transform_values { |v| v.fetch(:lines) }
73
+ else
74
+ result
75
+ end
76
+ end
77
+ end
63
78
  end
64
79
  end
65
80
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module CoverIt
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-cover_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Mueller