Created
November 24, 2016 13:29
-
-
Save ArturT/20fd2f9690c306f5b8edcfbf0e16d091 to your computer and use it in GitHub Desktop.
FakeEntity Virtus model with overridden status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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