# frozen_string_literal: true RSpec.describe StrikeMe::API::WebhookEvent do subject(:event) do described_class.new( 'id' => '245e40d8-f197-411c-8f20-a326d08da402', 'eventType' => 'invoice.updated', 'webhookVersion' => 'v1', 'data' => { 'entityId' => '602cc206-6b4a-42dd-bc89-9a534bb04034', 'changes' => ['state'] }, 'created' => '2026-09-15T12:00:00+00:00', 'deliverySuccess' => true ) end it 'exposes entity_id and changes from the nested data object' do expect(event.entity_id).to eq '602cc206-6b4a-42dd-bc89-9a534bb04034' expect(event.changes).to eq ['state'] end it 'aliases the camelCase attributes to snake_case' do expect(event.event_type).to eq 'invoice.updated' expect(event.webhook_version).to eq 'v1' expect(event.delivery_success).to eq true end it 'parses created as a real Time' do expect(event.created).to be_a Time end it 'identifies invoice events' do expect(event).to be_invoice_event end it 'does not carry the actual changed values — only that state changed, not to what' do expect(event.attributes.keys).not_to include('amount', 'state') end end