Sha256: 4c462bd3b3b840661ee5396a0939503ee9cb2dbffc0d2f34d556d6061aff35e8

Contents?: true

Size: 1.79 KB

Versions: 13

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe Konacha::Spec do
  describe "#asset_name" do
    it "is the asset_name of the path" do
      described_class.new("array_spec.js").asset_name.should == "array_spec"
      described_class.new("array_spec.coffee").asset_name.should == "array_spec"
    end

    it "ignores multiple extensions" do
      described_class.new("array_spec.js.coffee").asset_name.should == "array_spec"
    end

    it "includes relative path" do
      described_class.new("subdirectory/array_spec.js").asset_name.should == "subdirectory/array_spec"
    end
  end

  describe "#url" do
    it "returns a URL path" do
      described_class.new("array_spec.js").url.should == "/array_spec"
    end
  end

  describe ".all" do
    it "returns an array of specs" do
      Konacha.should_receive(:spec_paths) { ["a_spec.js", "b_spec.js"] }
      all = described_class.all
      all.length.should == 2
    end
  end

  describe ".find" do
    it "returns all Specs if given an empty path" do
      all = ["a_spec.js", "b_spec.js"]
      Konacha.should_receive(:spec_paths) { all }
      described_class.find("").map(&:path).should == all
    end

    it "returns an array containing the Spec with the given asset_name" do
      all = ["a_spec.js", "b_spec.js"]
      Konacha.should_receive(:spec_paths) { all }
      described_class.find("b_spec").map(&:path).should == [all[1]]
    end

    it "returns Specs that are children of the given path" do
      all = ["a/a_spec_1.js", "a/a_spec_2.js", "b/b_spec.js"]
      Konacha.should_receive(:spec_paths) { all }
      described_class.find("a").map(&:path).should == all[0..1]
    end

    it "raises NotFound if no Specs match" do
      Konacha.should_receive(:spec_paths) { [] }
      expect { described_class.find("b_spec") }.to raise_error(Konacha::Spec::NotFound)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
konacha-1.2.4 spec/models/spec_spec.rb
konacha-1.2.3 spec/models/spec_spec.rb
konacha-1.2.2 spec/models/spec_spec.rb
konacha-1.2.1 spec/models/spec_spec.rb
konacha-1.2.0 spec/models/spec_spec.rb
konacha-1.1.3 spec/models/spec_spec.rb
konacha-1.1.2 spec/models/spec_spec.rb
konacha-1.1.1 spec/models/spec_spec.rb
konacha-1.1.0 spec/models/spec_spec.rb
konacha-1.0.0 spec/models/spec_spec.rb
konacha-1.0.0.rc1 spec/models/spec_spec.rb
konacha-0.10.0 spec/models/spec_spec.rb
konacha-0.9.1 spec/models/spec_spec.rb