Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clean const_missing backtraces

  • Loading branch information...
commit dff001d9b58535721eafba54090b9f20be3db85a 1 parent 096e586
@dchelimsky dchelimsky authored
View
18 lib/rspec/core/backward_compatibility.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
View
21 spec/rspec/core/deprecations_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.