Sha256: cff3bdd3a2bda1896733916269efd47831d95555970e385a69b7c9267a0c0b23

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Mulder::Client do

  describe '.initialize' do
    let(:mocked_connection) { mock }

    it 'stores the app' do
      described_class.new(mocked_connection, 'foo', 'bar', 'worker').app.should == 'foo'
    end

    it 'stores the environment' do
      described_class.new(mocked_connection, 'foo', 'bar', 'worker').environment.should == 'bar'
    end
  end

  describe '#group' do
    it 'finds the correct group based on the given attributes' do
      mocked_connection = mock
      mocked_connection.expects(:group_by_id_regexp).with(/^.*-?foo-bar-(.*-)?WorkerGroup-.*$/i)
      client = described_class.new(mocked_connection, 'foo', 'bar', 'WorkerGroup')

      client.group
    end
  end

  describe '#instances' do
    it 'finds the instances for the group' do
      mocked_connection = mock
      mocked_group = mock
      mocked_connection.expects(:instances_by_group).with(mocked_group)
      client = described_class.new(mocked_connection, 'foo', 'bar', 'worker')
      client.expects(:group).returns(mocked_group)

      client.instances
    end
  end

  describe '#id_regexp' do
    it 'matches without an autogenerated id' do
      client = described_class.new(mock, 'foo', 'bar', 'worker')
      'foo-bar-worker-3'.should match(client.id_regexp)
    end

    it 'matches with an autogenerated id' do
      client = described_class.new(mock, 'foo', 'bar', 'worker')
      'foo-bar-abc123-worker-3'.should match(client.id_regexp)
    end

    it 'matches with a prefixed id' do
      client = described_class.new(mock, 'foo', 'bar', 'worker')
      'widget-foo-bar-abd123-worker-8'.should match(client.id_regexp)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mulder-0.2.1 spec/lib/mulder/client_spec.rb