Skip to content

Commit

Permalink
complete spec
Browse files Browse the repository at this point in the history
  • Loading branch information
bedrock-adam committed Jan 14, 2024
1 parent 36da040 commit c930ebc
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/outboxer/messageable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper'

RSpec.describe Outboxer::Messageable, type: :model do
before(:each) do
ActiveRecord::Schema.define do
create_table :events, force: true do |_t|
end
end

class Event < ActiveRecord::Base
include Outboxer::Messageable
end
end

after(:each) do
if ActiveRecord::Base.connection.table_exists?('events')
ActiveRecord::Migration.drop_table('events')
end

Object.send(:remove_const, :Event) if Object.const_defined?(:Event)
end

context 'when model created' do
let(:event) { Event.create! }
let(:outboxer_message) { event.outboxer_message }

it 'creates outboxer message' do
expect(outboxer_message.status).to eq(Outboxer::Models::Message::STATUS[:unpublished])
expect(outboxer_message.outboxer_messageable_type).to eq(event.class.to_s)
expect(outboxer_message.outboxer_messageable_id).to eq(event.id)
expect(outboxer_message.created_at).to be_present
expect(outboxer_message.updated_at).to be_present
end
end
end

0 comments on commit c930ebc

Please sign in to comment.