From 03dc165ebf17547e1b2351826bd9e1a6dd93c9f5 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Sun, 5 Aug 2012 02:01:17 -0700 Subject: [PATCH] Fix bug where we ignored type passed into Pry::Code.from_file --- lib/pry/code.rb | 2 +- test/test_code.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pry/code.rb b/lib/pry/code.rb index 82de80bf..aeaa8803 100644 --- a/lib/pry/code.rb +++ b/lib/pry/code.rb @@ -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 diff --git a/test/test_code.rb b/test/test_code.rb index e9e4cfbb..51d3f145 100644 --- a/test/test_code.rb +++ b/test/test_code.rb @@ -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')