diff --git a/Changelog.md b/Changelog.md index baa611712f..cd30d05568 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,10 +1,24 @@ +### 2.14.2 / 2013-07-09 +[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.1...v2.14.2) + +Bug fixes + +* Fix regression caused by 2.14.1 release: formatters that + report that they `respond_to?` a notification, but had + no corresponding method would raise an error when registered. + The new fix is to just implement `start` on the deprecation + formatter to fix the original JRuby/ruby-debug issue. + (Jon Rowe) + ### 2.14.1 / 2013-07-08 [full changelog](http://github.com/rspec/rspec-core/compare/v2.14.0...v2.14.1) Bug fixes -* Implement `#start` on the Deprecation Formatter to prevent collision with - `ruby-debug` on JRuby (Alex Portnov, Jon Rowe) +* Address deprecation formatter failure when using `ruby-debug` on + JRuby: fix `RSpec::Core::Reporter` to not send a notification + when the formatter's implementation of the notification method + comes from `Kernel` (Alex Portnov, Jon Rowe). ### 2.14.0 / 2013-07-06 [full changelog](http://github.com/rspec/rspec-core/compare/v2.14.0.rc1...v2.14.0) diff --git a/lib/rspec/core/formatters/deprecation_formatter.rb b/lib/rspec/core/formatters/deprecation_formatter.rb index b19aa4c1fa..b6583d441d 100644 --- a/lib/rspec/core/formatters/deprecation_formatter.rb +++ b/lib/rspec/core/formatters/deprecation_formatter.rb @@ -8,6 +8,10 @@ def initialize(deprecation_stream=$stderr, summary_stream=$stdout) @count = 0 end + def start(example_count=nil) + #no-op to fix #966 + end + def deprecation(data) @count += 1 if data[:message] diff --git a/lib/rspec/core/reporter.rb b/lib/rspec/core/reporter.rb index a7eca82d85..33f86f3f90 100644 --- a/lib/rspec/core/reporter.rb +++ b/lib/rspec/core/reporter.rb @@ -21,7 +21,7 @@ def initialize(*formatters) # events to all registered listeners def register_listener(listener, *notifications) notifications.each do |notification| - @listeners[notification.to_sym] << listener if understands(listener, notification) + @listeners[notification.to_sym] << listener if listener.respond_to?(notification) end true end @@ -128,18 +128,5 @@ def notify(event, *args, &block) end end - private - if Method.method_defined?(:owner) # 1.8.6 lacks Method#owner - def understands(listener, notification) - listener.respond_to?(notification) && listener.method(notification).owner != ::Kernel - end - else - def understands(listener, notification) - # Hack for 1.8.6 - # {}.method(:=~).to_s # => "#" - listener.respond_to?(notification) && !listener.method(notification).to_s.include('(Kernel)') - end - end - end end diff --git a/lib/rspec/core/version.rb b/lib/rspec/core/version.rb index a6733a01e3..3c78b98936 100644 --- a/lib/rspec/core/version.rb +++ b/lib/rspec/core/version.rb @@ -1,7 +1,7 @@ module RSpec module Core module Version - STRING = '2.14.1' + STRING = '2.14.2' end end end diff --git a/spec/rspec/core/formatters/deprecation_formatter_spec.rb b/spec/rspec/core/formatters/deprecation_formatter_spec.rb index f67afea294..86c3dc9214 100644 --- a/spec/rspec/core/formatters/deprecation_formatter_spec.rb +++ b/spec/rspec/core/formatters/deprecation_formatter_spec.rb @@ -4,12 +4,29 @@ module RSpec::Core::Formatters describe DeprecationFormatter do + let(:deprecation_stream) { StringIO.new } + let(:summary_stream) { StringIO.new } + let(:formatter) { DeprecationFormatter.new deprecation_stream, summary_stream } - describe "#deprecation" do - let(:deprecation_stream) { StringIO.new } - let(:summary_stream) { StringIO.new } - let(:formatter) { DeprecationFormatter.new deprecation_stream, summary_stream } + def with_start_defined_on_kernel + return yield if ::Kernel.method_defined?(:start) + + begin + ::Kernel.module_eval { def start(*); raise "boom"; end } + yield + ensure + ::Kernel.module_eval { undef start } + end + end + it 'does not blow up when `Kernel` defines `start`' do + with_start_defined_on_kernel do + reporter = ::RSpec::Core::Reporter.new(formatter) + reporter.start(3) + end + end + + describe "#deprecation" do it "includes the method" do formatter.deprecation(:deprecated => "i_am_deprecated") deprecation_stream.rewind diff --git a/spec/rspec/core/reporter_spec.rb b/spec/rspec/core/reporter_spec.rb index 1bdac4fa93..218457e573 100644 --- a/spec/rspec/core/reporter_spec.rb +++ b/spec/rspec/core/reporter_spec.rb @@ -120,28 +120,6 @@ module RSpec::Core end end - describe 'when message implemented on kernel' do - def with_message_defined_on_kernel - return yield if ::Kernel.method_defined?(:start) - - begin - ::Kernel.module_eval { def start(*); raise "boom"; end } - yield - ensure - ::Kernel.module_eval { undef start } - end - end - - let(:formatter) { double("formatter") } - - it 'does not blow up when `Kernel` defines message instead of a formatter' do - with_message_defined_on_kernel do - reporter = ::RSpec::Core::Reporter.new(formatter) - reporter.start(3) - end - end - end - describe "timing" do it "uses RSpec::Core::Time as to not be affected by changes to time in examples" do formatter = double(:formatter)