Sha256: 92582e1aaa260b712ee2b9d103829ab44343dd6d11d9be212f412d3d2a05103f

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

require 'shenandoah/locator'

describe Shenandoah::DefaultLocator do
  include Shenandoah::Spec::Tmpfile

  describe "default attributes" do
    before do
      ENV['TMPDIR'] = nil
      @loc = Shenandoah::DefaultLocator.new
    end

    it "has main_path = lib" do
      @loc.main_path.should == "lib"
    end

    it "has spec_path = spec" do
      @loc.spec_path.should == "spec"
    end

    it "uses the TMPDIR env var for tmp" do
      ENV['TMPDIR'] = "/var/tmp"
      Shenandoah::DefaultLocator.new.tmp_path.should == "/var/tmp"
    end

    it "has tmp_path = tmp" do
      @loc.tmp_path.should == "tmp"
    end
  end

  describe "initializing from options" do
    it "uses an explicit main path" do
      Shenandoah::DefaultLocator.new(:main_path => 'main').main_path.should == 'main'
    end

    it "uses an explicit spec path" do
      Shenandoah::DefaultLocator.new(:spec_path => 'foo').spec_path.should == 'foo'
    end

    it "uses an explicit tmp path" do
      Shenandoah::DefaultLocator.new(:tmp_path => 'foo').tmp_path.should == 'foo'
    end
  end

  describe "finding specs" do
    before do
      @loc = Shenandoah::DefaultLocator.new :spec_path => "#{tmpdir}/spec"
    end

    it "finds specs directly in spec_path" do
      tmpfile "spec/common_spec.js"
      @loc.spec_files.should == ["#{tmpdir}/spec/common_spec.js"]
    end

    it "finds specs in subdirs" do
      tmpfile "spec/foo/bar_spec.js"
      @loc.spec_files.should == ["#{tmpdir}/spec/foo/bar_spec.js"]
    end

    it "only finds specs" do
      tmpfile "spec/quux.js"
      tmpfile "spec/foo/bar_spec.js"
      @loc.spec_files.should == ["#{tmpdir}/spec/foo/bar_spec.js"]
    end

    it "doesn't cache results" do
      tmpfile "spec/bar/etc_spec.js"
      @loc.should have(1).spec_files
      tmpfile "spec/bar/quux_spec.js"
      @loc.should have(2).spec_files
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rsutphin-shenandoah-0.1.0 spec/shenandoah/locator_spec.rb
shenandoah-0.1.0 spec/shenandoah/locator_spec.rb
shenandoah-0.0.0 spec/shenandoah/locator_spec.rb