Permalink
Browse files

clean const_missing backtraces

  • Loading branch information...
1 parent 096e586 commit dff001d9b58535721eafba54090b9f20be3db85a @dchelimsky dchelimsky committed Mar 29, 2011
Showing with 37 additions and 2 deletions.
  1. +16 −2 lib/rspec/core/backward_compatibility.rb
  2. +21 −0 spec/rspec/core/deprecations_spec.rb
@@ -17,7 +17,14 @@ def const_missing(name)
WARNING
RSpec
else
- super(name)
+ begin
+ super
+ rescue Exception => e
+ while e.backtrace.first =~ /lib\/rspec\/(.*)\/backward_compatibility\.rb/
+ e.backtrace.shift
+ end
+ raise e
+ end
end
end
end
@@ -38,7 +45,14 @@ def self.const_missing(name)
require 'rspec/core/rake_task'
RSpec::Core::RakeTask
else
- super(name)
+ begin
+ super
+ rescue Exception => e
+ while e.backtrace.first =~ /(lib\/rspec\/(.*)\/backward_compatibility\.rb|lib\/rake\.rb)/
+ e.backtrace.shift
+ end
+ raise e
+ end
end
end
@@ -11,6 +11,16 @@
RSpec.stub(:warn_deprecation)
Spec.should == RSpec
end
+
+ it "doesn't include backward compatibility in const_missing backtrace" do
+ RSpec.stub(:warn_deprecation)
+ exception = nil
+ begin
+ ConstantThatDoesNotExist
+ rescue Exception => exception
+ end
+ exception.backtrace[0].should =~ Regexp.compile("#{__FILE__}:#{__LINE__ - 3}")
+ end
end
describe RSpec::Core::ExampleGroup do
@@ -41,5 +51,16 @@
RSpec.should_receive(:deprecate)
Spec::Rake::SpecTask
end
+
+ it "doesn't include backward compatibility in const_missing backtrace" do
+ RSpec.stub(:warn_deprecation)
+ exception = nil
+ begin
+ Spec::Rake::ConstantThatDoesNotExist
+ rescue Exception => exception
+ end
+ exception.backtrace[0].should =~ Regexp.compile("#{__FILE__}:#{__LINE__ - 3}")
+ end
end
+
end

0 comments on commit dff001d

Please sign in to comment.