require_relative "./helpers" describe BigBench::Runner do 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 load an external test and warn about the missing config" do test = File.open("spec/tests/local_invalid.rb", "rb"){ |file| file.read } lambda{ BigBench.load_test!(test) }.should raise_error(BigBench::Configuration::InvalidOptions, "At least: #{BigBench::Configuration::Config::VALIDATE_OPTIONS.join(', ')} are required") end it "should successfully load an external test" do test = File.open("spec/tests/local.rb", "rb"){ |file| file.read } BigBench.load_test!(test) BigBench.benchmarks.size.should == 2 end end