Sha256: 7d8cd81999c92c2b0f42a6f7bfdf3ee1fde607096859c0bdc72802ae8c2f2db3

Contents?: true

Size: 698 Bytes

Versions: 18

Compression:

Stored size: 698 Bytes

Contents

require 'spec_helper'

describe 'I can extend objects' do
  before do
    module Examples
      class User; end

      class Admin; end
    end
  end

  specify 'defining attributes on an object' do
    attributes = { :name => 'John', :age => 29 }

    admin = Examples::Admin.new
    admin.extend(Virtus)

    admin.attribute :name, String
    admin.attribute :age,  Integer

    admin.name = 'John'
    admin.age  = 29

    admin.name.should eql('John')
    admin.age.should eql(29)

    admin.attributes.should eql(attributes)

    new_attributes   = { :name => 'Jane', :age => 28 }
    admin.attributes = new_attributes

    admin.name.should eql('Jane')
    admin.age.should eql(28)
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
virtus-1.0.2 spec/integration/extending_objects_spec.rb
virtus-1.0.1 spec/integration/extending_objects_spec.rb
virtus-1.0.0 spec/integration/extending_objects_spec.rb
virtus-1.0.0.rc2 spec/integration/extending_objects_spec.rb
virtus-1.0.0.rc1 spec/integration/extending_objects_spec.rb
virtus-1.0.0.beta8 spec/integration/extending_objects_spec.rb
virtus-1.0.0.beta7 spec/integration/extending_objects_spec.rb
virtus-1.0.0.beta6 spec/integration/extending_objects_spec.rb
virtus-1.0.0.beta5 spec/integration/extending_objects_spec.rb
virtus-1.0.0.beta4 spec/integration/extending_objects_spec.rb
virtus-1.0.0.beta3 spec/integration/extending_objects_spec.rb
virtus-0.5.5 spec/integration/extending_objects_spec.rb
virtus-0.5.4 spec/integration/extending_objects_spec.rb
virtus-0.5.3 spec/integration/extending_objects_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/integration/extending_objects_spec.rb
virtus-0.5.2 spec/integration/extending_objects_spec.rb
virtus-0.5.1 spec/integration/extending_objects_spec.rb
virtus-0.5.0 spec/integration/extending_objects_spec.rb