diff --git a/lib/better_errors/stack_frame.rb b/lib/better_errors/stack_frame.rb index abc9b6d8..d9e14926 100644 --- a/lib/better_errors/stack_frame.rb +++ b/lib/better_errors/stack_frame.rb @@ -50,7 +50,7 @@ def gem? def gem_path Gem.path.each do |path| if filename.index(path) == 0 - return filename.gsub("#{path}/gems/", "(gem) ") + return filename.gsub(%r{#{path}/gems/([^/]+)-([\w.]+)/}, '\1 (\2) ') end end end diff --git a/spec/better_errors/stack_frame_spec.rb b/spec/better_errors/stack_frame_spec.rb index be47e020..b0e9e8a2 100644 --- a/spec/better_errors/stack_frame_spec.rb +++ b/spec/better_errors/stack_frame_spec.rb @@ -54,7 +54,7 @@ module BetterErrors Gem.stub!(:path).and_return(["/abc/xyz"]) frame = StackFrame.new("/abc/xyz/gems/whatever-1.2.3/lib/whatever.rb", 123, "foo") - frame.gem_path.should == "(gem) whatever-1.2.3/lib/whatever.rb" + frame.gem_path.should == "whatever (1.2.3) lib/whatever.rb" end it "should prioritize gem path over application path" do @@ -62,7 +62,7 @@ module BetterErrors Gem.stub!(:path).and_return(["/abc/xyz/vendor"]) frame = StackFrame.new("/abc/xyz/vendor/gems/whatever-1.2.3/lib/whatever.rb", 123, "foo") - frame.gem_path.should == "(gem) whatever-1.2.3/lib/whatever.rb" + frame.gem_path.should == "whatever (1.2.3) lib/whatever.rb" end end