Sha256: 62a9c9f2158d312ab7175a3e5fd52886d2a3cd8a2c0b8897bfd74cb64c45863e

Contents?: true

Size: 1.58 KB

Versions: 86

Compression:

Stored size: 1.58 KB

Contents

class PokemonSubscriber < ActionSubscriber::Base
  at_most_once!

  def caught_em_all
    $messages << "DONE::#{$messages.size}"
    raise RuntimeError.new("what do I do now?")
  end
end

class PokemonWithAroundSubscriber < ActionSubscriber::Base
  around_filter :catch_you_first
  at_most_once!

  def caught_em_all
    raise RuntimeError.new("what do I do now?")
  end

  private

  def catch_you_first
    $messages << "DONE::#{$messages.size}"
    raise RuntimeError.new("caught you first")
  end
end

describe "at_most_once! mode", :integration => true do
  context "without overriding around_filter" do
    let(:draw_routes) do
      ::ActionSubscriber.draw_routes do
        default_routes_for PokemonSubscriber
      end
    end
    let(:subscriber) { PokemonSubscriber }

    it "does not retry a failed message" do
      ::ActionSubscriber.start_subscribers!
      ::ActivePublisher.publish("pokemon.caught_em_all", "All Pokemon have been caught", "events")

      verify_expectation_within(1.0) do
        expect($messages.size).to eq 1
      end
    end
  end

  context "with overriding around_filter" do
    let(:draw_routes) do
      ::ActionSubscriber.draw_routes do
        default_routes_for PokemonWithAroundSubscriber
      end
    end
    let(:subscriber) { PokemonWithAroundSubscriber }

    it "does not retry a failed message" do
      ::ActionSubscriber.start_subscribers!
      ::ActivePublisher.publish("pokemon_with_around.caught_em_all", "All Pokemon have been caught", "events")

      verify_expectation_within(1.0) do
        expect($messages.size).to eq 1
      end
    end
  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
action_subscriber-5.3.3-java spec/integration/at_most_once_spec.rb
action_subscriber-5.3.3 spec/integration/at_most_once_spec.rb
action_subscriber-5.3.2-java spec/integration/at_most_once_spec.rb
action_subscriber-5.3.2 spec/integration/at_most_once_spec.rb
action_subscriber-5.3.1-java spec/integration/at_most_once_spec.rb
action_subscriber-5.3.1 spec/integration/at_most_once_spec.rb
action_subscriber-5.3.1.pre-java spec/integration/at_most_once_spec.rb
action_subscriber-5.3.1.pre spec/integration/at_most_once_spec.rb
action_subscriber-5.3.0-java spec/integration/at_most_once_spec.rb
action_subscriber-5.3.0 spec/integration/at_most_once_spec.rb
action_subscriber-5.2.4-java spec/integration/at_most_once_spec.rb
action_subscriber-5.2.4 spec/integration/at_most_once_spec.rb
action_subscriber-5.2.3-java spec/integration/at_most_once_spec.rb
action_subscriber-5.2.3 spec/integration/at_most_once_spec.rb
action_subscriber-5.2.2-java spec/integration/at_most_once_spec.rb
action_subscriber-5.2.2 spec/integration/at_most_once_spec.rb
action_subscriber-5.2.1-java spec/integration/at_most_once_spec.rb
action_subscriber-5.2.1 spec/integration/at_most_once_spec.rb
action_subscriber-5.2.0-java spec/integration/at_most_once_spec.rb
action_subscriber-5.2.0 spec/integration/at_most_once_spec.rb