Sha256: a7dea8669a3aeaf81305bc9eb80a2b728e12dd0aaf14b56550d6490ad48b4988

Contents?: true

Size: 908 Bytes

Versions: 164

Compression:

Stored size: 908 Bytes

Contents

describe ActionSubscriber::Middleware::Decoder do
  include_context 'action subscriber middleware env'

  subject { described_class.new(app) }

  it_behaves_like 'an action subscriber middleware'

  let(:env) { ActionSubscriber::Middleware::Env.new(UserSubscriber, encoded_payload, message_properties) }
  let(:encoded_payload) { JSON.generate(payload) }
  let(:payload) { {"ohai" => "GUYZ"} }

  context "when the content type has an associated decoder" do
    before { message_properties[:content_type] = "application/json"}

    it "decodes the payload" do
      subject.call(env)
      expect(env.payload).to eq(payload)
    end
  end

  context "when the content type does not have an associated decoder" do
    before { message_properties[:content_type] = "application/foo"}

    it "uses the payload as-is" do
      subject.call(env)
      expect(env.payload).to eq(encoded_payload)
    end
  end
end

Version data entries

164 entries across 164 versions & 1 rubygems

Version Path
action_subscriber-5.3.3-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.3 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.2-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.2 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.1-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.1 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.1.pre-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.1.pre spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.0-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.3.0 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.4-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.4 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.3-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.3 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.2-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.2 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.1-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.1 spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.0-java spec/lib/action_subscriber/middleware/decoder_spec.rb
action_subscriber-5.2.0 spec/lib/action_subscriber/middleware/decoder_spec.rb