Skip to content

Commit

Permalink
spec fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
raghuramg committed Jan 17, 2025
1 parent 25b96c9 commit 6f767e9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/event_source/operations/mime_encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def encode(mime_type, payload)
when 'application/json'
encoded_data = payload.to_json
end
log_encoding_details(mime_type, payload, encoded_data) if encoded_data
log_encoding_details(mime_type, payload.to_json, encoded_data) if encoded_data

Success(encoded_data || payload)
rescue JSON::GeneratorError => e
Expand Down
2 changes: 1 addition & 1 deletion lib/event_source/publish_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def determine_encoding
end

def amqp_protocol?
subject.is_a?(EventSource::Protocols::Amqp::BunnyPublisherProxy)
subject.is_a?(EventSource::Protocols::Amqp::BunnyExchangeProxy)
end
end
end
14 changes: 1 addition & 13 deletions spec/event_source/operations/mime_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
result = subject.call(mime_type, payload)

expect(result).to be_success
expect(result.value!).to eq(payload)
expect(result.value!).to eq(payload.to_json)
end
end

Expand All @@ -39,17 +39,5 @@
expect(result.failure).to eq("Invalid MIME type 'text/plain'. Supported types are: application/zlib, application/json.")
end
end

context "when the payload is invalid" do
let(:payload) { 1000 }
let(:mime_type) { "application/json" }

it "returns a failure" do
result = subject.call(mime_type, payload)

expect(result).to be_failure
expect(result.failure).to eq("Invalid payload type. Expected a Hash or String, but received Integer.")
end
end
end
end
4 changes: 2 additions & 2 deletions spec/event_source/protocols/amqp/bunny_exchange_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

describe '#publish' do
it 'publishes the payload with the correct bindings and headers' do
subject.publish(payload: payload, publish_bindings: publish_bindings, headers: headers)
subject.publish(payload: payload.to_json, publish_bindings: publish_bindings, headers: headers)

expect(bunny_exchange).to have_received(:publish).with(payload.to_json, {
correlation_id: '12345',
Expand All @@ -41,7 +41,7 @@
expect(subject.logger).to receive(:debug).with(/published message:/)
expect(subject.logger).to receive(:debug).with(/published message to exchange:/)

subject.publish(payload: payload, publish_bindings: publish_bindings, headers: headers)
subject.publish(payload: payload.to_json, publish_bindings: publish_bindings, headers: headers)
end

context 'when the payload is binary' do
Expand Down

0 comments on commit 6f767e9

Please sign in to comment.