require_relative "./helpers" describe BigBench::Runner do before(:each) do Dir.chdir File.dirname(__FILE__) end it "should raise an exception if no benchmarks were defined" do lambda {BigBench.run!}.should raise_error(BigBench::Runner::NoBenchmarksDefined, "Sorry, I couldn't find any benchmarks!") end it "should run all benchmarks" do BigBench.benchmark "index page" => "http://localhost:3001" do get "/" end BigBench.benchmark "login and logout" => "http://localhost:3001" do post "/login" post "/logout" end BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } BigBench.run! BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 1 } end it "should successfully load an external test" do test = File.open("tests/local.rb", "rb"){ |file| file.read } BigBench.load_test!(test) BigBench.config.duration.should == 1.second BigBench.duration.should == 1.second BigBench.benchmarks.size.should == 2 end end