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

Updates for frozen-string-literal compatibility. #2437

Merged
merged 5 commits into from
Jun 29, 2017
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: 1 addition & 1 deletion features/configuration/pattern.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Feature: pattern
Given a file named "spec/spec_helper.rb" with:
"""ruby
RSpec.configure do |config|
config.pattern << ',**/*.spec'
config.pattern += ',**/*.spec'
end
"""
And a file named "spec/two_examples.spec" with:
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/drb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def add_full_description(argv)
def add_filter(argv, name, hash)
hash.each_pair do |k, v|
next if CONDITIONAL_FILTERS.include?(k)
tag = name == :inclusion ? k.to_s : "~#{k}"
tag = name == :inclusion ? k.to_s : "~#{k}".dup
tag << ":#{v}" if v.is_a?(String)
argv << "--tag" << tag
end unless hash.empty?
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def mocks_need_verification?
def assign_generated_description
if metadata[:description].empty? && (description = generate_description)
metadata[:description] = description
metadata[:full_description] << description
metadata[:full_description] += description
end
ensure
RSpec::Matchers.clear_generated_description
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def self.remove_all_constants
end

def self.base_name_for(group)
return "Anonymous" if group.description.empty?
return "Anonymous".dup if group.description.empty?

# Convert to CamelCase.
name = ' ' + group.description
Expand Down
13 changes: 9 additions & 4 deletions lib/rspec/core/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::Console
# @return [String] The list of pending examples, fully formatted in the
# way that RSpec's built-in formatters emit.
def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n"
formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n".dup

pending_notifications.each_with_index do |notification, index|
formatted << notification.fully_formatted(index.next, colorizer)
Expand Down Expand Up @@ -232,9 +232,14 @@ class SkippedExampleNotification < ExampleNotification
# RSpec's built-in formatters emit.
def fully_formatted(pending_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location)
colorizer.wrap("\n #{pending_number}) #{example.full_description}", :pending) << "\n " <<
Formatters::ExceptionPresenter::PENDING_DETAIL_FORMATTER.call(example, colorizer) <<
"\n" << colorizer.wrap(" # #{formatted_caller}\n", :detail)

[
colorizer.wrap("\n #{pending_number}) #{example.full_description}", :pending),
"\n ",
Formatters::ExceptionPresenter::PENDING_DETAIL_FORMATTER.call(example, colorizer),
"\n",
colorizer.wrap(" # #{formatted_caller}\n", :detail)
].join("")
end
end

Expand Down
2 changes: 1 addition & 1 deletion rspec-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "minitest", "~> 5.3"
s.add_development_dependency "aruba", "~> 0.6.2" # 0.7 is broken on ruby 1.8.7

s.add_development_dependency "coderay", "~> 1.0.9"
s.add_development_dependency "coderay", "~> 1.1.1"

s.add_development_dependency "mocha", "~> 0.13.0"
s.add_development_dependency "rr", "~> 1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/formatters/base_text_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def run_all_and_dump_failures
if String.method_defined?(:encoding)
context "with an exception that has a differently encoded message" do
it "runs without encountering an encoding exception" do
group.example("Mixing encodings, e.g. UTF-8: © and Binary") { raise "Error: \xC2\xA9".force_encoding("ASCII-8BIT") }
group.example("Mixing encodings, e.g. UTF-8: © and Binary") { raise "Error: \xC2\xA9".dup.force_encoding("ASCII-8BIT") }
run_all_and_dump_failures
expect(formatter_output.string).to match(/RuntimeError:\n\s+Error: \?\?/m) # ?? because the characters dont encode properly
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/formatters/html_snippet_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Formatters

it "falls back on a default message when it gets a security error" do
message = with_safe_set_to_level_that_triggers_security_errors do
RSpec::Core::Formatters::HtmlSnippetExtractor.new.lines_around("blech".taint, 8)
RSpec::Core::Formatters::HtmlSnippetExtractor.new.lines_around("blech".dup.taint, 8)
end
expect(message).to eq("# Couldn't get snippet for blech")
end
Expand Down
4 changes: 2 additions & 2 deletions spec/rspec/core/formatters/syntax_highlighter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def find_highlighted_terms_in(code_snippet)
highlighted = highlighter.highlight(lines)
highlighted_terms = []

highlighted.join("\n").scan(/\e\[1;[1-9]\dm(\w+)\e\[0m/) do |first_capture, _|
highlighted.join("\n").scan(/\e\[[1-9]\dm(\w+)\e\[0m/) do |first_capture, _|
highlighted_terms << first_capture
end

Expand Down Expand Up @@ -124,7 +124,7 @@ def find_highlighted_terms_in(code_snippet)
end

def be_highlighted
include("\e[32m")
include("\e[31m")
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def normalize_one_backtrace(exception)
if String.method_defined?(:encoding)
it "returns failures_lines with invalid bytes replace by '?'" do
message_with_invalid_byte_sequence =
"\xEF \255 \xAD I have bad bytes".force_encoding(Encoding::UTF_8)
"\xEF \255 \xAD I have bad bytes".dup.force_encoding(Encoding::UTF_8)
allow(exception).to receive(:message).
and_return(message_with_invalid_byte_sequence)

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def reporter

RSpec.clear_examples

RSpec.configuration.deprecation_stream = StringIO.new(deprecations = "")
RSpec.configuration.deprecation_stream = StringIO.new(deprecations = "".dup)

group = RSpec.describe do
example { RSpec.deprecate("second deprecation") }
Expand Down