Sha256: 09546ef2b3db17493013c81103b89a4ab02852def9f643b6af5f3a4a82b353d6
Contents?: true
Size: 708 Bytes
Versions: 8
Compression:
Stored size: 708 Bytes
Contents
require 'spec_helper' describe Virtus::Attribute, '.new' do let(:model) do Class.new do include Virtus attribute :name, String attr_reader :email attr_accessor :age def self.new(attributes) instance = super instance.age = 28 instance end def initialize(attributes = {}) super @email = "john@domain.com" end end end let(:object) do model.new(:name => "john") end it "sets the attributes" do object.name.should eql("john") end it "calls custom #initialize" do object.email.should eql("john@domain.com") end it "calls custom .new" do object.age.should eql(28) end end
Version data entries
8 entries across 8 versions & 1 rubygems