From f4ba22a5abdee25e6ca77010a1afac47c47f23f3 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 7 Jul 2013 11:51:41 -0400 Subject: [PATCH 01/13] Run features without rubinius code compilation * This addresses sporadic failures --- features/support/rubinius.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 features/support/rubinius.rb diff --git a/features/support/rubinius.rb b/features/support/rubinius.rb new file mode 100644 index 0000000000..8524f51d08 --- /dev/null +++ b/features/support/rubinius.rb @@ -0,0 +1,2 @@ +# Required until https://github.com/rubinius/rubinius/issues/2430 is resolved +ENV['RBXOPT'] = "#{ENV["RBXOPT"]} -Xcompiler.no_rbc" From ed727ed47d7b6f1ebb6c1141f7dcc2cd3275ce46 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 7 Jul 2013 14:37:44 -0400 Subject: [PATCH 02/13] Disables certain scenarios on Rubinius * I cannot get Rubinius to raise a warning for some reason, even outside specs --- features/command_line/warnings_option.feature | 2 ++ features/support/rubinius.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/features/command_line/warnings_option.feature b/features/command_line/warnings_option.feature index d00199d96e..b359fe9547 100644 --- a/features/command_line/warnings_option.feature +++ b/features/command_line/warnings_option.feature @@ -2,6 +2,7 @@ Feature: run with warnings enabled You can use the `--warnings` option to run specs with warnings enabled + @unsupported-on-rbx Scenario: Given a file named "example_spec.rb" with: """ruby @@ -14,6 +15,7 @@ Feature: run with warnings enabled When I run `rspec --warnings example_spec.rb` Then the output should contain "warning" + @unsupported-on-rbx Scenario: Given a file named "example_spec.rb" with: """ruby diff --git a/features/support/rubinius.rb b/features/support/rubinius.rb index 8524f51d08..3907962528 100644 --- a/features/support/rubinius.rb +++ b/features/support/rubinius.rb @@ -1,2 +1,6 @@ # Required until https://github.com/rubinius/rubinius/issues/2430 is resolved ENV['RBXOPT'] = "#{ENV["RBXOPT"]} -Xcompiler.no_rbc" + +Around "@unsupported-on-rbx" do |scenario, block| + block.call unless defined?(Rubinius) +end From e5c05f1c89055a386c98698cfda4cfc7153a3e75 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 7 Jul 2013 16:44:37 -0400 Subject: [PATCH 03/13] The backtrace appears to be shifted by 1 in Rubinius --- lib/rspec/core/shared_example_group/collection.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rspec/core/shared_example_group/collection.rb b/lib/rspec/core/shared_example_group/collection.rb index 741f59b840..44a1a8172b 100644 --- a/lib/rspec/core/shared_example_group/collection.rb +++ b/lib/rspec/core/shared_example_group/collection.rb @@ -27,10 +27,11 @@ def fetch_anyway(key) def warn_deprecation_and_fetch_anyway(key) if (example = fetch_anyway key) + backtrace_line = defined?(Rubinius) ? caller(0)[7] : caller(0)[8] RSpec.warn_deprecation <<-WARNING.gsub(/^ /, '') Accessing shared_examples defined across contexts is deprecated. Please declare shared_examples within a shared context, or at the top level. - This message was generated at: #{caller(0)[8]} + This message was generated at: #{backtrace_line} WARNING example end From aef1c80af497fd581a3578fed5e17787312a9a80 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 7 Jul 2013 16:50:45 -0400 Subject: [PATCH 04/13] rbx build is green; let us try to keep it that way --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4dff3f2bcc..98f9876118 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,3 @@ rvm: - rbx-18mode - rbx-19mode - 2.0.0 -matrix: - allow_failures: - - rvm: rbx-19mode - - rvm: rbx-18mode - From da78adae021803e32498e79c4d0861c716da29f2 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 7 Jul 2013 18:04:52 -0400 Subject: [PATCH 05/13] Finds the backtrace line in a more robust way --- lib/rspec/core/shared_example_group/collection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rspec/core/shared_example_group/collection.rb b/lib/rspec/core/shared_example_group/collection.rb index 44a1a8172b..6047598723 100644 --- a/lib/rspec/core/shared_example_group/collection.rb +++ b/lib/rspec/core/shared_example_group/collection.rb @@ -27,7 +27,7 @@ def fetch_anyway(key) def warn_deprecation_and_fetch_anyway(key) if (example = fetch_anyway key) - backtrace_line = defined?(Rubinius) ? caller(0)[7] : caller(0)[8] + backtrace_line = caller.find { |line| !line.include?('lib/rspec/core') } RSpec.warn_deprecation <<-WARNING.gsub(/^ /, '') Accessing shared_examples defined across contexts is deprecated. Please declare shared_examples within a shared context, or at the top level. From 8b7bb6af8ec845e443d4761681281cec498c5139 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 7 Jul 2013 20:42:12 -0400 Subject: [PATCH 06/13] Revert "rbx build is green; let us try to keep it that way" This reverts commit aef1c80af497fd581a3578fed5e17787312a9a80. --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 98f9876118..4dff3f2bcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,8 @@ rvm: - rbx-18mode - rbx-19mode - 2.0.0 +matrix: + allow_failures: + - rvm: rbx-19mode + - rvm: rbx-18mode + From 7dc3658b7a4f4b6a117f3c109ca013910987d988 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 9 Jul 2013 11:33:59 +1000 Subject: [PATCH 07/13] work around ruby-debug injecting #start into Kernel on JRuby --- lib/rspec/core/formatters/deprecation_formatter.rb | 4 ++++ spec/rspec/core/formatters/deprecation_formatter_spec.rb | 7 +++++++ 2 files changed, 11 insertions(+) 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/spec/rspec/core/formatters/deprecation_formatter_spec.rb b/spec/rspec/core/formatters/deprecation_formatter_spec.rb index 25bad09efb..9c3ba196ba 100644 --- a/spec/rspec/core/formatters/deprecation_formatter_spec.rb +++ b/spec/rspec/core/formatters/deprecation_formatter_spec.rb @@ -4,6 +4,13 @@ module RSpec::Core::Formatters describe DeprecationFormatter do + describe '#start' do + it 'prevents Kernel#start from being called on jruby' do + formatter = DeprecationFormatter.new StringIO.new, StringIO.new + expect(formatter.start).to eq nil + end + end + describe "#deprecation" do let(:deprecation_stream) { StringIO.new } let(:summary_stream) { StringIO.new } From d2486d10e3cf95ccc76c746010adb86a2b1c78bb Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 9 Jul 2013 12:03:52 +1000 Subject: [PATCH 08/13] changelog --- Changelog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Changelog.md b/Changelog.md index 6c52626c40..5d06b371be 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,9 @@ +#dev + +Bug fix +* Implement `#start` on the Deprecation Formatter to prevent collision with + `ruby-debug` on JRuby (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) From c4f010cc3651dedf218467bc7ee7816cc9560f51 Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Mon, 8 Jul 2013 21:00:43 -0700 Subject: [PATCH 09/13] Fixup the spec to work regardless of which solution we wind up with. The original spec was focused on the exact fix that was originally put in place, but we may wind up changing to an alternate fix that would not be tested by the spec as it was. --- .../formatters/deprecation_formatter_spec.rb | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/spec/rspec/core/formatters/deprecation_formatter_spec.rb b/spec/rspec/core/formatters/deprecation_formatter_spec.rb index 9c3ba196ba..86c3dc9214 100644 --- a/spec/rspec/core/formatters/deprecation_formatter_spec.rb +++ b/spec/rspec/core/formatters/deprecation_formatter_spec.rb @@ -4,18 +4,29 @@ module RSpec::Core::Formatters describe DeprecationFormatter do - describe '#start' do - it 'prevents Kernel#start from being called on jruby' do - formatter = DeprecationFormatter.new StringIO.new, StringIO.new - expect(formatter.start).to eq nil + 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 - describe "#deprecation" do - let(:deprecation_stream) { StringIO.new } - let(:summary_stream) { StringIO.new } - let(:formatter) { DeprecationFormatter.new deprecation_stream, summary_stream } + 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 From 505d1b60ec981fd016ea7a62e1a90f6b47657245 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 9 Jul 2013 14:34:08 +1000 Subject: [PATCH 10/13] restore original deprecation formatter --- .../core/formatters/deprecation_formatter.rb | 4 --- .../formatters/deprecation_formatter_spec.rb | 25 +++---------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/lib/rspec/core/formatters/deprecation_formatter.rb b/lib/rspec/core/formatters/deprecation_formatter.rb index b6583d441d..b19aa4c1fa 100644 --- a/lib/rspec/core/formatters/deprecation_formatter.rb +++ b/lib/rspec/core/formatters/deprecation_formatter.rb @@ -8,10 +8,6 @@ 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/spec/rspec/core/formatters/deprecation_formatter_spec.rb b/spec/rspec/core/formatters/deprecation_formatter_spec.rb index 86c3dc9214..f67afea294 100644 --- a/spec/rspec/core/formatters/deprecation_formatter_spec.rb +++ b/spec/rspec/core/formatters/deprecation_formatter_spec.rb @@ -4,29 +4,12 @@ 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 } - - 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 + let(:deprecation_stream) { StringIO.new } + let(:summary_stream) { StringIO.new } + let(:formatter) { DeprecationFormatter.new deprecation_stream, summary_stream } + it "includes the method" do formatter.deprecation(:deprecated => "i_am_deprecated") deprecation_stream.rewind From b5b27142359ddc466738246216d1941a9a255994 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 9 Jul 2013 14:35:26 +1000 Subject: [PATCH 11/13] check that formatter understands notification --- lib/rspec/core/reporter.rb | 16 +++++++++++++++- spec/rspec/core/reporter_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/rspec/core/reporter.rb b/lib/rspec/core/reporter.rb index 5e03d9dd2b..a7eca82d85 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 listener.respond_to?(notification) + @listeners[notification.to_sym] << listener if understands(listener, notification) end true end @@ -127,5 +127,19 @@ def notify(event, *args, &block) formatter.send(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/spec/rspec/core/reporter_spec.rb b/spec/rspec/core/reporter_spec.rb index fd14f8349e..ba102c92bd 100644 --- a/spec/rspec/core/reporter_spec.rb +++ b/spec/rspec/core/reporter_spec.rb @@ -120,6 +120,28 @@ 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).as_null_object From 286b8f91af6cef92d0222baf0a88400b190d0880 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 9 Jul 2013 14:35:59 +1000 Subject: [PATCH 12/13] remove (now unecessary) as_null_object calls as they interfer with the check for listener understanding --- spec/rspec/core/reporter_spec.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spec/rspec/core/reporter_spec.rb b/spec/rspec/core/reporter_spec.rb index ba102c92bd..1bdac4fa93 100644 --- a/spec/rspec/core/reporter_spec.rb +++ b/spec/rspec/core/reporter_spec.rb @@ -9,7 +9,7 @@ module RSpec::Core %w[start_dump dump_pending dump_failures dump_summary close].each do |message| it "sends #{message} to the formatter(s) that respond to message" do - formatter.as_null_object.should_receive(message) + formatter.should_receive(message) reporter.abort(nil) end @@ -34,7 +34,7 @@ module RSpec::Core it "passes example_group_started and example_group_finished messages to that formatter in that order" do order = [] - formatter = double("formatter").as_null_object + formatter = double("formatter") formatter.stub(:example_group_started) { |group| order << "Started: #{group.description}" } formatter.stub(:example_group_finished) { |group| order << "Finished: #{group.description}" } @@ -61,7 +61,7 @@ module RSpec::Core context "given an example group with no examples" do it "does not pass example_group_started or example_group_finished to formatter" do - formatter = double("formatter").as_null_object + formatter = double("formatter") formatter.should_not_receive(:example_group_started) formatter.should_not_receive(:example_group_finished) @@ -144,16 +144,17 @@ def with_message_defined_on_kernel describe "timing" do it "uses RSpec::Core::Time as to not be affected by changes to time in examples" do - formatter = double(:formatter).as_null_object - reporter = Reporter.new formatter - reporter.start 1 - Time.stub(:now => ::Time.utc(2012, 10, 1)) - + formatter = double(:formatter) duration = nil formatter.stub(:dump_summary) do |dur, _, _, _| duration = dur end + reporter = Reporter.new formatter + reporter.start 1 + Time.stub(:now => ::Time.utc(2012, 10, 1)) + + reporter.finish 1234 expect(duration).to be < 0.2 end From a6be051c30a00c2a21a6b16cb51ef7b93cd9ce53 Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Mon, 8 Jul 2013 21:59:55 -0700 Subject: [PATCH 13/13] 2.14.1 release. --- Changelog.md | 8 +++++--- lib/rspec/core/version.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index 5d06b371be..baa611712f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,8 @@ -#dev +### 2.14.1 / 2013-07-08 +[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.0...v2.14.1) + +Bug fixes -Bug fix * Implement `#start` on the Deprecation Formatter to prevent collision with `ruby-debug` on JRuby (Alex Portnov, Jon Rowe) @@ -12,7 +14,7 @@ Enhancements * Apply focus to examples defined with `fit` (equivalent of `it "description", focus: true`) (Michael de Silva) -Bug fix +Bug fixes * Ensure methods defined by `let` take precedence over others when there is a name collision (e.g. from an included module). diff --git a/lib/rspec/core/version.rb b/lib/rspec/core/version.rb index 8c8b8ff904..a6733a01e3 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.0' + STRING = '2.14.1' end end end