Sha256: 18989525fc866d00a111ad50bd5b3045e675b2f38158b0d1fa3de7c1b6298a2a

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

describe RabbitMQ::Definition::Load do
  let(:client) do
    double(
      "client",
      :upload_definitions => nil,
    )
  end

   context "when a definition file does NOT exist" do
    before { allow(RabbitMQ::Definition::FileDefinition).to receive(:exists?).and_return(false) }

    it "notifies about error" do
      expect(RabbitMQ::Definition::Logger).to receive(:error).with("No definition with vhosts exists").once
      described_class.run(client, false)
    end
  end

  context "when a definition file does NOT exist" do
    let(:json) { '{"definitions": "json"}' }
    before do
      allow(RabbitMQ::Definition::FileDefinition).to receive(:exists?).and_return(true) 
      expect(RabbitMQ::Definition::FileDefinition).to receive(:read).and_return(double(:to_json => json))
    end

    it "notifies progress" do
      expect(RabbitMQ::Definition::Logger).to receive(:progress).with("Uploading definition...").once
      described_class.run(client, true)
    end

    it "notifies success" do
      expect(RabbitMQ::Definition::Logger).to receive(:success).with("Done").once
      described_class.run(client, true)
    end

    it "uploads the json definition to the client " do
      expect(client).to receive(:upload_definitions).with(json).once
      described_class.run(client, false)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rabbitmq-definition-0.1.2 spec/rabbitmq_definition/load_spec.rb
rabbitmq-definition-0.1.1 spec/rabbitmq_definition/load_spec.rb
rabbitmq-definition-0.1.0 spec/rabbitmq_definition/load_spec.rb