Sha256: ce0966ef0f23d22f3079b58c95a115b29dfb0c8451076df215e75113379159bd

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 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
    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

4 entries across 4 versions & 1 rubygems

Version Path
fake_sqs-0.4.0 spec/unit/api_spec.rb
fake_sqs-0.3.1 spec/unit/api_spec.rb
fake_sqs-0.3.0 spec/unit/api_spec.rb
fake_sqs-0.2.0 spec/unit/api_spec.rb