Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update coverage #1905

Merged
merged 7 commits into from
Mar 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Bug Fixes:
* Handle invalid UTF-8 strings within exception methods. (Benjamin Fleischer, #1760)
* Fix Rake Task quoting of file names with quotes to work properly on
Windows. (Myron Marston, #1887)
* Fix `RSpec::Core::RakeTask#failure_message` so that it gets printed
when the task failed. (Myron Marston, #1905)

### 3.2.2 / 2015-03-11
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.2.1...v3.2.2)
Expand Down
2 changes: 0 additions & 2 deletions lib/rspec/core/backtrace_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ def format_backtrace(backtrace, options={})

def backtrace_line(line)
Metadata.relative_path(line) unless exclude?(line)
rescue SecurityError
nil
end

def exclude?(line)
Expand Down
6 changes: 5 additions & 1 deletion lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,8 @@ def safe_include(mod, host)
def safe_extend(mod, host)
host.extend(mod) unless host.singleton_class < mod
end
else
else # for 1.8.7
# :nocov:
# @private
def safe_include(mod, host)
host.__send__(:include, mod) unless host.included_modules.include?(mod)
Expand All @@ -1271,6 +1272,7 @@ def safe_include(mod, host)
def safe_extend(mod, host)
host.extend(mod) unless (class << host; self; end).included_modules.include?(mod)
end
# :nocov:
end

# @private
Expand Down Expand Up @@ -1665,6 +1667,7 @@ def file_glob_from(path, pattern)
end

if RSpec::Support::OS.windows?
# :nocov:
def absolute_pattern?(pattern)
pattern =~ /\A[A-Z]:\\/ || windows_absolute_network_path?(pattern)
end
Expand All @@ -1673,6 +1676,7 @@ def windows_absolute_network_path?(pattern)
return false unless ::File::ALT_SEPARATOR
pattern.start_with?(::File::ALT_SEPARATOR + ::File::ALT_SEPARATOR)
end
# :nocov:
else
def absolute_pattern?(pattern)
pattern.start_with?(File::Separator)
Expand Down
8 changes: 0 additions & 8 deletions lib/rspec/core/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,6 @@ def location_description
"example at #{location}"
end

def skip_message
if String === skip
skip
else
Pending::NO_REASON_GIVEN
end
end

# Represents the result of executing an example.
# Behaves like a hash for backwards compatibility.
class ExecutionResult
Expand Down
8 changes: 8 additions & 0 deletions lib/rspec/core/example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ def self.superclass_before_context_ivars
superclass.before_context_ivars
end
else # 1.8.7
# :nocov:
# @private
def self.superclass_before_context_ivars
if superclass.respond_to?(:before_context_ivars)
Expand All @@ -496,6 +497,7 @@ def self.superclass_before_context_ivars
ancestors.find { |a| a.respond_to?(:before_context_ivars) }.before_context_ivars
end
end
# :nocov:
end

# @private
Expand Down Expand Up @@ -603,8 +605,10 @@ def self.set_ivars(instance, ivars)
end

if RUBY_VERSION.to_f < 1.9
# :nocov:
# @private
INSTANCE_VARIABLE_TO_IGNORE = '@__inspect_output'.freeze
# :nocov:
else
# @private
INSTANCE_VARIABLE_TO_IGNORE = :@__inspect_output
Expand All @@ -627,10 +631,12 @@ def inspect
end

unless method_defined?(:singleton_class) # for 1.8.7
# :nocov:
# @private
def singleton_class
class << self; self; end
end
# :nocov:
end

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

if RUBY_VERSION == '1.9.2'
# :nocov:
class << self
alias _base_name_for base_name_for
def base_name_for(group)
_base_name_for(group) + '_'
end
end
private_class_method :_base_name_for
# :nocov:
end

def self.disambiguate(name, const_scope)
Expand Down
4 changes: 0 additions & 4 deletions lib/rspec/core/filter_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ def add_with_low_priority(*args)
apply_standalone_filter(*args) || super
end

def use(*args)
apply_standalone_filter(*args) || super
end

def include_example?(example)
@rules.empty? || super
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/core/flat_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ def flat_map(array, &block)
array.flat_map(&block)
end
else # for 1.8.7
# :nocov:
def flat_map(array, &block)
array.map(&block).flatten(1)
end
# :nocov:
end

module_function :flat_map
Expand Down
8 changes: 1 addition & 7 deletions lib/rspec/core/formatters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,7 @@ def add(formatter_to_use, *paths)
formatter = RSpec::LegacyFormatters.load_formatter formatter_class, *args
@reporter.register_listener formatter, *formatter.notifications
else
line = ::RSpec::CallerFilter.first_non_rspec_line
if line
call_site = "Formatter added at: #{line}"
else
call_site = "The formatter was added via command line flag or your "\
"`.rspec` file."
end
call_site = "Formatter added at: #{::RSpec::CallerFilter.first_non_rspec_line}"

RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/, ' ')
|The #{formatter_class} formatter uses the deprecated formatter
Expand Down
4 changes: 0 additions & 4 deletions lib/rspec/core/formatters/documentation_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def next_failure_index
def current_indentation
' ' * @group_level
end

def example_group_chain
example_group.parent_groups.reverse
end
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/rspec/core/formatters/html_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ def example_failed(failure)
:message => exception.message,
:backtrace => failure.formatted_backtrace.join("\n")
}
else
false
end
extra = extra_failure_content(failure)

Expand All @@ -85,8 +83,7 @@ def example_failed(failure)
example.execution_result.run_time,
@failed_examples.size,
exception_details,
(extra == "") ? false : extra,
true
(extra == "") ? false : extra
)
@printer.flush
end
Expand Down
8 changes: 2 additions & 6 deletions lib/rspec/core/formatters/html_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def print_example_passed(description, run_time)

# rubocop:disable Style/ParameterLists
def print_example_failed(pending_fixed, description, run_time, failure_id,
exception, extra_content, escape_backtrace=false)
exception, extra_content)
# rubocop:enable Style/ParameterLists
formatted_run_time = "%.5f" % run_time

Expand All @@ -45,11 +45,7 @@ def print_example_failed(pending_fixed, description, run_time, failure_id,
@output.puts " <div class=\"failure\" id=\"failure_#{failure_id}\">"
if exception
@output.puts " <div class=\"message\"><pre>#{h(exception[:message])}</pre></div>"
if escape_backtrace
@output.puts " <div class=\"backtrace\"><pre>#{h exception[:backtrace]}</pre></div>"
else
@output.puts " <div class=\"backtrace\"><pre>#{exception[:backtrace]}</pre></div>"
end
@output.puts " <div class=\"backtrace\"><pre>#{h exception[:backtrace]}</pre></div>"
end
@output.puts extra_content if extra_content
@output.puts " </div>"
Expand Down
19 changes: 12 additions & 7 deletions lib/rspec/core/formatters/snippet_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ module Formatters
# and applies synax highlighting and line numbers using html.
class SnippetExtractor
# @private
class NullConverter
def convert(code)
module NullConverter
def self.convert(code)
%Q(#{code}\n<span class="comment"># Install the coderay gem to get syntax highlighting</span>)
end
end

# @private
class CoderayConverter
def convert(code)
module CoderayConverter
def self.convert(code)
CodeRay.scan(code, :ruby).html(:line_numbers => false)
end
end

# rubocop:disable Style/ClassVars
@@converter = NullConverter
begin
require 'coderay'
# rubocop:disable Style/ClassVars
@@converter = CoderayConverter.new
@@converter = CoderayConverter
# rubocop:disable Lint/HandleExceptions
rescue LoadError
@@converter = NullConverter.new
# it'll fall back to the NullConverter assigned above
# rubocop:enable Lint/HandleExceptions
end

# rubocop:enable Style/ClassVars

# @api private
Expand All @@ -43,6 +47,7 @@ def snippet(backtrace)
highlighted = @@converter.convert(raw_code)
post_process(highlighted, line)
end
# rubocop:enable Style/ClassVars

# @api private
#
Expand Down
6 changes: 5 additions & 1 deletion lib/rspec/core/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ def execute_with(example, procsy)
def hook_description
"around hook at #{Metadata.relative_path(block.source_location.join(':'))}"
end
else
else # for 1.8.7
# :nocov:
def hook_description
"around hook"
end
# :nocov:
end
end

Expand Down Expand Up @@ -622,9 +624,11 @@ def owner_parent_groups
@owner.parent_groups
end
else # Ruby < 2.1 (see https://bugs.ruby-lang.org/issues/8035)
# :nocov:
def owner_parent_groups
@owner_parent_groups ||= [@owner] + @owner.parent_groups
end
# :nocov:
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/core/memoized_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,15 @@ def self.define_helpers_on(example_group)
# Gets the named constant or yields.
# On 1.8, const_defined? / const_get do not take into
# account the inheritance hierarchy.
# :nocov:
def self.get_constant_or_yield(example_group, name)
if example_group.const_defined?(name)
example_group.const_get(name)
else
yield
end
end
# :nocov:
else
# @private
#
Expand Down
6 changes: 0 additions & 6 deletions lib/rspec/core/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ def self.deep_hash_dup(object)
end
end

# @private
def self.backtrace_from(block)
return caller unless block.respond_to?(:source_location)
[block.source_location.join(':')]
end

# @private
def self.id_from(metadata)
"#{metadata[:rerun_file_path]}[#{metadata[:scoped_id]}]"
Expand Down
4 changes: 4 additions & 0 deletions lib/rspec/core/metadata_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def items_for(request_meta)
end

unless [].respond_to?(:each_with_object) # For 1.8.7
# :nocov:
undef items_for
def items_for(request_meta)
@items_and_filters.inject([]) do |to_return, (item, item_meta)|
Expand All @@ -135,6 +136,7 @@ def items_for(request_meta)
to_return
end
end
# :nocov:
end
end

Expand Down Expand Up @@ -217,13 +219,15 @@ def proc_keys_from(metadata)
end

unless [].respond_to?(:each_with_object) # For 1.8.7
# :nocov:
undef proc_keys_from
def proc_keys_from(metadata)
metadata.inject([]) do |to_return, (key, value)|
to_return << key if Proc === value
to_return
end
end
# :nocov:
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/rspec/core/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ def encoding_of(string)
def encoded_string(string)
RSpec::Support::EncodedString.new(string, Encoding.default_external)
end
else
else # for 1.8.7
# :nocov:
def encoding_of(_string)
end

def encoded_string(string)
RSpec::Support::EncodedString.new(string)
end
# :nocov:
end

def backtrace_formatter
Expand Down
4 changes: 4 additions & 0 deletions lib/rspec/core/ordering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ module Core
# @private
RandomNumberGenerator = ::Random
else
# :nocov:
RSpec::Support.require_rspec_core "backport_random"
# @private
RandomNumberGenerator = RSpec::Core::Backports::Random
# :nocov:
end

# @private
Expand Down Expand Up @@ -42,6 +44,7 @@ def shuffle(list, rng)
list.shuffle(:random => rng)
end
else
# :nocov:
def shuffle(list, rng)
shuffled = list.dup
shuffled.size.times do |i|
Expand All @@ -52,6 +55,7 @@ def shuffle(list, rng)

shuffled
end
# :nocov:
end
end

Expand Down
Loading