diff --git a/Changelog.md b/Changelog.md index 6c52626c40..baa611712f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,11 @@ +### 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) + ### 2.14.0 / 2013-07-06 [full changelog](http://github.com/rspec/rspec-core/compare/v2.14.0.rc1...v2.14.0) @@ -6,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/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 new file mode 100644 index 0000000000..3907962528 --- /dev/null +++ b/features/support/rubinius.rb @@ -0,0 +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 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/lib/rspec/core/shared_example_group/collection.rb b/lib/rspec/core/shared_example_group/collection.rb index 741f59b840..6047598723 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 = 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. - This message was generated at: #{caller(0)[8]} + This message was generated at: #{backtrace_line} WARNING example end 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 diff --git a/spec/rspec/core/formatters/deprecation_formatter_spec.rb b/spec/rspec/core/formatters/deprecation_formatter_spec.rb index 25bad09efb..f67afea294 100644 --- a/spec/rspec/core/formatters/deprecation_formatter_spec.rb +++ b/spec/rspec/core/formatters/deprecation_formatter_spec.rb @@ -4,6 +4,7 @@ module RSpec::Core::Formatters describe DeprecationFormatter do + describe "#deprecation" do let(:deprecation_stream) { StringIO.new } let(:summary_stream) { StringIO.new } diff --git a/spec/rspec/core/reporter_spec.rb b/spec/rspec/core/reporter_spec.rb index fd14f8349e..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) @@ -120,18 +120,41 @@ 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 - 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