Skip to content

Commit

Permalink
Revert "Make debugger statements _just work_"
Browse files Browse the repository at this point in the history
- restore the --debugger/-d option
- this created a situation in which debugger did not work at all with
  rails, so need to figure out a different solution

This reverts commit 2466831.
  • Loading branch information
dchelimsky committed Nov 29, 2010
1 parent 393626f commit 2eb3c72
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Upgrade.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ JRuby installation to a newer release that allows the example to pass, RSpec
will report it as a failure (`Expected pending '...' to fail. No Error was raised.`),
so that know that you can remove the call to `pending`.

# rspec-core-2.0
# New features in rspec-core-2.0

### Runner

Expand Down
20 changes: 15 additions & 5 deletions lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,21 @@ def requires=(paths)
end

def debug=(bool)
RSpec.warn_deprecation <<-WARNING
The debug option (config.debug = true or --debug/-d on the command line)
is deprecated and no longer has any effect. This message will be removed
from future versions of RSpec.
WARNING
return unless bool
begin
require 'ruby-debug'
rescue LoadError
raise <<-EOM
#{'*'*50}
You must install ruby-debug to run rspec with the --debug option.
If you have ruby-debug installed as a ruby gem, then you need to either
require 'rubygems' or configure the RUBYOPT environment variable with
the value 'rubygems'.
#{'*'*50}
EOM
end
end

def line_number=(line_number)
Expand Down
28 changes: 3 additions & 25 deletions lib/rspec/core/extensions/kernel.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
module Kernel

private

alias_method :method_missing_without_debugger, :method_missing

def method_missing(m, *a)
if m.to_s == 'debugger'
begin
require 'ruby-debug'
debugger
rescue LoadError => e
warn <<-EOM
#{'*'*50}
The debugger statement on the following line was ignored:
#{caller(0).detect {|l| l !~ /method_missing/}}
To use the debugger statement, you must install ruby-debug.
#{'*'*50}
EOM
end
else
method_missing_without_debugger(m, *a)
end
end
def debugger(*args)
RSpec.configuration.error_stream.puts "debugger statement ignored, use -d or --debug option to enable debugging\n#{caller(0)[1]}"
end unless respond_to?(:debugger)
end
13 changes: 10 additions & 3 deletions spec/rspec/core/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,20 @@ def that_thing
end
end

describe "#debug=" do
it "is deprecated" do
RSpec.should_receive(:warn_deprecation)
describe "#debug=true" do
it "requires 'ruby-debug'" do
config.should_receive(:require).with('ruby-debug')
config.debug = true
end
end

describe "#debug=false" do
it "does not require 'ruby-debug'" do
config.should_not_receive(:require).with('ruby-debug')
config.debug = false
end
end

describe "#output=" do
it "sets the output" do
output = mock("output")
Expand Down
9 changes: 3 additions & 6 deletions spec/rspec/core/kernel_extensions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
require 'spec_helper'

describe "extensions" do
describe "#debugger" do
it "warns if ruby-debug is not installed" do
object = Object.new
object.should_receive(:warn).with(/debugger .* ignored:\n.* ruby-debug/m)
object.stub(:require) { raise LoadError }
object.__send__ :method_missing, :debugger
describe "debugger" do
it "is defined on Kernel" do
Kernel.should respond_to(:debugger)
end
end
end

0 comments on commit 2eb3c72

Please sign in to comment.