Sha256: 5a9684596db7611504741ca669e2976a9c0529c716ace11bf04f19b37b0581f0

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe AutoTest do

  before(:each) do
    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 single test" do

    before(:each) do
      @autotest.test_runner.stub!(:run_test).and_return false
    end  

    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
    end

    it "cannot run all test if test fail" do
      @autotest.test_runner.should_not_receive(:run_all_tests)
      @autotest.run(@class)
    end

    it "should run all test if test pass" do
      @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"
  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"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
java-autotest-0.0.2 spec/java_autotest/autotest_spec.rb