diff --git a/Changelog.md b/Changelog.md index d8c397cfad..657d352da2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,8 @@ -### Dev +### Development + +Breaking Changes for 3.0.0: + +* Remove explicit support for 1.8.6 (Jon Rowe) Enhancements diff --git a/cucumber.yml b/cucumber.yml index 2b5bc7f3e8..bb0b8cf01d 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -1,7 +1,6 @@ <% exclusions = [] exclusions << ' --tags ~@no-jruby' if RUBY_PLATFORM == 'java' -exclusions << ' --tags ~@no-ruby-186' if RUBY_VERSION == '1.8.6' %> default: --require features --strict --format progress --tags ~@wip<%= exclusions.join %> features wip: --require features --tags @wip:3 --wip features diff --git a/features/Upgrade.md b/features/Upgrade.md index e78d44548a..699ad950ee 100644 --- a/features/Upgrade.md +++ b/features/Upgrade.md @@ -123,10 +123,10 @@ Use :if and :unless keys to conditionally run examples with simple boolean expressions: describe "something" do - it "does something", :if => RUBY_VERSION == 1.8.6 do + it "does something", :if => RUBY_VERSION == 1.8.7 do # ... end - it "does something", :unless => RUBY_VERSION == 1.8.6 do + it "does something", :unless => RUBY_VERSION == 1.8.7 do # ... end end diff --git a/lib/rspec/core.rb b/lib/rspec/core.rb index 25fd945cbf..8c28748a92 100644 --- a/lib/rspec/core.rb +++ b/lib/rspec/core.rb @@ -14,8 +14,6 @@ require_rspec['core/filter_manager'] require_rspec['core/dsl'] require_rspec['core/extensions/kernel'] -require_rspec['core/extensions/instance_eval_with_args'] -require_rspec['core/extensions/module_eval_with_args'] require_rspec['core/extensions/ordered'] require_rspec['core/deprecation'] require_rspec['core/backward_compatibility'] diff --git a/lib/rspec/core/example.rb b/lib/rspec/core/example.rb index afee4f226c..415dfe54fe 100644 --- a/lib/rspec/core/example.rb +++ b/lib/rspec/core/example.rb @@ -243,8 +243,8 @@ def instance_eval_with_rescue(context = nil, &block) end # @private - def instance_eval_with_args(*args, &block) - @example_group_instance.instance_eval_with_args(*args, &block) + def instance_exec(*args, &block) + @example_group_instance.instance_exec(*args, &block) end private diff --git a/lib/rspec/core/example_group.rb b/lib/rspec/core/example_group.rb index ca82168d23..163680a049 100644 --- a/lib/rspec/core/example_group.rb +++ b/lib/rspec/core/example_group.rb @@ -14,11 +14,9 @@ module Core # is declared. class ExampleGroup extend MetadataHashBuilder::WithDeprecationWarning - extend Extensions::ModuleEvalWithArgs extend Hooks include MemoizedHelpers - include Extensions::InstanceEvalWithArgs include Pending include SharedExampleGroup @@ -161,7 +159,7 @@ def self.find_and_eval_shared(label, name, *args, &customization_block) raise ArgumentError, "Could not find shared #{label} #{name.inspect}" unless shared_block = shared_example_groups[name] - module_eval_with_args(*args, &shared_block) + module_exec(*args, &shared_block) module_eval(&customization_block) if customization_block end diff --git a/lib/rspec/core/extensions/instance_eval_with_args.rb b/lib/rspec/core/extensions/instance_eval_with_args.rb deleted file mode 100644 index a3c1d59978..0000000000 --- a/lib/rspec/core/extensions/instance_eval_with_args.rb +++ /dev/null @@ -1,44 +0,0 @@ -module RSpec - module Core - module Extensions - # @private - module InstanceEvalWithArgs - # @private - # - # Used internally to support `instance_exec` in Ruby 1.8.6. - # - # based on Bounded Spec InstanceExec (Mauricio Fernandez) - # http://eigenclass.org/hiki/bounded+space+instance_exec - # - uses singleton_class instead of global InstanceExecHelper module - # - this keeps it scoped to classes/modules that include this module - # - only necessary for ruby 1.8.6 - def instance_eval_with_args(*args, &block) - return instance_exec(*args, &block) if respond_to?(:instance_exec) - - # If there are no args and the block doesn't expect any, there's no - # need to fake instance_exec with our hack below. - # Notes: - # * lambda { }.arity # => -1 - # * lambda { || }.arity # => 0 - # * lambda { |*a| }.arity # -1 - return instance_eval(&block) if block.arity < 1 && args.size.zero? - - singleton_class = (class << self; self; end) - begin - orig_critical, Thread.critical = Thread.critical, true - n = 0 - n += 1 while respond_to?(method_name="__instance_exec#{n}") - singleton_class.module_eval{ define_method(method_name, &block) } - ensure - Thread.critical = orig_critical - end - begin - return send(method_name, *args) - ensure - singleton_class.module_eval{ remove_method(method_name) } rescue nil - end - end - end - end - end -end diff --git a/lib/rspec/core/extensions/module_eval_with_args.rb b/lib/rspec/core/extensions/module_eval_with_args.rb deleted file mode 100644 index a6bb25a1f4..0000000000 --- a/lib/rspec/core/extensions/module_eval_with_args.rb +++ /dev/null @@ -1,38 +0,0 @@ -module RSpec - module Core - module Extensions - # @private - module ModuleEvalWithArgs - include InstanceEvalWithArgs - - # @private - # - # Used internally to support `module_exec` in Ruby 1.8.6. - def module_eval_with_args(*args, &block) - # ruby > 1.8.6 - return module_exec(*args, &block) if respond_to?(:module_exec) - - # If there are no args and the block doesn't expect any, there's no - # need to fake module_exec with our hack below. - # Notes: - # * lambda { }.arity # => -1 - # * lambda { || }.arity # => 0 - # * lambda { |*a| }.arity # => -1 - return module_eval(&block) if block.arity < 1 && args.size.zero? - - orig_singleton_methods = singleton_methods - instance_eval_with_args(*args, &block) - - # The only difference between instance_eval and module_eval is static method defs. - # * `def foo` in instance_eval defines a singleton method on the instance - # * `def foo` in class/module_eval defines an instance method for the class/module - # Here we deal with this difference by defining an instance method for - # each new singleton method. - # This has the side effect of duplicating methods (all new class methods will - # become instance methods and vice versa), but I don't see a way around it... - (singleton_methods - orig_singleton_methods).each { |m| define_method(m, &method(m)) } - end - end - end - end -end diff --git a/lib/rspec/core/hooks.rb b/lib/rspec/core/hooks.rb index df3ea70366..f6b2fe5b87 100644 --- a/lib/rspec/core/hooks.rb +++ b/lib/rspec/core/hooks.rb @@ -84,7 +84,7 @@ def with(example, initial_procsy) def run inject(@initial_procsy) do |procsy, around_hook| Example.procsy(procsy.metadata) do - @example.instance_eval_with_args(procsy, &around_hook.block) + @example.instance_exec(procsy, &around_hook.block) end end.call end diff --git a/lib/rspec/core/rake_task.rb b/lib/rspec/core/rake_task.rb index 1bbb9f9ebd..d34983b42f 100644 --- a/lib/rspec/core/rake_task.rb +++ b/lib/rspec/core/rake_task.rb @@ -151,14 +151,8 @@ def run_task(verbose) private - if "".respond_to?(:shellescape) - def shellescape(string) - string.shellescape - end - else # 1.8.6's shellwords doesn't provide shellescape :(. - def shellescape(string) - string.gsub(/"/, '\"').gsub(/'/, "\\\\'") - end + def shellescape(string) + string.shellescape end def files_to_run diff --git a/rspec-core.gemspec b/rspec-core.gemspec index f6db3e9896..a8d6412535 100644 --- a/rspec-core.gemspec +++ b/rspec-core.gemspec @@ -23,6 +23,8 @@ Gem::Specification.new do |s| s.rdoc_options = ["--charset=UTF-8"] s.require_path = "lib" + s.required_ruby_version = '>= 1.8.7' + s.add_development_dependency "rake", "~> 10.0.0" s.add_development_dependency "cucumber", "~> 1.1.9" s.add_development_dependency "aruba", "~> 0.5"