Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 76e6976

Browse files
committed
Exclude version/platform-specific code from simplecov.
1 parent 2ecdecc commit 76e6976

File tree

10 files changed

+37
-3
lines changed

10 files changed

+37
-3
lines changed

lib/rspec/core/configuration.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,8 @@ def safe_include(mod, host)
12611261
def safe_extend(mod, host)
12621262
host.extend(mod) unless host.singleton_class < mod
12631263
end
1264-
else
1264+
else # for 1.8.7
1265+
# :nocov:
12651266
# @private
12661267
def safe_include(mod, host)
12671268
host.__send__(:include, mod) unless host.included_modules.include?(mod)
@@ -1271,6 +1272,7 @@ def safe_include(mod, host)
12711272
def safe_extend(mod, host)
12721273
host.extend(mod) unless (class << host; self; end).included_modules.include?(mod)
12731274
end
1275+
# :nocov:
12741276
end
12751277

12761278
# @private
@@ -1665,6 +1667,7 @@ def file_glob_from(path, pattern)
16651667
end
16661668

16671669
if RSpec::Support::OS.windows?
1670+
# :nocov:
16681671
def absolute_pattern?(pattern)
16691672
pattern =~ /\A[A-Z]:\\/ || windows_absolute_network_path?(pattern)
16701673
end
@@ -1673,6 +1676,7 @@ def windows_absolute_network_path?(pattern)
16731676
return false unless ::File::ALT_SEPARATOR
16741677
pattern.start_with?(::File::ALT_SEPARATOR + ::File::ALT_SEPARATOR)
16751678
end
1679+
# :nocov:
16761680
else
16771681
def absolute_pattern?(pattern)
16781682
pattern.start_with?(File::Separator)

lib/rspec/core/example_group.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ def self.superclass_before_context_ivars
482482
superclass.before_context_ivars
483483
end
484484
else # 1.8.7
485+
# :nocov:
485486
# @private
486487
def self.superclass_before_context_ivars
487488
if superclass.respond_to?(:before_context_ivars)
@@ -496,6 +497,7 @@ def self.superclass_before_context_ivars
496497
ancestors.find { |a| a.respond_to?(:before_context_ivars) }.before_context_ivars
497498
end
498499
end
500+
# :nocov:
499501
end
500502

501503
# @private
@@ -603,8 +605,10 @@ def self.set_ivars(instance, ivars)
603605
end
604606

605607
if RUBY_VERSION.to_f < 1.9
608+
# :nocov:
606609
# @private
607610
INSTANCE_VARIABLE_TO_IGNORE = '@__inspect_output'.freeze
611+
# :nocov:
608612
else
609613
# @private
610614
INSTANCE_VARIABLE_TO_IGNORE = :@__inspect_output
@@ -627,10 +631,12 @@ def inspect
627631
end
628632

629633
unless method_defined?(:singleton_class) # for 1.8.7
634+
# :nocov:
630635
# @private
631636
def singleton_class
632637
class << self; self; end
633638
end
639+
# :nocov:
634640
end
635641

636642
# Raised when an RSpec API is called in the wrong scope, such as `before`
@@ -774,13 +780,15 @@ def self.base_name_for(group)
774780
end
775781

776782
if RUBY_VERSION == '1.9.2'
783+
# :nocov:
777784
class << self
778785
alias _base_name_for base_name_for
779786
def base_name_for(group)
780787
_base_name_for(group) + '_'
781788
end
782789
end
783790
private_class_method :_base_name_for
791+
# :nocov:
784792
end
785793

786794
def self.disambiguate(name, const_scope)

lib/rspec/core/flat_map.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ def flat_map(array, &block)
77
array.flat_map(&block)
88
end
99
else # for 1.8.7
10+
# :nocov:
1011
def flat_map(array, &block)
1112
array.map(&block).flatten(1)
1213
end
14+
# :nocov:
1315
end
1416

1517
module_function :flat_map

lib/rspec/core/hooks.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,12 @@ def execute_with(example, procsy)
394394
def hook_description
395395
"around hook at #{Metadata.relative_path(block.source_location.join(':'))}"
396396
end
397-
else
397+
else # for 1.8.7
398+
# :nocov:
398399
def hook_description
399400
"around hook"
400401
end
402+
# :nocov:
401403
end
402404
end
403405

@@ -622,9 +624,11 @@ def owner_parent_groups
622624
@owner.parent_groups
623625
end
624626
else # Ruby < 2.1 (see https://bugs.ruby-lang.org/issues/8035)
627+
# :nocov:
625628
def owner_parent_groups
626629
@owner_parent_groups ||= [@owner] + @owner.parent_groups
627630
end
631+
# :nocov:
628632
end
629633
end
630634
end

lib/rspec/core/memoized_helpers.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,15 @@ def self.define_helpers_on(example_group)
443443
# Gets the named constant or yields.
444444
# On 1.8, const_defined? / const_get do not take into
445445
# account the inheritance hierarchy.
446+
# :nocov:
446447
def self.get_constant_or_yield(example_group, name)
447448
if example_group.const_defined?(name)
448449
example_group.const_get(name)
449450
else
450451
yield
451452
end
452453
end
454+
# :nocov:
453455
else
454456
# @private
455457
#

lib/rspec/core/metadata_filter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def items_for(request_meta)
127127
end
128128

129129
unless [].respond_to?(:each_with_object) # For 1.8.7
130+
# :nocov:
130131
undef items_for
131132
def items_for(request_meta)
132133
@items_and_filters.inject([]) do |to_return, (item, item_meta)|
@@ -135,6 +136,7 @@ def items_for(request_meta)
135136
to_return
136137
end
137138
end
139+
# :nocov:
138140
end
139141
end
140142

@@ -217,13 +219,15 @@ def proc_keys_from(metadata)
217219
end
218220

219221
unless [].respond_to?(:each_with_object) # For 1.8.7
222+
# :nocov:
220223
undef proc_keys_from
221224
def proc_keys_from(metadata)
222225
metadata.inject([]) do |to_return, (key, value)|
223226
to_return << key if Proc === value
224227
to_return
225228
end
226229
end
230+
# :nocov:
227231
end
228232
end
229233
end

lib/rspec/core/notifications.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,15 @@ def encoding_of(string)
209209
def encoded_string(string)
210210
RSpec::Support::EncodedString.new(string, Encoding.default_external)
211211
end
212-
else
212+
else # for 1.8.7
213+
# :nocov:
213214
def encoding_of(_string)
214215
end
215216

216217
def encoded_string(string)
217218
RSpec::Support::EncodedString.new(string)
218219
end
220+
# :nocov:
219221
end
220222

221223
def backtrace_formatter

lib/rspec/core/ordering.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ module Core
44
# @private
55
RandomNumberGenerator = ::Random
66
else
7+
# :nocov:
78
RSpec::Support.require_rspec_core "backport_random"
89
# @private
910
RandomNumberGenerator = RSpec::Core::Backports::Random
11+
# :nocov:
1012
end
1113

1214
# @private
@@ -42,6 +44,7 @@ def shuffle(list, rng)
4244
list.shuffle(:random => rng)
4345
end
4446
else
47+
# :nocov:
4548
def shuffle(list, rng)
4649
shuffled = list.dup
4750
shuffled.size.times do |i|
@@ -52,6 +55,7 @@ def shuffle(list, rng)
5255

5356
shuffled
5457
end
58+
# :nocov:
5559
end
5660
end
5761

lib/rspec/core/rake_task.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ def file_inclusion_specification
123123
end
124124

125125
if RSpec::Support::OS.windows?
126+
# :nocov:
126127
def escape(shell_command)
127128
"'#{shell_command.gsub("'", "\\\\'")}'"
128129
end
130+
# :nocov:
129131
else
130132
require 'shellwords'
131133

lib/rspec/core/shared_example_group.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,12 @@ def formatted_location(block)
195195
if Proc.method_defined?(:source_location)
196196
def ensure_block_has_source_location(_block); end
197197
else # for 1.8.7
198+
# :nocov:
198199
def ensure_block_has_source_location(block)
199200
source_location = yield.split(':')
200201
block.extend Module.new { define_method(:source_location) { source_location } }
201202
end
203+
# :nocov:
202204
end
203205
end
204206
end

0 commit comments

Comments
 (0)