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 end it "should run a local test with trackings" do argv = ["run", "local", "spec/tests/local.rb"] BigBench::Executor.run!(argv) BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 1 } File.exist?(BigBench.config.output).should be_true File.open(BigBench.config.output) do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end File.delete BigBench.config.output end it "should run a bot test" do argv = ["run", "bots", "spec/tests/local.rb"] BigBench::Executor.run!(argv) BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } File.exist?(BigBench.config.output).should be_true File.open(BigBench.config.output) do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end 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 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) BigBench.benchmarks.size.should == 0 BigBench::Store.test.should be_nil end end