spec/java_autotest/autotest_spec.rb in java-autotest-0.0.1 vs spec/java_autotest/autotest_spec.rb in java-autotest-0.0.2

- old
+ new

@@ -1,46 +1,48 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe AutoTest do before(:each) do - @autotest = AutoTest.new - @class = "src/main/java/app/model/Order.java" + test_runner = mock(TestRunner) + TestRunner.stub!(:new).and_return(test_runner) + test_runner.should_receive(:run_all_tests) + @autotest = AutoTest.new + @class = "src/main/java/app/model/Order.java" end - - context "run test" do - + + context "run single test" do + before(:each) do - TestRunner.stub(:run_test).and_return false + @autotest.test_runner.stub!(:run_test).and_return false end - - it "should reset run at date" do + + it "should reset run_at after run" do now = mock(Time) - Time.stub!(:new).and_return(now) - @autotest.run(@class) - @autotest.run_at.should == now + Time.stub!(:new).and_return now + @autotest.run(@class) + @autotest.run_at.should == now end - + it "cannot run all test if test fail" do - TestRunner.should_not_receive(:run_all_tests) + @autotest.test_runner.should_not_receive(:run_all_tests) @autotest.run(@class) end - + it "should run all test if test pass" do - TestRunner.stub(:run_test).and_return true - TestRunner.should_receive(:run_all_tests) + @autotest.test_runner.stub!(:run_test).and_return true + @autotest.test_runner.should_receive(:run_all_tests) @autotest.run(@class) end - + end - + it "should find test class name when class is not a test class" do - test_class = @autotest.find_test_class(@class) - test_class.should == "OrderTest.java" - end - + test_class = @autotest.find_test_class(@class) + test_class.should == "OrderTest" + end + it "should find test class name when class is a test class" do test_class = @autotest.find_test_class("src/test/java/app/model/OrderTest.java") - test_class.should == "OrderTest.java" + test_class.should == "OrderTest" end - end