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 08e4f81
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 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
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

0 comments on commit 08e4f81

Please sign in to comment.