Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make debugger statements _just work_

- debugger statements work anywhere in the code, even parts that are
  outside RSpec's control (like before a describe declaration).
- deprecated --debug/-d command line option
  - it doesn't do anything any more
- warns if ruby-debug is not installed
- only downside is for people who like to leave debugger statements
  around in their code
  • Loading branch information...
commit 246683127a176e79a2bddf2a69b8b55ccde6aabb 1 parent 0b278b2
@dchelimsky dchelimsky authored
5 History.markdown
@@ -4,9 +4,14 @@
[full changelog](http://github.com/rspec/rspec-core/compare/v2.1.0...master)
+* Deprecations
+ * --debug/-d on command line is deprecated and now has no effect
+
* Enhancements
* Raise exception with helpful message when rspec-1 is loaded alongside
rspec-2 (Justin Ko)
+ * debugger statements _just work_ as long as ruby-debug is installed
+ * otherwise you get warned, but not fired
* Bug fixes
* Make sure --fail-fast makes it across drb
View
16 Upgrade.markdown
@@ -1,4 +1,16 @@
-# New features in rspec-core-2.1
+# rspec-core-2.2
+
+## Command line
+
+### --debug/-d is now deprecated
+
+This command line option is now has no effect (other than a deprecation
+warning). To use the debugger, just add a `debugger` statement anywhere in your
+code. As long as you have ruby-debug installed, it will just work. If you
+don't, then you'll get a friendly warning telling you what's going on, but
+execution will continue.
+
+# rspec-core-2.1
## Command line
@@ -61,7 +73,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`.
-# New features in rspec-core-2.0
+# rspec-core-2.0
### Runner
View
20 lib/rspec/core/configuration.rb
@@ -182,21 +182,11 @@ def requires=(paths)
end
def debug=(bool)
- 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
+ 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
end
def line_number=(line_number)
View
23 lib/rspec/core/extensions/kernel.rb
@@ -1,5 +1,22 @@
module Kernel
- 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)
+ 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
+ super
+ end
+ end
end
View
13 spec/rspec/core/configuration_spec.rb
@@ -531,20 +531,13 @@ def that_thing
end
end
- describe "#debug=true" do
- it "requires 'ruby-debug'" do
- config.should_receive(:require).with('ruby-debug')
+ describe "#debug=" do
+ it "is deprecated" do
+ RSpec.should_receive(:warn_deprecation)
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")
View
9 spec/rspec/core/kernel_extensions_spec.rb
@@ -1,9 +1,12 @@
require 'spec_helper'
describe "extensions" do
- describe "debugger" do
- it "is defined on Kernel" do
- Kernel.should respond_to(:debugger)
+ describe "#debugger" do
+ it "warns if ruby-debug is not installed" do
+ object = Object.new
+ object.should_receive(:warn).with(/debugger .* ignored/)
+ object.stub(:require) { raise LoadError }
+ object.method_missing(:debugger)
end
end
end

0 comments on commit 2466831

Please sign in to comment.
Something went wrong with that request. Please try again.