Sha256: 8f0ff02b5b4693a92bb64d30b67b010035c94c7936935754e196a13f398877a9

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

require 'spec_helper'

describe Pairzone::Api::PairzoneLifecycle do
  subject { stub(:lifecycle, create: unstarted, find_by_project_name: started).extend(Pairzone::Api::PairzoneLifecycle) }
  let(:unstarted) { mock(:pairzone, name: 'pairzone', collaborators: [], ip: '', status: 'unstarted') }
  let(:started) { mock(:pairzone, name: 'pairzone', collaborators: [], ip: '', status: 'started') }

  before do
    subject.start_wait_interval = 0
  end

  context "starting" do
    it "calls create" do
      subject.should_receive(:create) { unstarted }
      subject.start({})
    end

    it "blocks, calling find_by_project_name until the state is started" do
      subject.should_receive(:find_by_project_name).with(unstarted.name).
        exactly(5).times.
        and_return(unstarted, unstarted, unstarted, unstarted, started)
      subject.start({})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pairzone-0.0.1 spec/pairzone/api/pairzone_lifecycle_spec.rb