Sha256: 06ffdd4ffe05765b8afbaab5d393a970cc2aa65e5f3ab19c2f2bad761eeaebaa

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'fake_sqs/api'

class FakeSQS::Actions::TheAction

  def initialize(options)
    @options = options
  end

  def call(params)
    { :options => @options, :params => params }
  end

end

RSpec.describe FakeSQS::API do

  it "delegates actions to classes" do
    queues = double :queues
    allow(queues).to receive(:transaction).and_yield
    api = FakeSQS::API.new(:queues => queues)

    response = api.call("TheAction", {}, {:foo => "bar"})

    expect(response[:options]).to eq :queues => queues, :request => {}
    expect(response[:params]).to eq :foo => "bar"
  end

  it "raises InvalidAction for unknown actions" do
    api = FakeSQS::API.new(:queues => [])

    expect {
      api.call("SomethingDifferentAndUnknown", {:foo => "bar"})
    }.to raise_error(FakeSQS::InvalidAction)

  end

  it "resets queues" do
    queues = double :queues
    api = FakeSQS::API.new(:queues => queues)
    expect(queues).to receive(:reset)
    api.reset
  end

  it "expires messages in queues" do
    queues = double :queues
    api = FakeSQS::API.new(:queues => queues)
    expect(queues).to receive(:expire)
    api.expire
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fake_sqs-0.4.3 spec/unit/api_spec.rb
fake_sqs-0.4.2 spec/unit/api_spec.rb
fake_sqs-0.4.1 spec/unit/api_spec.rb