require 'rails_helper'

RSpec.describe SP::Alerts::ActiveRecordExtension do
  describe ".alertable" do
    it "allows resource to be alerted" do
      skip
    end
  end
end

require 'rails_helper'

RSpec.describe SP::Alerts::ActiveRecordExtension do
  describe ActiveRecord::Base do
    it "includes the 'ActiveRecordExtension' module" do
      expect(ActiveRecord::Base.included_modules).to include(SP::Alerts::ActiveRecordExtension)
    end

    it "has the 'alertable' class method" do
      expect(ActiveRecord::Base).to respond_to(:alertable)
    end
  end

  describe ".alertable" do
    before(:all) { class RecordMock < ActiveRecord::Base; end }
    before(:all) { class ModelMock; include SP::Alerts::ActiveRecordExtension; end }

    it "includes the 'Alertable' module" do
      RecordMock.alertable
      expect(RecordMock.included_modules).to include(SP::Alerts::Alertable)
      expect(ActiveRecord::Base.included_modules).not_to include(SP::Alerts::Alertable)
    end

    it "allows resource to be alerted" do
      ModelMock.alertable
      expect(ModelMock.new).to respond_to(:alert)
      expect(ModelMock).not_to respond_to(:alert)
    end
  end
end

Test active record extensions integration
Test active record extensions integration
