rspec-cover_it 0.0.6 → 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: 5989ad87b5dccfd49f0e4074fde2aa5ee796af31c93d7a8c3b081fd5283db3aa
4
- data.tar.gz: ef49e7f6d941accf93973aaf56da57a6ae60db7232042b9d06edad5d1845dc5e
3
+ metadata.gz: 63e1b79c2f0b0d52869caa48e5d7dcfee100a726f1fb4698bcbef5d228179ec4
4
+ data.tar.gz: 24d36270a6320b920f30134c8bb354b77325b16e4a311b1fb018470c72f0c5a7
5
5
  SHA512:
6
- metadata.gz: 0d64ad3f4a25abd3a5af67ab7e6ff3f548e7c43004c25c6c7dba5da4de81d5217a2160ae7c725c50af9fb9caecad57105c4d0f18cafb5b12a4968c63de849993
7
- data.tar.gz: e0dee5c4480e921645112dcd5bfcbe303f144a90564d03542fe6b84b11159566807555b06c45382eb5a0302faba6470b786bcd38c4e5ba16563184a0bad52259
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
@@ -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.6"
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Mueller