diff --git a/features/command_line/exit_status.feature b/features/command_line/exit_status.feature index 3aca1d54a3..da982ffd09 100644 --- a/features/command_line/exit_status.feature +++ b/features/command_line/exit_status.feature @@ -71,7 +71,7 @@ Feature: exit status require 'rspec/autorun' at_exit { exit(0) } - describe "exit 0 at_exit" do + RSpec.describe "exit 0 at_exit" do it "does not interfere with rspec's exit code" do fail end diff --git a/features/command_line/ruby.feature b/features/command_line/ruby.feature index f55e472df5..6c150a7b38 100644 --- a/features/command_line/ruby.feature +++ b/features/command_line/ruby.feature @@ -12,7 +12,7 @@ Feature: run with ruby command """ruby require 'rspec/autorun' - describe 1 do + RSpec.describe 1 do it "is < 2" do expect(1).to be < 2 end diff --git a/features/configuration/enable_global_dsl.feature b/features/configuration/enable_global_dsl.feature new file mode 100644 index 0000000000..ad0cc3f4dc --- /dev/null +++ b/features/configuration/enable_global_dsl.feature @@ -0,0 +1,54 @@ +Feature: Global namespace DSL + + RSpec has a few top-level constructs that allow you to begin describing + behaviour: + + * `RSpec.describe`: Define a named context for a group of examples. + * `RSpec.shared_examples_for`: Define a set of shared examples that can later be included in an example group. + * `RSpec.shared_context`: define some common context (using `before`, `let`, helper methods, etc) that can later be included in an example group. + + Historically, these constructs have been available directly off of the main + object, so that you could use these at the start of a file without the + `RSpec.` prefix. They have also been available off of any class or module so + that you can scope your examples within a particular constant namespace. + + RSpec 3 now provides an option to disable this global monkey patching: + + `config.expose_dsl_globally = false`. + + For backwards compatibility it defaults to true. + + Scenario: by default RSpec allows the DSL to be used globally + Given a file named "spec/example_spec.rb" with: + """ruby + describe "specs here" do + it "passes" do + end + end + """ + When I run `rspec` + Then the output should contain "1 example, 0 failures" + + Scenario: when exposing globally is disabled the top level DSL no longer works + Given a file named "spec/example_spec.rb" with: + """ruby + RSpec.configure { |c| c.expose_dsl_globally = false } + describe "specs here" do + it "passes" do + end + end + """ + When I run `rspec` + Then the output should contain "undefined method `describe'" + + Scenario: regardless of setting + Given a file named "spec/example_spec.rb" with: + """ruby + RSpec.configure { |c| c.expose_dsl_globally = true } + RSpec.describe "specs here" do + it "passes" do + end + end + """ + When I run `rspec` + Then the output should contain "1 example, 0 failures" diff --git a/lib/rspec/core.rb b/lib/rspec/core.rb index 5ca0c77e77..62a5368db2 100644 --- a/lib/rspec/core.rb +++ b/lib/rspec/core.rb @@ -99,7 +99,12 @@ def self.configuration WARNING end - @configuration ||= RSpec::Core::Configuration.new + @configuration ||= begin + config = RSpec::Core::Configuration.new + config.expose_dsl_globally = true + config + end + end # @private diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index 8a4965baed..1da31d5542 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -102,6 +102,23 @@ def self.add_setting(name, opts={}) # Default: `$stderr`. add_setting :error_stream + # @macro add_setting + # Default: true + # Use this to expose the core RSpec DSL via `Module` and the `main` + # object. It will be set automatically but you can override it to + # remove the DSL. + add_setting :expose_dsl_globally + + def expose_dsl_globally=(value) + if value + Core::DSL.expose_globally! + Core::SharedExampleGroup::TopLevelDSL.expose_globally! + else + Core::DSL.remove_globally! + Core::SharedExampleGroup::TopLevelDSL.remove_globally! + end + end + # @macro add_setting # Default: `$stderr`. add_setting :deprecation_stream diff --git a/lib/rspec/core/dsl.rb b/lib/rspec/core/dsl.rb index f73ae36437..9955175163 100644 --- a/lib/rspec/core/dsl.rb +++ b/lib/rspec/core/dsl.rb @@ -1,26 +1,66 @@ module RSpec + + # Defines a named context for one or more examples. The given block + # is evaluated in the context of a generated subclass of + # {RSpec::Core::ExampleGroup} + # + # ## Examples: + # + # describe "something" do + # it "does something" do + # # example code goes here + # end + # end + # + # @see ExampleGroup + # @see ExampleGroup.describe + def self.describe(*args, &example_group_block) + RSpec::Core::ExampleGroup.describe(*args, &example_group_block).register + end + module Core - # Adds the `describe` method to the top-level namespace. module DSL - # Generates a subclass of {ExampleGroup} - # - # ## Examples: - # - # describe "something" do - # it "does something" do - # # example code goes here - # end - # end - # - # @see ExampleGroup - # @see ExampleGroup.describe - def describe(*args, &example_group_block) - RSpec::Core::ExampleGroup.describe(*args, &example_group_block).register + + class << self + # @private + attr_accessor :top_level + end + + # @private + def self.exposed_globally? + @exposed_globally ||= false + end + + # Add's the describe method to Module and the top level binding + def self.expose_globally! + return if exposed_globally? + + to_define = proc do + def describe(*args, &block) + ::RSpec.describe(*args, &block) + end + end + + top_level.instance_eval(&to_define) + Module.class_exec(&to_define) + @exposed_globally = true + end + + def self.remove_globally! + return unless exposed_globally? + + to_undefine = proc do + undef describe + end + + top_level.instance_eval(&to_undefine) + Module.class_exec(&to_undefine) + @exposed_globally = false end + end end end -extend RSpec::Core::DSL -Module.send(:include, RSpec::Core::DSL) - +# cature main without an eval +::RSpec::Core::DSL.top_level = self diff --git a/lib/rspec/core/shared_example_group.rb b/lib/rspec/core/shared_example_group.rb index 467f0cf3b3..b2bb89c44c 100644 --- a/lib/rspec/core/shared_example_group.rb +++ b/lib/rspec/core/shared_example_group.rb @@ -41,17 +41,49 @@ def shared_example_groups end module TopLevelDSL - def shared_examples(*args, &block) - SharedExampleGroup.registry.add_group('main', *args, &block) + def self.definitions + proc do + def shared_examples(*args, &block) + SharedExampleGroup.registry.add_group('main', *args, &block) + end + alias :shared_context :shared_examples + alias :share_examples_for :shared_examples + alias :shared_examples_for :shared_examples + def shared_example_groups + SharedExampleGroup.registry.shared_example_groups_for('main') + end + end end - alias_method :shared_context, :shared_examples - alias_method :share_examples_for, :shared_examples - alias_method :shared_examples_for, :shared_examples + # @private + def self.exposed_globally? + @exposed_globally ||= false + end - def shared_example_groups - SharedExampleGroup.registry.shared_example_groups_for('main') + def self.expose_globally! + return if exposed_globally? + + Core::DSL.top_level.instance_eval(&definitions) + Module.class_exec(&definitions) + @exposed_globally = true + end + + def self.remove_globally! + return unless exposed_globally? + + to_undefine = proc do + undef shared_examples + undef shared_context + undef share_examples_for + undef shared_examples_for + undef shared_example_groups + end + + Core::DSL.top_level.instance_eval(&to_undefine) + Module.class_exec(&to_undefine) + @exposed_globally = false end + end def self.registry @@ -140,7 +172,6 @@ def ensure_block_has_source_location(block, caller_line) end end end -end -extend RSpec::Core::SharedExampleGroup::TopLevelDSL -Module.send(:include, RSpec::Core::SharedExampleGroup::TopLevelDSL) + instance_eval &Core::SharedExampleGroup::TopLevelDSL.definitions +end diff --git a/script/ignores b/script/ignores index 35032e676e..0e53328e2f 100644 --- a/script/ignores +++ b/script/ignores @@ -72,3 +72,16 @@ lib/rspec/core/example_group.rb: subclass = Class.new(parent) # This happens at file load time. lib/rspec/core/formatters/deprecation_formatter.rb: DeprecationError = Class.new(StandardError) +# This enables / disable monkey patching and only happens on demand +lib/rspec/core/dsl.rb: to_undefine = proc do +lib/rspec/core/dsl.rb: undef describe +lib/rspec/core/dsl.rb: top_level.instance_eval(&to_undefine) +lib/rspec/core/dsl.rb: Module.class_exec(&to_undefine) +lib/rspec/core/shared_example_group.rb: to_undefine = proc do +lib/rspec/core/shared_example_group.rb: undef shared_examples +lib/rspec/core/shared_example_group.rb: undef shared_context +lib/rspec/core/shared_example_group.rb: undef share_examples_for +lib/rspec/core/shared_example_group.rb: undef shared_examples_for +lib/rspec/core/shared_example_group.rb: undef shared_example_groups +lib/rspec/core/shared_example_group.rb: Core::DSL.top_level.instance_eval(&to_undefine) +lib/rspec/core/shared_example_group.rb: Module.class_exec(&to_undefine) diff --git a/spec/command_line/order_spec.rb b/spec/command_line/order_spec.rb index 4a7aa04c29..1eee5dee2b 100644 --- a/spec/command_line/order_spec.rb +++ b/spec/command_line/order_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' -describe 'command line', :ui do +RSpec.describe 'command line', :ui do let(:stderr) { StringIO.new } let(:stdout) { StringIO.new } before :all do write_file 'spec/simple_spec.rb', """ - describe 'group 1' do + RSpec.describe 'group 1' do specify('group 1 example 1') {} specify('group 1 example 2') {} specify('group 1 example 3') {} @@ -19,7 +19,7 @@ """ write_file 'spec/simple_spec2.rb', """ - describe 'group 2' do + RSpec.describe 'group 2' do specify('group 2 example 1') {} specify('group 2 example 2') {} specify('group 2 example 3') {} @@ -32,7 +32,7 @@ """ write_file 'spec/order_spec.rb', """ - describe 'group 1' do + RSpec.describe 'group 1' do specify('group 1 example 1') {} specify('group 1 example 2') {} specify('group 1 example 3') {} @@ -68,15 +68,15 @@ describe('group 1-10') { specify('example') {} } end - describe('group 2') { specify('example') {} } - describe('group 3') { specify('example') {} } - describe('group 4') { specify('example') {} } - describe('group 5') { specify('example') {} } - describe('group 6') { specify('example') {} } - describe('group 7') { specify('example') {} } - describe('group 8') { specify('example') {} } - describe('group 9') { specify('example') {} } - describe('group 10') { specify('example') {} } + RSpec.describe('group 2') { specify('example') {} } + RSpec.describe('group 3') { specify('example') {} } + RSpec.describe('group 4') { specify('example') {} } + RSpec.describe('group 5') { specify('example') {} } + RSpec.describe('group 6') { specify('example') {} } + RSpec.describe('group 7') { specify('example') {} } + RSpec.describe('group 8') { specify('example') {} } + RSpec.describe('group 9') { specify('example') {} } + RSpec.describe('group 10') { specify('example') {} } """ end @@ -158,14 +158,14 @@ end end - describe 'group B' do + RSpec.describe 'group B' do specify('group B example D') {} specify('group B example B') {} specify('group B example A') {} specify('group B example C') {} end - describe 'group A' do + RSpec.describe 'group A' do specify('group A example 1') {} end """ diff --git a/spec/rspec/core/backtrace_formatter_spec.rb b/spec/rspec/core/backtrace_formatter_spec.rb index 556b11ebd1..fd991ca746 100644 --- a/spec/rspec/core/backtrace_formatter_spec.rb +++ b/spec/rspec/core/backtrace_formatter_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" module RSpec::Core - describe BacktraceFormatter do + RSpec.describe BacktraceFormatter do def make_backtrace_formatter(exclusion_patterns=nil, inclusion_patterns=nil) BacktraceFormatter.new.tap do |bc| bc.exclusion_patterns = exclusion_patterns if exclusion_patterns diff --git a/spec/rspec/core/command_line_spec.rb b/spec/rspec/core/command_line_spec.rb index a3dfaa9ba8..753d107b2c 100644 --- a/spec/rspec/core/command_line_spec.rb +++ b/spec/rspec/core/command_line_spec.rb @@ -3,19 +3,23 @@ require 'tmpdir' module RSpec::Core - describe CommandLine do + RSpec.describe CommandLine do let(:out) { StringIO.new } let(:err) { StringIO.new } let(:config) { RSpec::configuration } let(:world) { RSpec::world } - before { allow(config.hooks).to receive(:run) } + before do + allow(config.hooks).to receive(:run) + allow(config).to receive(:expose_dsl_globally?).and_return(false) + end it "configures streams before command line options" do + allow(RSpec).to receive(:deprecate) # remove this and should_receive when ordered stdout = StringIO.new - allow(config).to receive :load_spec_files - allow(config).to receive_messages(:reporter => double.as_null_object) + allow(config).to receive(:load_spec_files) + allow(config).to receive(:reporter).and_return(double.as_null_object) config.output_stream = $stdout # this is necessary to ensure that color works correctly on windows diff --git a/spec/rspec/core/configuration_options_spec.rb b/spec/rspec/core/configuration_options_spec.rb index d4a18a591b..876657d730 100644 --- a/spec/rspec/core/configuration_options_spec.rb +++ b/spec/rspec/core/configuration_options_spec.rb @@ -2,7 +2,7 @@ require 'ostruct' require 'rspec/core/drb_options' -describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolated_home => true do +RSpec.describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolated_home => true do include ConfigOptionsHelper it "warns when HOME env var is not set", :unless => (RUBY_PLATFORM == 'java') do @@ -20,6 +20,8 @@ end describe "#configure" do + let(:config) { RSpec::Core::Configuration.new } + it "sends libs before requires" do opts = config_options_object(*%w[--require a/path -I a/lib]) config = double("config").as_null_object @@ -62,14 +64,12 @@ it "assigns inclusion_filter" do opts = config_options_object(*%w[--tag awesome]) - config = RSpec::Core::Configuration.new opts.configure(config) expect(config.inclusion_filter).to have_key(:awesome) end it "merges the :exclusion_filter option with the default exclusion_filter" do opts = config_options_object(*%w[--tag ~slow]) - config = RSpec::Core::Configuration.new opts.configure(config) expect(config.exclusion_filter).to have_key(:slow) end @@ -104,7 +104,6 @@ it "merges --require specified by multiple configuration sources" do with_env_vars 'SPEC_OPTS' => "--require file_from_env" do opts = config_options_object(*%w[--require file_from_opts]) - config = RSpec::Core::Configuration.new expect(config).to receive(:require).with("file_from_opts") expect(config).to receive(:require).with("file_from_env") opts.configure(config) @@ -114,7 +113,6 @@ it "merges --I specified by multiple configuration sources" do with_env_vars 'SPEC_OPTS' => "-I dir_from_env" do opts = config_options_object(*%w[-I dir_from_opts]) - config = RSpec::Core::Configuration.new expect(config).to receive(:libs=).with(["dir_from_opts", "dir_from_env"]) opts.configure(config) end diff --git a/spec/rspec/core/configuration_spec.rb b/spec/rspec/core/configuration_spec.rb index 0fbee288a8..cbe979060d 100644 --- a/spec/rspec/core/configuration_spec.rb +++ b/spec/rspec/core/configuration_spec.rb @@ -3,7 +3,7 @@ module RSpec::Core - describe Configuration do + RSpec.describe Configuration do let(:config) { Configuration.new } diff --git a/spec/rspec/core/drb_command_line_spec.rb b/spec/rspec/core/drb_command_line_spec.rb index a29353e61d..fd5f83923b 100644 --- a/spec/rspec/core/drb_command_line_spec.rb +++ b/spec/rspec/core/drb_command_line_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require 'rspec/core/drb_command_line' -describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' do +RSpec.describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' do let(:config) { RSpec::Core::Configuration.new } let(:out) { StringIO.new } let(:err) { StringIO.new } @@ -70,7 +70,8 @@ class SimpleDRbSpecServer def self.run(argv, err, out) options = RSpec::Core::ConfigurationOptions.new(argv) options.parse_options - RSpec::Core::CommandLine.new(options, RSpec::Core::Configuration.new).run(err, out) + config = RSpec::Core::Configuration.new + RSpec::Core::CommandLine.new(options, config).run(err, out) end end diff --git a/spec/rspec/core/drb_options_spec.rb b/spec/rspec/core/drb_options_spec.rb index 5950a116e2..5b57cb21e1 100644 --- a/spec/rspec/core/drb_options_spec.rb +++ b/spec/rspec/core/drb_options_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require 'rspec/core/drb_options' -describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home => true do +RSpec.describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home => true do include ConfigOptionsHelper describe "#drb_argv" do diff --git a/spec/rspec/core/dsl_spec.rb b/spec/rspec/core/dsl_spec.rb index 08c75614ea..2105c06ceb 100644 --- a/spec/rspec/core/dsl_spec.rb +++ b/spec/rspec/core/dsl_spec.rb @@ -1,8 +1,11 @@ require 'spec_helper' +require 'support/in_sub_process' main = self -describe "The RSpec DSL" do +RSpec.describe "The RSpec DSL" do + include InSubProcess + methods = [ :describe, :share_examples_for, @@ -13,9 +16,17 @@ methods.each do |method_name| describe "##{method_name}" do + it "is added to the main object and Module when expose_dsl_globally is enabled" do + in_sub_process do + RSpec.configuration.expose_dsl_globally = true + expect(main).to respond_to(method_name) + expect(Module.new).to respond_to(method_name) + end + end + it "is added to the RSpec DSL" do + expect(::RSpec).to respond_to(method_name) + end it "is not added to every object in the system" do - expect(main).to respond_to(method_name) - expect(Module.new).to respond_to(method_name) expect(Object.new).not_to respond_to(method_name) end end diff --git a/spec/rspec/core/example_group_spec.rb b/spec/rspec/core/example_group_spec.rb index d1b0033151..7a6d3c1ed2 100644 --- a/spec/rspec/core/example_group_spec.rb +++ b/spec/rspec/core/example_group_spec.rb @@ -12,7 +12,7 @@ def initialize end module RSpec::Core - describe ExampleGroup do + RSpec.describe ExampleGroup do it_behaves_like "metadata hash builder" do def metadata_hash(*args) group = ExampleGroup.describe('example description', *args) diff --git a/spec/rspec/core/example_spec.rb b/spec/rspec/core/example_spec.rb index e78a723fe2..05f6891255 100644 --- a/spec/rspec/core/example_spec.rb +++ b/spec/rspec/core/example_spec.rb @@ -2,7 +2,7 @@ require 'pp' require 'stringio' -describe RSpec::Core::Example, :parent_metadata => 'sample' do +RSpec.describe RSpec::Core::Example, :parent_metadata => 'sample' do let(:example_group) do RSpec::Core::ExampleGroup.describe('group description') end diff --git a/spec/rspec/core/filter_manager_spec.rb b/spec/rspec/core/filter_manager_spec.rb index dca5303de0..f98a91182e 100644 --- a/spec/rspec/core/filter_manager_spec.rb +++ b/spec/rspec/core/filter_manager_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' module RSpec::Core - describe FilterManager do + RSpec.describe FilterManager do def opposite(name) name =~ /^in/ ? name.sub(/^(in)/,'ex') : name.sub(/^(ex)/,'in') end diff --git a/spec/rspec/core/formatters/base_formatter_spec.rb b/spec/rspec/core/formatters/base_formatter_spec.rb index 6901c6ea6d..c534ab67f0 100644 --- a/spec/rspec/core/formatters/base_formatter_spec.rb +++ b/spec/rspec/core/formatters/base_formatter_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rspec/core/formatters/base_formatter' -describe RSpec::Core::Formatters::BaseFormatter do +RSpec.describe RSpec::Core::Formatters::BaseFormatter do let(:output) { StringIO.new } let(:formatter) { RSpec::Core::Formatters::BaseFormatter.new(output) } diff --git a/spec/rspec/core/formatters/base_text_formatter_spec.rb b/spec/rspec/core/formatters/base_text_formatter_spec.rb index 028c5deebd..27aa85fe5d 100644 --- a/spec/rspec/core/formatters/base_text_formatter_spec.rb +++ b/spec/rspec/core/formatters/base_text_formatter_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rspec/core/formatters/base_text_formatter' -describe RSpec::Core::Formatters::BaseTextFormatter do +RSpec.describe RSpec::Core::Formatters::BaseTextFormatter do let(:output) { StringIO.new } let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) } diff --git a/spec/rspec/core/formatters/deprecation_formatter_spec.rb b/spec/rspec/core/formatters/deprecation_formatter_spec.rb index 05ac56463b..3111c875aa 100644 --- a/spec/rspec/core/formatters/deprecation_formatter_spec.rb +++ b/spec/rspec/core/formatters/deprecation_formatter_spec.rb @@ -3,7 +3,7 @@ require 'tempfile' module RSpec::Core::Formatters - describe DeprecationFormatter do + RSpec.describe DeprecationFormatter do describe "#deprecation" do let(:formatter) { DeprecationFormatter.new(deprecation_stream, summary_stream) } let(:summary_stream) { StringIO.new } diff --git a/spec/rspec/core/formatters/documentation_formatter_spec.rb b/spec/rspec/core/formatters/documentation_formatter_spec.rb index 2bb8e41e7f..c99f35a9d1 100644 --- a/spec/rspec/core/formatters/documentation_formatter_spec.rb +++ b/spec/rspec/core/formatters/documentation_formatter_spec.rb @@ -2,7 +2,7 @@ require 'rspec/core/formatters/documentation_formatter' module RSpec::Core::Formatters - describe DocumentationFormatter do + RSpec.describe DocumentationFormatter do it "numbers the failures" do examples = [ diff --git a/spec/rspec/core/formatters/helpers_spec.rb b/spec/rspec/core/formatters/helpers_spec.rb index 115bdff4dc..f395753ec9 100644 --- a/spec/rspec/core/formatters/helpers_spec.rb +++ b/spec/rspec/core/formatters/helpers_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rspec/core/formatters/helpers' -describe RSpec::Core::Formatters::Helpers do +RSpec.describe RSpec::Core::Formatters::Helpers do let(:helper) { Object.new.extend(RSpec::Core::Formatters::Helpers) } describe "format duration" do diff --git a/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html b/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html index 145d0ec628..04cb2de86c 100644 --- a/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +++ b/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html @@ -317,12 +317,13 @@
./spec/rspec/core/resources/formatter_specs.rb:18:in `(root)' -./spec/support/sandboxed_mock_space.rb:33:in `run' +./spec/support/sandboxed_mock_space.rb:33:in `sandboxed' ./spec/support/sandboxed_mock_space.rb:72:in `sandboxed' -./spec/support/sandboxed_mock_space.rb:32:in `run' +./spec/support/sandboxed_mock_space.rb:32:in `sandboxed' ./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `generated_html' -./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `Formatters' -./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `Formatters' +./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters' +./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters' +./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters' ./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
16 context "with content that would pass" do
17 it "fails" do
@@ -357,14 +358,15 @@ RSpec Code Examples
(compared using ==)
./spec/rspec/core/resources/formatter_specs.rb:33:in `(root)' -./spec/support/sandboxed_mock_space.rb:33:in `run' +./spec/support/sandboxed_mock_space.rb:33:in `sandboxed' ./spec/support/sandboxed_mock_space.rb:72:in `sandboxed' -./spec/support/sandboxed_mock_space.rb:32:in `run' +./spec/support/sandboxed_mock_space.rb:32:in `sandboxed' ./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `generated_html' -./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `Formatters' -./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `Formatters' +./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters' +./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters' +./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters' ./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
31describe "failing spec" do
+ 31RSpec.describe "failing spec" do
32 it "fails" do
33 expect(1).to eq(2)
34 end
@@ -386,12 +388,13 @@ RSpec Code Examples
(erb):1:in `result'
./spec/rspec/core/resources/formatter_specs.rb:41:in `(root)'
-./spec/support/sandboxed_mock_space.rb:33:in `run'
+./spec/support/sandboxed_mock_space.rb:33:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
-./spec/support/sandboxed_mock_space.rb:32:in `run'
+./spec/support/sandboxed_mock_space.rb:32:in `sandboxed'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `generated_html'
-./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `Formatters'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
-1# Couldn't get snippet for (erb)
diff --git a/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html b/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html
index c591b8c81c..2068afd9b7 100644
--- a/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html
+++ b/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html
@@ -317,21 +317,21 @@ RSpec Code Examples
./spec/rspec/core/resources/formatter_specs.rb:18:in `__script__'
-kernel/common/eval18.rb:45:in `instance_eval'
+kernel/common/eval18.rb:104:in `instance_exec'
./spec/support/sandboxed_mock_space.rb:33:in `run'
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/array18.rb:18:in `map'
-./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `Formatters'
kernel/common/hash18.rb:195:in `fetch'
-./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/io.rb:217:in `open'
-./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/dir.rb:92:in `chdir'
-./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `__script__'
-kernel/common/eval18.rb:45:in `instance_eval'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
+kernel/common/eval18.rb:104:in `instance_exec'
kernel/bootstrap/proc.rb:22:in `call'
kernel/common/eval18.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
@@ -341,9 +341,9 @@ RSpec Code Examples
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/proc.rb:22:in `call'
-kernel/loader.rb:702:in `run_at_exits'
-kernel/loader.rb:722:in `epilogue'
-kernel/loader.rb:855:in `main'
+kernel/loader.rb:698:in `run_at_exits'
+kernel/loader.rb:718:in `epilogue'
+kernel/loader.rb:851:in `main'
16 context "with content that would pass" do
17 it "fails" do
18 pending do
@@ -377,20 +377,20 @@ RSpec Code Examples
(compared using ==)
./spec/rspec/core/resources/formatter_specs.rb:33:in `__script__'
-kernel/common/eval18.rb:45:in `instance_eval'
+kernel/common/eval18.rb:104:in `instance_exec'
./spec/support/sandboxed_mock_space.rb:33:in `run'
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/array18.rb:18:in `map'
-./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `Formatters'
kernel/common/hash18.rb:195:in `fetch'
-./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/io.rb:217:in `open'
-./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/dir.rb:92:in `chdir'
-./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `__script__'
-kernel/common/eval18.rb:45:in `instance_eval'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
+kernel/common/eval18.rb:104:in `instance_exec'
kernel/bootstrap/proc.rb:22:in `call'
kernel/common/eval18.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
@@ -400,10 +400,10 @@ RSpec Code Examples
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/proc.rb:22:in `call'
-kernel/loader.rb:702:in `run_at_exits'
-kernel/loader.rb:722:in `epilogue'
-kernel/loader.rb:855:in `main'
- 31describe "failing spec" do
+kernel/loader.rb:698:in `run_at_exits'
+kernel/loader.rb:718:in `epilogue'
+kernel/loader.rb:851:in `main'
+ 31RSpec.describe "failing spec" do
32 it "fails" do
33 expect(1).to eq(2)
34 end
@@ -424,24 +424,24 @@ RSpec Code Examples
(erb):1:in `__script__'
-kernel/common/block_environment.rb:57:in `call_on_instance'
-kernel/common/eval.rb:73:in `eval'
-/Users/bradley/.rvm/rubies/rbx-head-18mode/lib/18/erb.rb:719:in `result'
+kernel/common/block_environment.rb:75:in `call_on_instance'
+kernel/common/eval.rb:75:in `eval'
+/Users/jon/.rvm/rubies/rbx-head/lib/18/erb.rb:719:in `result'
./spec/rspec/core/resources/formatter_specs.rb:41:in `__script__'
-kernel/common/eval18.rb:45:in `instance_eval'
+kernel/common/eval18.rb:104:in `instance_exec'
./spec/support/sandboxed_mock_space.rb:33:in `run'
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/array18.rb:18:in `map'
-./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `Formatters'
kernel/common/hash18.rb:195:in `fetch'
-./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/io.rb:217:in `open'
-./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `__script__'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/dir.rb:92:in `chdir'
-./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `__script__'
-kernel/common/eval18.rb:45:in `instance_eval'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
+kernel/common/eval18.rb:104:in `instance_exec'
kernel/bootstrap/proc.rb:22:in `call'
kernel/common/eval18.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
@@ -451,9 +451,9 @@ RSpec Code Examples
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/array18.rb:18:in `map'
kernel/bootstrap/proc.rb:22:in `call'
-kernel/loader.rb:702:in `run_at_exits'
-kernel/loader.rb:722:in `epilogue'
-kernel/loader.rb:855:in `main'
+kernel/loader.rb:698:in `run_at_exits'
+kernel/loader.rb:718:in `epilogue'
+kernel/loader.rb:851:in `main'
-1# Couldn't get snippet for (erb)
diff --git a/spec/rspec/core/formatters/html_formatted-1.8.7.html b/spec/rspec/core/formatters/html_formatted-1.8.7.html
index 40e7461174..63da2e8efc 100644
--- a/spec/rspec/core/formatters/html_formatted-1.8.7.html
+++ b/spec/rspec/core/formatters/html_formatted-1.8.7.html
@@ -370,7 +370,7 @@ RSpec Code Examples
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:58
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
- 31describe "failing spec" do
+ 31RSpec.describe "failing spec" do
32 it "fails" do
33 expect(1).to eq(2)
34 end
diff --git a/spec/rspec/core/formatters/html_formatted-1.9.2.html b/spec/rspec/core/formatters/html_formatted-1.9.2.html
index d0236792f5..ec97f8c294 100644
--- a/spec/rspec/core/formatters/html_formatted-1.9.2.html
+++ b/spec/rspec/core/formatters/html_formatted-1.9.2.html
@@ -370,7 +370,7 @@ RSpec Code Examples
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `block (3 levels) in <module:Formatters>'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
- 31describe "failing spec" do
+ 31RSpec.describe "failing spec" do
32 it "fails" do
33 expect(1).to eq(2)
34 end
diff --git a/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html b/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html
index 5c70bffec2..27b000236e 100644
--- a/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html
+++ b/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html
@@ -317,13 +317,14 @@ RSpec Code Examples
./spec/rspec/core/resources/formatter_specs.rb:18:in `(root)'
-././spec/support/sandboxed_mock_space.rb:33:in `run'
-././spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
-././spec/support/sandboxed_mock_space.rb:32:in `run'
+./spec/support/sandboxed_mock_space.rb:33:in `run'
+./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
+./spec/support/sandboxed_mock_space.rb:32:in `run'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `generated_html'
-./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `Formatters'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `Formatters'
-././spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
+./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
16 context "with content that would pass" do
17 it "fails" do
18 pending do
@@ -357,14 +358,15 @@ RSpec Code Examples
(compared using ==)
./spec/rspec/core/resources/formatter_specs.rb:33:in `(root)'
-././spec/support/sandboxed_mock_space.rb:33:in `run'
-././spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
-././spec/support/sandboxed_mock_space.rb:32:in `run'
+./spec/support/sandboxed_mock_space.rb:33:in `run'
+./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
+./spec/support/sandboxed_mock_space.rb:32:in `run'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `generated_html'
-./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `Formatters'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `Formatters'
-././spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
- 31describe "failing spec" do
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
+./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
+ 31RSpec.describe "failing spec" do
32 it "fails" do
33 expect(1).to eq(2)
34 end
@@ -386,13 +388,14 @@ RSpec Code Examples
(erb):1:in `result'
./spec/rspec/core/resources/formatter_specs.rb:41:in `(root)'
-././spec/support/sandboxed_mock_space.rb:33:in `run'
-././spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
-././spec/support/sandboxed_mock_space.rb:32:in `run'
+./spec/support/sandboxed_mock_space.rb:33:in `run'
+./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
+./spec/support/sandboxed_mock_space.rb:32:in `run'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `generated_html'
-./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `Formatters'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `Formatters'
-././spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
+./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
-1# Couldn't get snippet for (erb)
diff --git a/spec/rspec/core/formatters/html_formatted-1.9.3.html b/spec/rspec/core/formatters/html_formatted-1.9.3.html
index 169d6194bc..ec97f8c294 100644
--- a/spec/rspec/core/formatters/html_formatted-1.9.3.html
+++ b/spec/rspec/core/formatters/html_formatted-1.9.3.html
@@ -321,9 +321,11 @@ RSpec Code Examples
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `block (2 levels) in <module:Formatters>'
-./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `block (3 levels) in <module:Formatters>'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `chdir'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `block (2 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `block (5 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `open'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `block (4 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `chdir'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `block (3 levels) in <module:Formatters>'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
16 context "with content that would pass" do
17 it "fails" do
@@ -362,11 +364,13 @@ RSpec Code Examples
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `block (2 levels) in <module:Formatters>'
-./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `block (3 levels) in <module:Formatters>'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `chdir'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `block (2 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `block (5 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `open'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `block (4 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `chdir'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `block (3 levels) in <module:Formatters>'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
- 31describe "failing spec" do
+ 31RSpec.describe "failing spec" do
32 it "fails" do
33 expect(1).to eq(2)
34 end
@@ -392,9 +396,11 @@ RSpec Code Examples
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `block (2 levels) in <module:Formatters>'
-./spec/rspec/core/formatters/html_formatter_spec.rb:73:in `block (3 levels) in <module:Formatters>'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `chdir'
-./spec/rspec/core/formatters/html_formatter_spec.rb:72:in `block (2 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `block (5 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `open'
+./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `block (4 levels) in <module:Formatters>'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `chdir'
+./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `block (3 levels) in <module:Formatters>'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
-1# Couldn't get snippet for (erb)
diff --git a/spec/rspec/core/formatters/html_formatted-2.0.0.html b/spec/rspec/core/formatters/html_formatted-2.0.0.html
index a637c20243..5e8890f955 100644
--- a/spec/rspec/core/formatters/html_formatted-2.0.0.html
+++ b/spec/rspec/core/formatters/html_formatted-2.0.0.html
@@ -370,7 +370,7 @@ RSpec Code Examples
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `block (3 levels) in <module:Formatters>'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
- 31describe "failing spec" do
+ 31RSpec.describe "failing spec" do
32 it "fails" do
33 expect(1).to eq(2)
34 end
diff --git a/spec/rspec/core/formatters/html_formatter_spec.rb b/spec/rspec/core/formatters/html_formatter_spec.rb
index 1818350e42..96873aa690 100644
--- a/spec/rspec/core/formatters/html_formatter_spec.rb
+++ b/spec/rspec/core/formatters/html_formatter_spec.rb
@@ -6,7 +6,7 @@
module RSpec
module Core
module Formatters
- describe HtmlFormatter, :if => RUBY_VERSION =~ /^(1.8.7|1.9.2|1.9.3|2.0.0)$/ do
+ RSpec.describe HtmlFormatter, :if => RUBY_VERSION =~ /^(1.8.7|1.9.2|1.9.3|2.0.0)$/ do
let(:suffix) {
if ::RUBY_PLATFORM == 'java'
"-jruby"
diff --git a/spec/rspec/core/formatters/json_formatter_spec.rb b/spec/rspec/core/formatters/json_formatter_spec.rb
index 399e1c1bb5..6194d72276 100644
--- a/spec/rspec/core/formatters/json_formatter_spec.rb
+++ b/spec/rspec/core/formatters/json_formatter_spec.rb
@@ -11,7 +11,7 @@
# it "shows the pending message if one was given"
# it "shows the seed if run was randomized"
# it "lists pending specs that were fixed"
-describe RSpec::Core::Formatters::JsonFormatter do
+RSpec.describe RSpec::Core::Formatters::JsonFormatter do
let(:output) { StringIO.new }
let(:formatter) { RSpec::Core::Formatters::JsonFormatter.new(output) }
let(:config) { RSpec::Core::Configuration.new }
diff --git a/spec/rspec/core/formatters/progress_formatter_spec.rb b/spec/rspec/core/formatters/progress_formatter_spec.rb
index b9f6cc5dd1..0c25ab9308 100644
--- a/spec/rspec/core/formatters/progress_formatter_spec.rb
+++ b/spec/rspec/core/formatters/progress_formatter_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'rspec/core/formatters/progress_formatter'
-describe RSpec::Core::Formatters::ProgressFormatter do
+RSpec.describe RSpec::Core::Formatters::ProgressFormatter do
before do
@output = StringIO.new
diff --git a/spec/rspec/core/formatters/snippet_extractor_spec.rb b/spec/rspec/core/formatters/snippet_extractor_spec.rb
index 5898f14872..341007bb2f 100644
--- a/spec/rspec/core/formatters/snippet_extractor_spec.rb
+++ b/spec/rspec/core/formatters/snippet_extractor_spec.rb
@@ -4,7 +4,7 @@
module RSpec
module Core
module Formatters
- describe SnippetExtractor do
+ RSpec.describe SnippetExtractor do
it "falls back on a default message when it doesn't understand a line" do
expect(RSpec::Core::Formatters::SnippetExtractor.new.snippet_for("blech")).to eq(["# Couldn't get snippet for blech", 1])
end
diff --git a/spec/rspec/core/hooks_filtering_spec.rb b/spec/rspec/core/hooks_filtering_spec.rb
index 2eda0b4c6a..dc593d6707 100644
--- a/spec/rspec/core/hooks_filtering_spec.rb
+++ b/spec/rspec/core/hooks_filtering_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
module RSpec::Core
- describe "config block hook filtering" do
+ RSpec.describe "config block hook filtering" do
describe "unfiltered hooks" do
it "is run" do
filters = []
diff --git a/spec/rspec/core/hooks_spec.rb b/spec/rspec/core/hooks_spec.rb
index 5263674b9d..21c3508ea4 100644
--- a/spec/rspec/core/hooks_spec.rb
+++ b/spec/rspec/core/hooks_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
module RSpec::Core
- describe Hooks do
+ RSpec.describe Hooks do
class HooksHost
include Hooks
diff --git a/spec/rspec/core/memoized_helpers_spec.rb b/spec/rspec/core/memoized_helpers_spec.rb
index 0dee317f09..bbcf57aeec 100644
--- a/spec/rspec/core/memoized_helpers_spec.rb
+++ b/spec/rspec/core/memoized_helpers_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
module RSpec::Core
- describe MemoizedHelpers do
+ RSpec.describe MemoizedHelpers do
before(:each) { RSpec.configuration.configure_expectation_framework }
def subject_value_for(describe_arg, &block)
@@ -325,7 +325,7 @@ def not_ok?; false; end
end
end
- describe "#let" do
+ RSpec.describe "#let" do
let(:counter) do
Class.new do
def initialize
@@ -443,7 +443,7 @@ def hello_message; "Hello from module"; end
end
end
- describe "#let!" do
+ RSpec.describe "#let!" do
subject { [1,2,3] }
let!(:popped) { subject.pop }
@@ -456,7 +456,7 @@ def hello_message; "Hello from module"; end
end
end
- describe 'using subject in before and let blocks' do
+ RSpec.describe 'using subject in before and let blocks' do
shared_examples_for 'a subject' do
let(:subject_id_in_let) { subject.object_id }
before { @subject_id_in_before = subject.object_id }
@@ -485,7 +485,7 @@ def hello_message; "Hello from module"; end
end
end
- describe 'Module#define_method' do
+ RSpec.describe 'Module#define_method' do
it 'is still a private method' do
a_module = Module.new
expect { a_module.define_method(:name) { "implementation" } }.to raise_error NoMethodError
diff --git a/spec/rspec/core/metadata_spec.rb b/spec/rspec/core/metadata_spec.rb
index 0b8dba10cc..b5013a1667 100644
--- a/spec/rspec/core/metadata_spec.rb
+++ b/spec/rspec/core/metadata_spec.rb
@@ -2,7 +2,7 @@
module RSpec
module Core
- describe Metadata do
+ RSpec.describe Metadata do
describe '.relative_path' do
let(:here) { File.expand_path(".") }
diff --git a/spec/rspec/core/option_parser_spec.rb b/spec/rspec/core/option_parser_spec.rb
index 22d9949117..b73e452ee8 100644
--- a/spec/rspec/core/option_parser_spec.rb
+++ b/spec/rspec/core/option_parser_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
module RSpec::Core
- describe OptionParser do
+ RSpec.describe OptionParser do
let(:output_file){ mock File }
before do
diff --git a/spec/rspec/core/ordering_spec.rb b/spec/rspec/core/ordering_spec.rb
index 03b991e447..2a96328cc0 100644
--- a/spec/rspec/core/ordering_spec.rb
+++ b/spec/rspec/core/ordering_spec.rb
@@ -3,13 +3,13 @@
module RSpec
module Core
module Ordering
- describe Identity do
+ RSpec.describe Identity do
it "does not affect the ordering of the items" do
expect(Identity.new.order([1, 2, 3])).to eq([1, 2, 3])
end
end
- describe Random do
+ RSpec.describe Random do
describe '.order' do
subject { described_class.new(configuration) }
@@ -48,7 +48,7 @@ module Ordering
end
end
- describe Custom do
+ RSpec.describe Custom do
it 'uses the block to order the list' do
strategy = Custom.new(proc { |list| list.reverse })
@@ -56,7 +56,7 @@ module Ordering
end
end
- describe Registry do
+ RSpec.describe Registry do
let(:configuration) { Configuration.new }
subject(:registry) { Registry.new(configuration) }
diff --git a/spec/rspec/core/pending_example_spec.rb b/spec/rspec/core/pending_example_spec.rb
index bda20629e4..6cc044adf7 100644
--- a/spec/rspec/core/pending_example_spec.rb
+++ b/spec/rspec/core/pending_example_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "an example" do
+RSpec.describe "an example" do
matcher :be_pending_with do |message|
match do |example|
example.pending? && example.metadata[:execution_result][:pending_message] == message
diff --git a/spec/rspec/core/project_initializer_spec.rb b/spec/rspec/core/project_initializer_spec.rb
index 2d189dade7..6c9108cb9d 100644
--- a/spec/rspec/core/project_initializer_spec.rb
+++ b/spec/rspec/core/project_initializer_spec.rb
@@ -2,7 +2,7 @@
require 'rspec/core/project_initializer'
module RSpec::Core
- describe ProjectInitializer, :isolated_directory => true do
+ RSpec.describe ProjectInitializer, :isolated_directory => true do
describe "#run" do
context "with no args" do
diff --git a/spec/rspec/core/rake_task_spec.rb b/spec/rspec/core/rake_task_spec.rb
index 6f9a1f1337..980577e449 100644
--- a/spec/rspec/core/rake_task_spec.rb
+++ b/spec/rspec/core/rake_task_spec.rb
@@ -3,7 +3,7 @@
require 'tempfile'
module RSpec::Core
- describe RakeTask do
+ RSpec.describe RakeTask do
let(:task) { RakeTask.new }
def ruby
diff --git a/spec/rspec/core/random_spec.rb b/spec/rspec/core/random_spec.rb
index 88bb27033d..0875d4cec9 100644
--- a/spec/rspec/core/random_spec.rb
+++ b/spec/rspec/core/random_spec.rb
@@ -2,7 +2,7 @@
module RSpec
module Core
- describe RandomNumberGenerator do
+ RSpec.describe RandomNumberGenerator do
it 'is a random number generator' do
random = described_class.new
diff --git a/spec/rspec/core/reporter_spec.rb b/spec/rspec/core/reporter_spec.rb
index b6ad45a2e2..815eb2c040 100644
--- a/spec/rspec/core/reporter_spec.rb
+++ b/spec/rspec/core/reporter_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
module RSpec::Core
- describe Reporter do
+ RSpec.describe Reporter do
let(:config) { Configuration.new }
def reporter_for(*formatters)
diff --git a/spec/rspec/core/resources/formatter_specs.rb b/spec/rspec/core/resources/formatter_specs.rb
index 88a3ccd4f6..b1f4db40af 100644
--- a/spec/rspec/core/resources/formatter_specs.rb
+++ b/spec/rspec/core/resources/formatter_specs.rb
@@ -1,10 +1,10 @@
# Deliberately named _specs.rb to avoid being loaded except when specified
-describe "pending spec with no implementation" do
+RSpec.describe "pending spec with no implementation" do
it "is pending"
end
-describe "pending command with block format" do
+RSpec.describe "pending command with block format" do
context "with content that would fail" do
it "is pending" do
pending do
@@ -22,19 +22,19 @@
end
end
-describe "passing spec" do
+RSpec.describe "passing spec" do
it "passes" do
expect(1).to eq(1)
end
end
-describe "failing spec" do
+RSpec.describe "failing spec" do
it "fails" do
expect(1).to eq(2)
end
end
-describe "a failing spec with odd backtraces" do
+RSpec.describe "a failing spec with odd backtraces" do
it "fails with a backtrace that has no file" do
require 'erb'
diff --git a/spec/rspec/core/rspec_matchers_spec.rb b/spec/rspec/core/rspec_matchers_spec.rb
index 128de47673..70e51b3c5d 100644
--- a/spec/rspec/core/rspec_matchers_spec.rb
+++ b/spec/rspec/core/rspec_matchers_spec.rb
@@ -14,7 +14,7 @@ module ModThatIncludesMatchers
c.include ModThatIncludesMatchers, :include_mod_that_includes_rspec_matchers => true
end
- describe self do
+ RSpec.describe self do
shared_examples_for "a normal module with a method that supers" do
it "raises the expected error (and not SystemStackError)" do
expect { __method_with_super }.to raise_error(NoMethodError) # there is no __method_with_super in an ancestor
diff --git a/spec/rspec/core/ruby_project_spec.rb b/spec/rspec/core/ruby_project_spec.rb
index 805614b9f5..7091c188b9 100644
--- a/spec/rspec/core/ruby_project_spec.rb
+++ b/spec/rspec/core/ruby_project_spec.rb
@@ -2,7 +2,7 @@
module RSpec
module Core
- describe RubyProject do
+ RSpec.describe RubyProject do
describe "#determine_root" do
diff --git a/spec/rspec/core/runner_spec.rb b/spec/rspec/core/runner_spec.rb
index 923d4af77f..193789a48c 100644
--- a/spec/rspec/core/runner_spec.rb
+++ b/spec/rspec/core/runner_spec.rb
@@ -2,7 +2,7 @@
require 'rspec/core/drb_command_line'
module RSpec::Core
- describe Runner do
+ RSpec.describe Runner do
describe 'invocation' do
before do
# Simulate invoking the suite like exe/rspec does.
diff --git a/spec/rspec/core/shared_context_spec.rb b/spec/rspec/core/shared_context_spec.rb
index 0f14b6c419..aee413c754 100644
--- a/spec/rspec/core/shared_context_spec.rb
+++ b/spec/rspec/core/shared_context_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe RSpec::SharedContext do
+RSpec.describe RSpec::SharedContext do
it "is accessible as RSpec::Core::SharedContext" do
RSpec::Core::SharedContext
end
@@ -42,11 +42,11 @@
c.before(:each) { ordered_hooks << "config" }
end
- shared_context("before each stuff", :example => :before_each_hook_order) do
+ RSpec.shared_context("before each stuff", :example => :before_each_hook_order) do
before(:each) { ordered_hooks << "shared_context"}
end
- group = RSpec::Core::ExampleGroup.describe :example => :before_each_hook_order do
+ group = RSpec.describe :example => :before_each_hook_order do
before(:each) { ordered_hooks << "example_group" }
example {}
end
@@ -61,7 +61,7 @@
extend RSpec::SharedContext
let(:foo) { 'foo' }
end
- group = RSpec::Core::ExampleGroup.describe do
+ group = RSpec.describe do
include shared
end
diff --git a/spec/rspec/core/shared_example_group/collection_spec.rb b/spec/rspec/core/shared_example_group/collection_spec.rb
index 3075c4db60..2649a6d502 100644
--- a/spec/rspec/core/shared_example_group/collection_spec.rb
+++ b/spec/rspec/core/shared_example_group/collection_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
module RSpec::Core::SharedExampleGroup
- describe Collection do
+ RSpec.describe Collection do
# this represents:
#
diff --git a/spec/rspec/core/shared_example_group_spec.rb b/spec/rspec/core/shared_example_group_spec.rb
index cebe89e058..386ec19037 100644
--- a/spec/rspec/core/shared_example_group_spec.rb
+++ b/spec/rspec/core/shared_example_group_spec.rb
@@ -1,13 +1,15 @@
require 'spec_helper'
+require 'support/in_sub_process'
module RandomTopLevelModule
def self.setup!
- shared_examples_for("top level in module") {}
+ RSpec.shared_examples_for("top level in module") {}
end
end
module RSpec::Core
- describe SharedExampleGroup do
+ RSpec.describe SharedExampleGroup do
+ include InSubProcess
ExampleModule = Module.new
ExampleClass = Class.new
@@ -18,7 +20,7 @@ module RSpec::Core
end
module SharedExampleGroup
- describe Registry do
+ RSpec.describe Registry do
it "can safely be reset when there aren't any shared groups" do
expect { Registry.new.clear }.to_not raise_error
end
@@ -38,8 +40,15 @@ module SharedExampleGroup
group.send(shared_method_name, *args, &block)
end
- it "is exposed to the global namespace" do
- expect(Kernel).to respond_to(shared_method_name)
+ it "is exposed to the global namespace when expose_dsl_globally is enabled" do
+ in_sub_process do
+ RSpec.configuration.expose_dsl_globally = true
+ expect(Kernel).to respond_to(shared_method_name)
+ end
+ end
+
+ it "is not exposed to the global namespace when monkey patching is disabled" do
+ expect(Kernel).to_not respond_to(shared_method_name)
end
it "displays a warning when adding a second shared example group with the same name" do
diff --git a/spec/rspec/core/warnings_spec.rb b/spec/rspec/core/warnings_spec.rb
index 1ace69e995..f018b6174f 100644
--- a/spec/rspec/core/warnings_spec.rb
+++ b/spec/rspec/core/warnings_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe "RSpec deprecations and warnings" do
+RSpec.describe "rspec warnings and deprecations" do
describe "#deprecate" do
it "passes the hash to the reporter" do
diff --git a/spec/rspec/core/world_spec.rb b/spec/rspec/core/world_spec.rb
index cd8d4386db..c9bf3608d1 100644
--- a/spec/rspec/core/world_spec.rb
+++ b/spec/rspec/core/world_spec.rb
@@ -5,7 +5,7 @@ class Foo; end
module RSpec::Core
- describe RSpec::Core::World do
+ RSpec.describe RSpec::Core::World do
let(:configuration) { RSpec::Core::Configuration.new }
let(:world) { RSpec::Core::World.new(configuration) }
diff --git a/spec/rspec/core_spec.rb b/spec/rspec/core_spec.rb
index 802124db1a..070773a2ab 100644
--- a/spec/rspec/core_spec.rb
+++ b/spec/rspec/core_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe RSpec do
+RSpec.describe RSpec do
describe "::configuration" do
it "returns the same object every time" do
expect(RSpec.configuration).to equal(RSpec.configuration)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2a21f8009b..6dac170077 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -58,6 +58,7 @@ def self.sandboxed(&block)
@orig_world = RSpec.world
@orig_example = RSpec.current_example
new_config = RSpec::Core::Configuration.new
+ new_config.expose_dsl_globally = false
new_world = RSpec::Core::World.new(new_config)
RSpec.configuration = new_config
RSpec.world = new_world
diff --git a/spec/support/isolate_load_path_mutation.rb b/spec/support/isolate_load_path_mutation.rb
index 98184cccca..7eb0181b2c 100644
--- a/spec/support/isolate_load_path_mutation.rb
+++ b/spec/support/isolate_load_path_mutation.rb
@@ -1,6 +1,5 @@
-shared_context "isolate load path mutation" do
+RSpec.shared_context "isolate load path mutation" do
original_load_path = nil
before { original_load_path = $LOAD_PATH.dup }
after { $LOAD_PATH.replace(original_load_path) }
end
-
diff --git a/spec/support/isolated_directory.rb b/spec/support/isolated_directory.rb
index b01c2b9efd..d83b51b7f4 100644
--- a/spec/support/isolated_directory.rb
+++ b/spec/support/isolated_directory.rb
@@ -1,7 +1,7 @@
require 'tmpdir'
require 'fileutils'
-shared_context "isolated directory", :isolated_directory => true do
+RSpec.shared_context "isolated directory", :isolated_directory => true do
around do |ex|
Dir.mktmpdir do |tmp_dir|
Dir.chdir(tmp_dir, &ex)
diff --git a/spec/support/isolated_home_directory.rb b/spec/support/isolated_home_directory.rb
index b66f6064f1..2f6fb940f9 100644
--- a/spec/support/isolated_home_directory.rb
+++ b/spec/support/isolated_home_directory.rb
@@ -1,7 +1,7 @@
require 'tmpdir'
require 'fileutils'
-shared_context "isolated home directory", :isolated_home => true do
+RSpec.shared_context "isolated home directory", :isolated_home => true do
around do |ex|
Dir.mktmpdir do |tmp_dir|
original_home = ENV['HOME']
diff --git a/spec/support/shared_example_groups.rb b/spec/support/shared_example_groups.rb
index d39a134ea4..6ad7fcb789 100644
--- a/spec/support/shared_example_groups.rb
+++ b/spec/support/shared_example_groups.rb
@@ -1,4 +1,4 @@
-shared_examples_for "metadata hash builder" do
+RSpec.shared_examples_for "metadata hash builder" do
let(:hash) { metadata_hash(:foo, :bar, :bazz => 23) }
it 'treats symbols as metadata keys with a true value' do
diff --git a/spec/support/spec_files.rb b/spec/support/spec_files.rb
index c2724f7544..a9f89f16e8 100644
--- a/spec/support/spec_files.rb
+++ b/spec/support/spec_files.rb
@@ -1,4 +1,4 @@
-shared_context "spec files" do
+RSpec.shared_context "spec files" do
def failing_spec_filename
@failing_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_failing_spec.rb"
end
@@ -10,7 +10,7 @@ def passing_spec_filename
def create_passing_spec_file
File.open(passing_spec_filename, 'w') do |f|
f.write %q{
- describe "passing spec" do
+ RSpec.describe "passing spec" do
it "passes" do
expect(1).to eq(1)
end
@@ -22,7 +22,7 @@ def create_passing_spec_file
def create_failing_spec_file
File.open(failing_spec_filename, 'w') do |f|
f.write %q{
- describe "failing spec" do
+ RSpec.describe "failing spec" do
it "fails" do
expect(1).to eq(2)
end