Sha256: 7c78f8b0be88500d78b6871f48e8220e59982649961d2336a3e79ef0709ad84e

Contents?: true

Size: 1.67 KB

Versions: 42

Compression:

Stored size: 1.67 KB

Contents

# encoding: utf-8
# author: Dominik Richter
# author: Christoph Hartmann

require 'helper'

describe Fetchers::Local do
  let(:fetcher) { Fetchers::Local }

  it 'registers with the fetchers registry' do
    reg = Inspec::Fetcher.registry
    _(reg['local']).must_equal fetcher
  end

  describe 'applied to this file' do
    let(:res) { fetcher.resolve(__FILE__) }

    it 'must be resolved' do
      _(res).must_be_kind_of fetcher
    end

    it 'must only contain this file' do
      _(res.files).must_equal [__FILE__]
    end

    it 'must not read if the file doesnt exist' do
      _(res.read('file-does-not-exist')).must_be_nil
    end

    it 'must not read files not covered' do
      not_covered = File.expand_path('../tar_test.rb', __FILE__)
      _(File.file?(not_covered)).must_equal true
      _(res.read(not_covered)).must_be_nil
    end

    it 'must read the contents of the file' do
      _(res.read(__FILE__)).must_equal File.read(__FILE__)
    end
  end

  describe 'applied to this folder' do
    let(:path) { File.dirname(__FILE__) }
    let(:res) { fetcher.resolve(path) }

    it 'must be resolved' do
      _(res).must_be_kind_of fetcher
    end

    it 'must contain all files' do
      _(res.files).must_include __FILE__
    end

    it 'must not read if the file doesnt exist' do
      _(res.read('file-not-in-folder')).must_be_nil
    end

    it 'must not read files not covered' do
      not_covered = File.expand_path('../../../helper.rb', __FILE__)
      _(File.file?(not_covered)).must_equal true
      _(res.read(not_covered)).must_be_nil
    end

    it 'must read the contents of the file' do
      _(res.read(__FILE__)).must_equal File.read(__FILE__)
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
inspec-0.30.0 test/unit/fetchers/local_test.rb
inspec-0.29.0 test/unit/fetchers/local_test.rb
inspec-0.28.1 test/unit/fetchers/local_test.rb
inspec-0.28.0 test/unit/fetchers/local_test.rb
inspec-0.27.1 test/unit/fetchers/local_test.rb
inspec-0.27.0 test/unit/fetchers/local_test.rb
inspec-0.26.0 test/unit/fetchers/local_test.rb
inspec-0.25.0 test/unit/fetchers/local_test.rb
inspec-0.24.0 test/unit/fetchers/local_test.rb
inspec-0.23 test/unit/fetchers/local_test.rb
inspec-0.22.1 test/unit/fetchers/local_test.rb
inspec-0.22.0 test/unit/fetchers/local_test.rb
inspec-0.21.6 test/unit/fetchers/local_test.rb
inspec-0.21.5 test/unit/fetchers/local_test.rb
inspec-0.21.4 test/unit/fetchers/local_test.rb
inspec-0.21.3 test/unit/fetchers/local_test.rb
inspec-0.21.2 test/unit/fetchers/local_test.rb
inspec-0.21.1 test/unit/fetchers/local_test.rb
inspec-0.21.0 test/unit/fetchers/local_test.rb
inspec-0.20.1 test/unit/fetchers/local_test.rb