From ed11b05b97c1cafab516e4cb0697d503fc9051b2 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 5 Nov 2013 14:37:26 -0500 Subject: [PATCH] add rscons_spec.rb --- spec/rscons_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/rscons_spec.rb diff --git a/spec/rscons_spec.rb b/spec/rscons_spec.rb new file mode 100644 index 0000000..9fa2bfe --- /dev/null +++ b/spec/rscons_spec.rb @@ -0,0 +1,26 @@ +describe Rscons do + describe ".clean" do + it "removes all build targets and created directories" do + cache = "cache" + Rscons::Cache.should_receive(:new).and_return(cache) + cache.should_receive(:targets).and_return(["build/a.out", "build/main.o"]) + FileUtils.should_receive(:rm_f).with("build/a.out") + FileUtils.should_receive(:rm_f).with("build/main.o") + cache.should_receive(:directories).and_return(["build/one", "build/one/two", "build", "other"]) + File.should_receive(:directory?).with("build/one/two").and_return(true) + Dir.should_receive(:entries).with("build/one/two").and_return([".", ".."]) + Dir.should_receive(:rmdir).with("build/one/two") + File.should_receive(:directory?).with("build/one").and_return(true) + Dir.should_receive(:entries).with("build/one").and_return([".", ".."]) + Dir.should_receive(:rmdir).with("build/one") + File.should_receive(:directory?).with("build").and_return(true) + Dir.should_receive(:entries).with("build").and_return([".", ".."]) + Dir.should_receive(:rmdir).with("build") + File.should_receive(:directory?).with("other").and_return(true) + Dir.should_receive(:entries).with("other").and_return([".", "..", "other.file"]) + Rscons::Cache.should_receive(:clear) + + Rscons.clean + end + end +end