Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 03dc165ebf17547e1b2351826bd9e1a6dd93c9f5 1 parent d242a70
@rf- rf- authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  lib/pry/code.rb
  2. +6 −0 test/test_code.rb
View
2  lib/pry/code.rb
@@ -41,7 +41,7 @@ def from_file(fn, code_type = nil)
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
6 test/test_code.rb
@@ -23,6 +23,12 @@
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')
Please sign in to comment.
Something went wrong with that request. Please try again.