Skip to content

Commit

Permalink
add specs for #pretty_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Somerville committed Dec 16, 2012
1 parent 537f981 commit 6f49bcd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/better_errors/stack_frame_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,29 @@ module BetterErrors

frame.gem_path.should == "(gem) whatever-1.2.3/lib/whatever.rb"
end

it "should prioritize gem path over application path" do
BetterErrors.stub!(:application_root).and_return("/abc/xyz")
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"
end
end

context "#pretty_path" do
it "should return #application_path for application paths" do
BetterErrors.stub!(:application_root).and_return("/abc/xyz")
frame = StackFrame.new("/abc/xyz/app/controllers/crap_controller.rb", 123, "index")
frame.pretty_path.should == frame.application_path
end

it "should return #gem_path for gem paths" do
Gem.stub!(:path).and_return(["/abc/xyz"])
frame = StackFrame.new("/abc/xyz/gems/whatever-1.2.3/lib/whatever.rb", 123, "foo")

frame.pretty_path.should == frame.gem_path
end
end

it "should special case SyntaxErrors" do
Expand Down

0 comments on commit 6f49bcd

Please sign in to comment.