Sha256: 7f900025e9c6c4dc2943f6e354ef09a5a3a057df7c9d33b907807ef266245cc2

Contents?: true

Size: 1.09 KB

Versions: 50

Compression:

Stored size: 1.09 KB

Contents

class InstaSubscriber < ActionSubscriber::Base
  around_filter :whisper
  around_filter :yell
  around_filter :whisper
  around_filter :whisper
  around_filter :yell

  def first
    $messages << payload
  end

  private

  def whisper
    $messages << :whisper_before
    yield
    $messages << :whisper_after
  end

  def yell
    $messages << :yell_before
    yield
    $messages << :yell_after
  end
end

describe "subscriber filters", :integration => true do
  let(:draw_routes) do
    ::ActionSubscriber.draw_routes do
      default_routes_for InstaSubscriber
    end
  end
  let(:subscriber) { InstaSubscriber }

  it "does not allow an around filter to be pushed on twice" do
    expect(InstaSubscriber.around_filters).to eq([:whisper, :yell])
  end

  it "runs multiple around filters" do
    $messages = []  #testing the order of things
    ::ActionSubscriber.start_subscribers!
    ::ActivePublisher.publish("insta.first", "hEY Guyz!", "events")

    verify_expectation_within(1.0) do
      expect($messages).to eq [:whisper_before, :yell_before, "hEY Guyz!", :yell_after, :whisper_after]
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
action_subscriber-5.1.4-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.4 spec/integration/around_filters_spec.rb
action_subscriber-5.1.4.pre0 spec/integration/around_filters_spec.rb
action_subscriber-5.1.4.pre0-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.3 spec/integration/around_filters_spec.rb
action_subscriber-5.1.3-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.3.pre2 spec/integration/around_filters_spec.rb
action_subscriber-5.1.3.pre2-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.3.pre1 spec/integration/around_filters_spec.rb
action_subscriber-5.1.3.pre1-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.2-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.2 spec/integration/around_filters_spec.rb
action_subscriber-5.1.1-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.1 spec/integration/around_filters_spec.rb
action_subscriber-5.1.1.pre0 spec/integration/around_filters_spec.rb
action_subscriber-5.1.1.pre0-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.0-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.0 spec/integration/around_filters_spec.rb
action_subscriber-5.1.0.pre-java spec/integration/around_filters_spec.rb
action_subscriber-5.1.0.pre spec/integration/around_filters_spec.rb