Sha256: ea18213eb8c0c1eb1b68c8d06a1bf79fd6a314f548bb0b490af131d9e55c12e9

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

require "spec_helper"

require "config_hound/resource"
require "uri"

describe ConfigHound::Resource do

  let(:resource) { described_class[path] }

  context "with a URI" do

    let(:uri) { URI("http://example.com/some_uri") }
    let(:path) { uri }

    it "retains the URI" do
      expect(resource.to_s).to eq(uri.to_s)
    end

  end

  context "with a fully-qualified path" do

    let(:path) { "/path/to/file" }

    it "assumes it's a file" do
      expect(resource.to_s).to eq("file:/path/to/file")
    end

    describe "#resolve" do

      context "with a relative path" do
        it "resolves relatively" do
          other_resource = resource.resolve("other_file")
          expect(other_resource).to be_a(ConfigHound::Resource)
          expect(other_resource.to_s).to eq("file:/path/to/other_file")
        end
      end

      context "with an absolute file path" do
        it "resolves relatively" do
          other_resource = resource.resolve("/different/path")
          expect(other_resource.to_s).to eq("file:/different/path")
        end
      end

      context "with a fully-qualified URI" do
        it "uses the URI provided" do
          other_resource = resource.resolve("http://foo/bar")
          expect(other_resource.to_s).to eq("http://foo/bar")
        end
      end

    end

  end

  context "with a relative path" do

    let(:path) { "config.yml" }

    it "assumes it's a file relative to $CWD" do
      expect(resource.to_s).to eq("file:#{Dir.pwd}/config.yml")
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
config_hound-1.4.2 spec/config_hound/resource_spec.rb
config_hound-1.4.1 spec/config_hound/resource_spec.rb
config_hound-1.4.0 spec/config_hound/resource_spec.rb
config_hound-1.3.2 spec/config_hound/resource_spec.rb
config_hound-1.3.0 spec/config_hound/resource_spec.rb
config_hound-1.2.1 spec/config_hound/resource_spec.rb
config_hound-1.2.0 spec/config_hound/resource_spec.rb