Skip to content

Instantly share code, notes, and snippets.

@ArturT
Created November 24, 2016 13:29
Show Gist options
  • Save ArturT/20fd2f9690c306f5b8edcfbf0e16d091 to your computer and use it in GitHub Desktop.
Save ArturT/20fd2f9690c306f5b8edcfbf0e16d091 to your computer and use it in GitHub Desktop.
FakeEntity Virtus model with overridden status.
require 'spec_helper'
class FakeEntity
include Virtus.model(coerce: true)
attribute :status, String
attribute :internal_status, String
def initialize(**kwargs)
super
self.attributes = attributes.merge({
internal_status: attributes[:status],
status: get_status,
})
end
def get_status
'current'
end
end
describe FakeEntity do
let(:entity) { FakeEntity.new(status: 'live') }
it { expect(entity.status).to eq 'current' }
it { expect(entity.internal_status).to eq 'live' }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment