may fix #119, file paths on windows

This commit is contained in:
John Bintz 2012-02-21 09:04:00 -05:00
parent c96cbd4aac
commit 2e2651d11a
2 changed files with 28 additions and 1 deletions

View File

@ -54,7 +54,11 @@ module Jasmine::Headless
end
def cache_file
@cache_file ||= File.expand_path(File.join(self.class.cache_dir, self.class.cache_type, file)) + '.js'
@cache_file ||= File.expand_path(relative_cache_file) + '.js'
end
def relative_cache_file
File.join(self.class.cache_dir, self.class.cache_type, file.gsub(Dir.pwd + '/', ''))
end
def fresh?

View File

@ -95,5 +95,28 @@ describe Jasmine::Headless::CacheableAction do
end
end
end
describe '#relative_cache_file' do
context 'file is an absolute windows file' do
let(:current_path) { 'C:/path' }
let(:filename) { "file.coffee" }
let(:windows_path) { File.join(current_path, filename) }
let(:cache_dir) { 'cache dir' }
let(:cache_type) { 'cache type' }
before do
cache_object.stubs(:file).returns(windows_path)
described_class.stubs(:cache_dir).returns(cache_dir)
described_class.stubs(:cache_type).returns(cache_type)
Dir.stubs(:pwd).returns(current_path)
end
subject { cache_object.relative_cache_file }
it { should == File.join(cache_dir, cache_type, filename) }
end
end
end