Skip to content

Commit

Permalink
Allow sandbox cache_file names to have path separators.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Feb 25, 2010
1 parent 4f7f9ec commit fdae33d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/vcr/sandbox.rb
Expand Up @@ -29,7 +29,7 @@ def store_recorded_response!(recorded_response)
end

def cache_file
File.join(VCR::Config.cache_dir, "#{name.to_s.gsub(/[^\w\-]+/, '_')}.yml") if VCR::Config.cache_dir
File.join(VCR::Config.cache_dir, "#{name.to_s.gsub(/[^\w\-\/]+/, '_')}.yml") if VCR::Config.cache_dir
end

def self.raise_error_unless_valid_record_mode(record_mode)
Expand Down
7 changes: 6 additions & 1 deletion spec/sandbox_spec.rb
Expand Up @@ -14,10 +14,15 @@
end

it 'should strip out disallowed characters so that it is a valid file name with no spaces' do
sandbox = VCR::Sandbox.new("\nthis \t! / is-the_13212_file name")
sandbox = VCR::Sandbox.new("\nthis \t! is-the_13212_file name")
sandbox.cache_file.should =~ /#{Regexp.escape('_this_is-the_13212_file_name.yml')}$/
end

it 'should keep any path separators' do
sandbox = VCR::Sandbox.new("dir/file_name")
sandbox.cache_file.should =~ /#{Regexp.escape('dir/file_name.yml')}$/
end

it 'should return nil if the cache_dir is not set' do
VCR::Config.cache_dir = nil
sandbox = VCR::Sandbox.new('the_cache_file')
Expand Down

0 comments on commit fdae33d

Please sign in to comment.