Class: RSpec::CoverIt::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/cover_it/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope:, rspec_context:, autoenforce:) ⇒ Context

Returns a new instance of Context.



4
5
6
# File 'lib/rspec/cover_it/context.rb', line 4

def initialize(scope:, rspec_context:, autoenforce:)
  @scope, @rspec_context, @autoenforce = scope, rspec_context, autoenforce
end

Instance Method Details

#cover_it?Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/rspec/cover_it/context.rb', line 8

def cover_it?
  target_class &&
    .fetch(:cover_it, autoenforce?) &&
    completeness_checker.running_all_examples?
end

#scope_nameObject



27
28
29
# File 'lib/rspec/cover_it/context.rb', line 27

def scope_name
  scope.file_path
end

#specific_thresholdObject



14
15
16
17
# File 'lib/rspec/cover_it/context.rb', line 14

def specific_threshold
  meta_value = .fetch(:cover_it, nil)
  meta_value.is_a?(Numeric) ? meta_value / 100.0 : nil
end

#target_classObject



23
24
25
# File 'lib/rspec/cover_it/context.rb', line 23

def target_class
  .fetch(:described_class, nil)
end

#target_pathObject



19
20
21
# File 'lib/rspec/cover_it/context.rb', line 19

def target_path
  .key?(:covers_path) ?  : inferred_path
end