spec/lib/jsus/pool_spec.rb in jsus-0.1.4 vs spec/lib/jsus/pool_spec.rb in jsus-0.1.5
- old
+ new
@@ -32,12 +32,17 @@
subject.packages.map {|p| p.name }.should include("Mash", "Hash", "Class")
end
it "should add all the source files to pool" do
subject.should have_exactly(3).sources
- subject.sources.map {|s| s.provides }.flatten.should include("Mash/Mash", "Hash/Hash", "Class/Class")
+ subject.sources.map {|s| s.provides_names }.flatten.should include("Mash/Mash", "Hash/Hash", "Class/Class")
end
+
+ it "should keep track of extensions" do
+ pool = Jsus::Pool.new("spec/data/Extensions/app/javascripts")
+ pool.send(:extensions_map).keys.should include(Jsus::Tag["Core/Class"])
+ end
end
end
describe "#lookup" do
@@ -50,28 +55,60 @@
end
it "should return nil if nothing could be found" do
subject.lookup("Core/WTF").should be_nil
end
+
+ it "should allow tags" do
+ subject.lookup(Jsus::Tag["Class/Class"]).should == sources[1]
+ end
end
describe "#lookup_direct_dependencies" do
before(:each) do
packages.each {|package| subject << package.source_files }
end
it "should return a container with direct dependencies" do
subject.lookup_direct_dependencies("Mash/Mash").should be_a(Jsus::Container)
subject.lookup_direct_dependencies("Mash/Mash").should == [sources[2]]
+ subject.lookup_direct_dependencies(Jsus::Tag["Mash/Mash"]).should be_a(Jsus::Container)
+ subject.lookup_direct_dependencies(Jsus::Tag["Mash/Mash"]).should == [sources[2]]
end
+
+ it "should return empty array if pool doesn't contain given source" do
+ subject.lookup_direct_dependencies("Lol/Wtf").should == []
+ subject.lookup_direct_dependencies(Jsus::Tag["Lol/Wtf"]).should == []
+ end
end
describe "#lookup_dependencies" do
before(:each) do
packages.each {|package| subject << package.source_files }
end
it "should return a container with files and dependencies" do
subject.lookup_dependencies("Mash/Mash").should == [sources[1], sources[2]]
+ subject.lookup_dependencies(Jsus::Tag["Mash/Mash"]).should == [sources[1], sources[2]]
+ end
+
+ it "should return empty array if pool doesn't contain given source" do
+ subject.lookup_dependencies("Lol/Wtf").should == []
+ subject.lookup_dependencies(Jsus::Tag["Caught/Mosh"]).should == []
+ end
+ end
+
+ describe "#lookup_extensions" do
+ let(:input_dir) { "spec/Data/Extensions/app/javascripts" }
+ subject { Jsus::Pool.new(input_dir) }
+
+ it "should return empty array if there's not a single extension for given tag" do
+ subject.lookup_extensions("Core/WTF").should be_empty
+ subject.lookup_extensions(Jsus::Tag["Core/WTF"]).should be_empty
+ end
+
+ it "should return an array with extensions if there are extensions for given tag" do
+ subject.lookup_extensions("Core/Class").should have_exactly(1).item
+ subject.lookup_extensions(Jsus::Tag["Core/Class"]).should have_exactly(1).item
end
end
end
\ No newline at end of file