Skip to content

Commit

Permalink
Merge pull request #1281 from rspec/remove-more-deprecations
Browse files Browse the repository at this point in the history
Remove more deprecations
  • Loading branch information
JonRowe committed Feb 1, 2014
2 parents 729f2f7 + d55891f commit 6b22861
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 115 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Expand Up @@ -16,6 +16,14 @@ Breaking Changes for 3.0.0:
are handled by methods matching the names on formatters. This allows
us to add or remove notifications without breaking existing formatters.
(Jon Rowe)
* Remove support for deprecated `:alias` option for
`RSpec.configuration.add_setting`. (Myron Marston)
* Remove support for deprecated `RSpec.configuration.requires = [...]`.
(Myron Marston)
* Remove support for deprecated `--formatter` CLI option. (Myron Marston)
* Remove support for deprecated `--configure` CLI option. (Myron Marston)
* Remove support for deprecated `RSpec::Core::RakeTask#spec_opts=`.
(Myron Marston)

Enhancements:

Expand Down
14 changes: 0 additions & 14 deletions lib/rspec/core.rb
Expand Up @@ -85,20 +85,6 @@ def self.reset
# @see RSpec.configure
# @see Core::Configuration
def self.configuration
if block_given?
RSpec.warn_deprecation <<-WARNING
*****************************************************************
DEPRECATION WARNING
* RSpec.configuration with a block is deprecated and has no effect.
* please use RSpec.configure with a block instead.
Called from #{CallerFilter.first_non_rspec_line}
*****************************************************************
WARNING
end
@configuration ||= begin
config = RSpec::Core::Configuration.new
config.expose_dsl_globally = true
Expand Down
22 changes: 3 additions & 19 deletions lib/rspec/core/configuration.rb
Expand Up @@ -41,11 +41,6 @@ def self.define_reader(name)
end
end

# @private
def self.deprecate_alias_key
RSpec.deprecate("add_setting with :alias option", :replacement => ":alias_with")
end

# @private
def self.define_aliases(name, alias_name)
alias_method alias_name, name
Expand All @@ -64,13 +59,9 @@ def self.define_predicate_for(*names)
# `Configuration` instance rather than this class method.
def self.add_setting(name, opts={})
raise "Use the instance add_setting method if you want to set a default" if opts.has_key?(:default)
if opts[:alias]
deprecate_alias_key
define_aliases(opts[:alias], name)
else
attr_writer name
add_read_only_setting name
end
attr_writer name
add_read_only_setting name

Array(opts[:alias_with]).each do |alias_name|
define_aliases(name, alias_name)
end
Expand Down Expand Up @@ -559,13 +550,6 @@ def libs=(libs)
end
end

def requires=(paths)
RSpec.deprecate("RSpec::Core::Configuration#requires=(paths)",
:replacement => "paths.each {|path| require path}")
paths.map {|path| require path}
@requires += paths
end

# Run examples defined on `line_numbers` in all files to run.
def line_numbers=(line_numbers)
filter_run :line_numbers => line_numbers.map{|l| l.to_i}
Expand Down
8 changes: 0 additions & 8 deletions lib/rspec/core/option_parser.rb
Expand Up @@ -26,9 +26,6 @@ def parse(args)
def convert_deprecated_args(args)
args.map! { |arg|
case arg
when "--formatter"
RSpec.deprecate("the --formatter option", :replacement => "-f or --format")
"--format"
when "--default_path"
"--default-path"
when "--line_number"
Expand Down Expand Up @@ -100,11 +97,6 @@ def parser(options)
exit
end

parser.on('--configure', 'Deprecated. Use --init instead.') do |cmd|
RSpec.warning "--configure is deprecated with no effect. Use --init instead.", :call_site => nil
exit
end

parser.separator("\n **** Output ****\n\n")

parser.on('-f', '--format FORMATTER', 'Choose a formatter.',
Expand Down
12 changes: 0 additions & 12 deletions lib/rspec/core/rake_task.rb
Expand Up @@ -54,18 +54,6 @@ class RakeTask < ::Rake::TaskLib
# nil
attr_accessor :rspec_opts

# @deprecated
# Use rspec_opts instead.
#
# Command line options to pass to rspec.
#
# default:
# nil
def spec_opts=(opts)
RSpec.deprecate('RSpec::Core::RakeTask#spec_opts=', :replacement => 'rspec_opts=')
@rspec_opts = opts
end

def initialize(*args, &task_block)
setup_ivars(args)

Expand Down
33 changes: 0 additions & 33 deletions spec/rspec/core/configuration_spec.rb
Expand Up @@ -7,15 +7,6 @@ module RSpec::Core

let(:config) { Configuration.new }

describe "RSpec.configuration with a block" do
before { allow(RSpec).to receive(:warn_deprecation) }

it "is deprecated" do
expect(RSpec).to receive(:warn_deprecation)
RSpec.configuration {}
end
end

describe '#deprecation_stream' do
it 'defaults to standard error' do
expect($rspec_core_without_stderr_monkey_patch.deprecation_stream).to eq STDERR
Expand Down Expand Up @@ -1030,22 +1021,6 @@ def metadata_hash(*args)
end
end

describe "#requires=" do
before { expect(RSpec).to receive :deprecate }

it "requires the configured files" do
expect(config).to receive(:require).with('foo').ordered
expect(config).to receive(:require).with('bar').ordered
config.requires = ['foo', 'bar']
end

it "stores require paths" do
expect(config).to receive(:require).with("a/path")
config.requires = ["a/path"]
expect(config.requires).to eq ['a/path']
end
end

describe "#add_setting" do
describe "with no modifiers" do
context "with no additional options" do
Expand Down Expand Up @@ -1097,14 +1072,6 @@ def metadata_hash(*args)
end
end

context "with :alias => " do
it "is deprecated" do
expect(RSpec)::to receive(:deprecate).with(/:alias option/, :replacement => ":alias_with")
config.add_setting :custom_option
config.add_setting :another_custom_option, :alias => :custom_option
end
end

context "with :alias_with => " do
before do
config.add_setting :custom_option, :alias_with => :another_custom_option
Expand Down
36 changes: 19 additions & 17 deletions spec/rspec/core/example_group_spec.rb
Expand Up @@ -938,29 +938,31 @@ def extract_execution_results(group)
end

%w[ fdescribe fcontext ].each do |method_name|
def executed_examples_of(group)
examples = group.examples.select { |ex| ex.metadata[:execution_result][:started_at] }
group.children.inject(examples) { |exs, child| exs + executed_examples_of(child) }
end
describe ".#{method_name}" do
def executed_examples_of(group)
examples = group.examples.select { |ex| ex.metadata[:execution_result][:started_at] }
group.children.inject(examples) { |exs, child| exs + executed_examples_of(child) }
end

[:focus, :focused].each do |metadata|
it "generates an example group that can be filtered with :#{metadata}" do
RSpec.configuration.filter_run metadata
[:focus, :focused].each do |metadata|
it "generates an example group that can be filtered with :#{metadata}" do
RSpec.configuration.filter_run metadata

parent_group = ExampleGroup.describe do
describe "not focused" do
example("not focused example") { }
end
parent_group = ExampleGroup.describe do
describe "not focused" do
example("not focused example") { }
end

send(method_name, "focused") do
example("focused example") { }
send(method_name, "focused") do
example("focused example") { }
end
end
end

parent_group.run
parent_group.run

executed_descriptions = executed_examples_of(parent_group).map(&:description)
expect(executed_descriptions).to eq(["focused example"])
executed_descriptions = executed_examples_of(parent_group).map(&:description)
expect(executed_descriptions).to eq(["focused example"])
end
end
end
end
Expand Down
12 changes: 0 additions & 12 deletions spec/rspec/core/option_parser_spec.rb
Expand Up @@ -45,18 +45,6 @@ module RSpec::Core
end
end

describe "--formatter" do
it "is deprecated" do
expect(RSpec).to receive(:deprecate)
Parser.parse(%w[--formatter doc])
end

it "gets converted to --format" do
options = Parser.parse(%w[--formatter doc])
expect(options[:formatters].first).to eq(["doc"])
end
end

describe "--default_path" do
it "gets converted to --default-path" do
options = Parser.parse(%w[--default_path foo])
Expand Down

0 comments on commit 6b22861

Please sign in to comment.