Sha256: bfa02acb1817c6d8bb8c14d2530cb244007c8463d16f2629a5f73c54bc9ab94d
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' describe MultiSync::LocalResource, fakefs: true do before do FileUtils.mkdir_p('tmp/local-resource') File.open('tmp/local-resource/foo.txt', 'w') do |f| f.write('foo') end end describe :local do context :valid do it 'should return correct file details' do resource = MultiSync::LocalResource.new( path_with_root: Pathname.new('tmp/local-resource/foo.txt'), path_without_root: Pathname.new('foo.txt') ) expect(resource.body).to eq 'foo' expect(resource.content_length).to eq 3 expect(resource.content_type).to eq 'text/plain' expect(resource.mtime).to be_within(1).of(Time.now) expect(resource.etag).to eq 'acbd18db4cc2f85cedef654fccc4a4d8' end end context :known do it 'should return correct file details (with overwritten info)' do resource = MultiSync::LocalResource.new( path_with_root: Pathname.new('tmp/local-resource/foo.txt'), path_without_root: Pathname.new('foo.txt'), content_length: 42, mtime: Time.now - 1, etag: 'etag' ) expect(resource.body).to eq 'foo' expect(resource.content_length).to eq 42 expect(resource.content_type).to eq 'text/plain' expect(resource.mtime).to eq Time.now - 1 expect(resource.etag).to eq 'etag' end end context :unknown do it 'should return default file details' do resource = MultiSync::LocalResource.new( path_with_root: Pathname.new('tmp/local-resource/missing.txt'), path_without_root: Pathname.new('missing.txt') ) expect(resource.body).to eq nil expect(resource.content_length).to eq 0 expect(resource.content_type).to eq 'text/plain' expect(resource.mtime).to eq nil expect(resource.etag).to eq nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
multi_sync-0.0.4 | spec/unit/multi_sync/resources/local_resource_spec.rb |
multi_sync-0.0.3 | spec/unit/multi_sync/resources/local_resource_spec.rb |