Sha256: 10909a980d5722c54939feed4bb698162a3702d09a6d2860abe069f0f5372eb6

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

require 'spec_helper'

describe EventLogger::EventLog do
  it { should have_db_column(:event).of_type(:string) }
  it { should have_db_column(:object).of_type(:text) }
  it { should validate_presence_of(:event) }

  describe "#create" do
    it "should make a new event log given valid attributes" do
      expect { 
        event = EventLogger::EventLog.create(:event => "user:registration:failed", :object => "{'somekey': 'somevalue'}")
        event.save!
      }.to change {EventLogger::EventLog.count}.by(1)
    end
    it "will save a return full objects" do
      user = User.create(name: 'Frank Awesome', age: '30')
      event = EventLogger::EventLog.create(:event => "user_registration_success", :object => user)
      saved_event = EventLogger::EventLog.find(event.id)
      expect(saved_event.object.name).to eq(user.name)
    end
  end
     
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
event_logger-0.1.0 spec/models/event_logger/event_log_spec.rb