Sha256: 502a1988273082783d4ee1c2a1f42ef1586c6c7d30a1904b7a70b940e42fd58a

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'
require 'bait/tester'

describe Bait::Tester do
  let(:build) { Bait::Build.create(name: "bait", clone_url:repo_path) }
  let(:tester) { Bait::Tester.new }

  describe "#perform" do
    subject { build.reload }
    before { build.clone! }

    describe "real-time events" do
      before do
        write_script_with_status build.script("test"), 0
      end
      it "push updates directly to the browser" do
        Bait.should_receive(:broadcast).with(:build, :status, build.id, 'testing')
        Bait.should_receive(:broadcast).with(:build, :output, build.id, kind_of(String))
        Bait.should_receive(:broadcast).with(:build, :status, build.id, 'passed')
        tester.perform build.id
      end
    end

    context "build repo did not have a test script" do
      before do
        FileUtils.rm build.script("test")
        tester.perform build.id
      end
      it "has errors in output" do
        build.reload.output.should match /was expected but is missing/
      end
      it "has a useful status" do
        build.reload.status.should eq "script missing"
      end
    end

    context "has a test script" do
      before do
        write_script_with_status build.script('test'), status
        tester.perform build.id
      end

      shared_examples_for "a test run" do
        it "saves output into the build" do
          build.reload.output.should match "this is a test script"
        end
      end

      context "successful" do
        let(:status) { 0 }
        it { should be_passed }
        it_behaves_like "a test run"
      end
      context 'failure' do
        let(:status) { 1 }
        it { should_not be_passed }
        it_behaves_like "a test run"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bait-0.5.6 spec/lib/bait/tester_spec.rb
bait-0.5.5 spec/lib/bait/tester_spec.rb
bait-0.5.4 spec/lib/bait/tester_spec.rb