spec/executor_spec.rb in bigbench-0.0.4 vs spec/executor_spec.rb in bigbench-0.0.5

- old
+ new

@@ -1,37 +1,17 @@ require_relative "./helpers" describe BigBench::Executor do - context "should raise an argument error for" do - - it "nil arguments" do - argv = nil - lambda{ BigBench::Executor.run!(argv) }.should raise_exception(BigBench::Executor::InvalidCommand) - end - - it "empty arguments" do - argv = [] - lambda{ BigBench::Executor.run!(argv) }.should raise_exception(BigBench::Executor::InvalidCommand) - end - - it "weird arguments" do - argv = ["something"] - lambda{ BigBench::Executor.run!(argv) }.should raise_exception(BigBench::Executor::InvalidCommand) - end - - it "longer weird arguments" do - argv = ["something", "really", "strange"] - lambda{ BigBench::Executor.run!(argv) }.should raise_exception(BigBench::Executor::InvalidCommand) - end - + before(:each) do + Dir.chdir File.dirname(__FILE__) end it "should run a local test with trackings" do - argv = ["run", "local", "spec/tests/local.rb"] - BigBench::Executor.run!(argv) + argv = ["local", "tests/local.rb"] + BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 1 } File.exist?(BigBench.config.output).should be_true @@ -43,12 +23,12 @@ end it "should run a bot test" do - argv = ["run", "bots", "spec/tests/local.rb"] - BigBench::Executor.run!(argv) + argv = ["bots", "tests/local.rb"] + BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } File.exist?(BigBench.config.output).should be_true @@ -59,30 +39,30 @@ File.delete BigBench.config.output end it "should show the help file" do - argv = ["--help"] - lambda{ BigBench::Executor.run!(argv) }.should_not raise_exception - File.exists?("lib/bigbench/help/executor.txt").should be_true + argv = ["help"] + lambda{ BigBench::Executor::Executable.start(argv) }.should_not raise_exception + File.exists?("../lib/bigbench/help/executor.txt").should be_true end it "should reset everything" do BigBench::Store.setup!("http://localhost:6379").should be_true BigBench::Store.test = "something" - argv = ["reset", "all"] - BigBench::Executor.run!(argv) + argv = ["reset"] + BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 0 BigBench::Store.test.should be_nil end it "should re-run the post processors from a receipt" do - argv = ["run", "postprocessors", "spec/tests/with_post_processor.rb"] - BigBench::Executor.run!(argv) + argv = ["process", "tests/with_post_processor.rb"] + BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 1 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } File.exist?(BigBench.config.output).should be_true @@ -94,12 +74,12 @@ end it "should run a single post processor for a single test" do - argv = ["run", "postprocessor", "spec/tests/with_post_processor.rb", "statistics"] - BigBench::Executor.run!(argv) + argv = ["process", "tests/with_post_processor.rb", "statistics"] + BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 1 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } File.exist?(BigBench.config.output).should be_true @@ -108,8 +88,18 @@ end BigBench.post_processors.size.should == 1 BigBench.post_processors.first.runs.should == 1 + end + + it "should generate a new testfile", :generate do + Dir.chdir "tmp" + + File.exists?("new_test.rb").should be_false + argv = ["generate", "new_test"] + BigBench::Executor::Executable.start(argv) + File.exists?("new_test.rb").should be_true + FileUtils.rm "new_test.rb" end end \ No newline at end of file