Sha256: 0b77aabc54f3d58cd167dd2ef431843e74cc76d724208e3166b42b346e91265b

Contents?: true

Size: 1.6 KB

Versions: 18

Compression:

Stored size: 1.6 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe LocalStorage do
  let(:valid_pac_file) do <<-EOS.strip_heredoc
                           function FindProxyForURL(url, host) {
                             return "DIRECT"
                           }
  EOS
  end

  context '#initialize' do
    it 'initializes storage' do
      file = double('File')
      allow(file).to receive(:name).and_return(:file1)
      
      repo = double('GitRepository')
      expect(repo).to receive(:[]).and_return(file)

      storage = LocalStorage.new(repo)
      file = storage.find('file1')
      expect(file.name).to eq(:file1)
    end

    context '#find' do
      it 'returns file if exists' do
        file = double('GitFile')
        allow(file).to receive(:name).and_return(:file1)

        repo = double('GitRepository')
        expect(repo).to receive(:[]).and_return(file)

        storage = LocalStorage.new(repo)
        file = storage.find('file1')
        expect(file.name).to eq(:file1)
      end

      it 'returns file for pac in subdir' do
        file = double('GitFile')
        allow(file).to receive(:name).and_return(:'dir::file1')

        repo = double('GitRepository')
        expect(repo).to receive(:[]).and_return(file)

        storage = LocalStorage.new(repo)
        file = storage.find('dir/file1')
        expect(file.name).to eq(:'dir::file1')
      end

      it 'returns null file if does not exist' do
        repo = double('GitRepository')
        expect(repo).to receive(:[]).and_return(nil)

        storage = LocalStorage.new(repo)
        expect(storage.find('unexist')).to be_nil
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
local_pac-0.3.0 spec/local_storage_spec.rb
local_pac-0.2.3 spec/local_storage_spec.rb
local_pac-0.2.2 spec/local_storage_spec.rb
local_pac-0.2.1 spec/local_storage_spec.rb
local_pac-0.2.0 spec/local_storage_spec.rb
local_pac-0.1.13 spec/local_storage_spec.rb
local_pac-0.1.11 spec/local_storage_spec.rb
local_pac-0.1.10 spec/local_storage_spec.rb
local_pac-0.1.9 spec/local_storage_spec.rb
local_pac-0.1.8 spec/local_storage_spec.rb
local_pac-0.1.7 spec/local_storage_spec.rb
local_pac-0.1.6 spec/local_storage_spec.rb
local_pac-0.1.5 spec/local_storage_spec.rb
local_pac-0.1.4 spec/local_storage_spec.rb
local_pac-0.1.3 spec/local_storage_spec.rb
local_pac-0.1.2 spec/local_storage_spec.rb
local_pac-0.1.1 spec/local_storage_spec.rb
local_pac-0.1.0 spec/local_storage_spec.rb