Sha256: 2b9e4bf1382d7385e83bb5c6bd914c3fe952d7095cb5f4788808c0b34e6b18a0
Contents?: true
Size: 1.91 KB
Versions: 51
Compression:
Stored size: 1.91 KB
Contents
require File.join(File.dirname(__FILE__), "..", "spec_helper") class Redcar::Project describe DirMirror do before do @dirname = "project_spec_testdir" @files = {"Carnegie" => "steel", "Rockefeller" => "oil", "subdir" => { "Ford" => "cars" }} write_dir_contents(@dirname, @files) @mirror = DirMirror.new(File.expand_path(@dirname)) end describe "for a directory" do it "tells you the directory exists" do @mirror.exists?.should be_true end it "tells you it has changed" do @mirror.changed?.should be_true end describe "top level contents" do it "the nodes are the contents of the directory" do top_nodes = @mirror.top top_nodes.length.should == 3 top_nodes.map {|n| n.text}.should == %w(subdir Carnegie Rockefeller) end it "files are leaf nodes" do top_nodes = @mirror.top top_nodes.detect {|n| n.text == "Carnegie"}.leaf?.should be_true top_nodes.detect {|n| n.text == "Rockefeller"}.leaf?.should be_true end it "subdirectories are not leaf nodes" do top_nodes = @mirror.top top_nodes.detect {|n| n.text == "subdir"}.leaf?.should be_false end it "isn't changed after you have got the top nodes" do @mirror.top @mirror.changed?.should be_false end describe "sub directory contents" do it "the nodes return their children" do subdir_node = @mirror.top.detect {|n| n.text == "subdir"} sub_nodes = subdir_node.children sub_nodes.length.should == 1 sub_nodes.map {|n| n.text}.should == %w(Ford) end end end end after do FileUtils.rm_r(@dirname) end end end
Version data entries
51 entries across 51 versions & 2 rubygems