Sha256: 74134e76f970ae2b7d2bcb7f79bb3158f71d13fd2f2a05d990fe64bd485f3c05

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

require "spec_helper"

describe Soloist::Spotlight do
  let(:tempdir) { Dir.mktmpdir }
  let(:shallow_path) { File.expand_path("beans/roger", tempdir) }
  let(:spotlight) { Soloist::Spotlight.new(shallow_path) }

  before { FileUtils.mkdir_p(shallow_path) }

  describe "#find" do
    context "with non-existent files" do
      it "raises an error with three files" do
        expect do
          begin
            spotlight.find!("larry", "moe", "curly")
          rescue Soloist::NotFound => e
            e.message.should == "Could not find larry, moe or curly"
            raise
          end
        end.to raise_error(Soloist::NotFound)
      end

      it "raises an error with two files" do
        expect do
          begin
            spotlight.find!("lulz", "wut")
          rescue Soloist::NotFound => e
            e.message.should == "Could not find lulz or wut"
            raise
          end
        end.to raise_error(Soloist::NotFound)
      end

      it "raises an error with one file" do
        expect do
          begin
            spotlight.find!("whatever.dude")
          rescue Soloist::NotFound => e
            e.message.should == "Could not find whatever.dude"
            raise
          end
        end.to raise_error(Soloist::NotFound)
      end
    end

    context "when the file exists" do
      let(:file_path) { File.expand_path("soloistrc", shallow_path) }

      before { FileUtils.touch(file_path) }

      it "finds a soloistrc in the current directory" do
        spotlight.find("soloistrc").to_s.should == tempdir + "/beans/roger/soloistrc"
      end

      context "inside a deeper directory" do
        let(:deep_path) { File.expand_path("meat/hi", shallow_path) }
        let(:spotlight) { Soloist::Spotlight.new(deep_path) }

        before { FileUtils.mkdir_p(deep_path) }

        it "finds a soloistrc upwards" do
          spotlight.find("soloistrc").to_s.should == file_path
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
soloist-1.0.0.pre spec/lib/soloist/spotlight_spec.rb