Fix bug where we ignored type passed into Pry::Code.from_file

This commit is contained in:
Ryan Fitzgerald 2012-08-05 02:01:17 -07:00
parent d242a70444
commit 03dc165ebf
2 changed files with 7 additions and 1 deletions

View File

@ -41,7 +41,7 @@ class Pry
else
if File.readable?(fn)
f = File.open(fn, 'r')
code_type = type_from_filename(fn)
code_type ||= type_from_filename(fn)
else
raise MethodSource::SourceNotFoundError, "Cannot open #{fn.inspect} for reading."
end

View File

@ -23,6 +23,12 @@ describe Pry::Code do
end
end
should 'use the provided extension' do
temp_file('.c') do |f|
Pry::Code.from_file(f.path, :ruby).code_type.should == :ruby
end
end
should 'raise an error if the file doesn\'t exist' do
proc do
Pry::Code.from_file('/knalkjsdnalsd/alkjdlkq')