Sha256: 6f02f563bab8c89b8a4075ac0678f6591f9dc0385b3f7c8784c23d9e1a649dfc

Contents?: true

Size: 606 Bytes

Versions: 15

Compression:

Stored size: 606 Bytes

Contents

require 'spec_helper'

describe Virtus::AttributeSet, '#[]' do
  subject { object[name] }

  let(:name)       { :name                                   }
  let(:attribute)  { Virtus::Attribute.build(String, :name => :name) }
  let(:attributes) { [ attribute ]                           }
  let(:parent)     { described_class.new                     }
  let(:object)     { described_class.new(parent, attributes) }

  it { is_expected.to equal(attribute) }

  it 'allows indexed access to attributes by the string representation of their name' do
    expect(object[name.to_s]).to equal(attribute)
  end
end

Version data entries

15 entries across 13 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/spec/unit/virtus/attribute_set/element_reference_spec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/spec/unit/virtus/attribute_set/element_reference_spec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/spec/unit/virtus/attribute_set/element_reference_spec.rb
virtus2-2.1.0 spec/unit/virtus/attribute_set/element_reference_spec.rb
virtus2-2.0.2 spec/unit/virtus/attribute_set/element_reference_spec.rb
virtus2-2.0.1 spec/unit/virtus/attribute_set/element_reference_spec.rb
virtus-2.0.0 spec/unit/virtus/attribute_set/element_reference_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/virtus-1.0.5/spec/unit/virtus/attribute_set/element_reference_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/virtus-1.0.5/spec/unit/virtus/attribute_set/element_reference_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/spec/unit/virtus/attribute_set/element_reference_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/spec/unit/virtus/attribute_set/element_reference_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/spec/unit/virtus/attribute_set/element_reference_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/spec/unit/virtus/attribute_set/element_reference_spec.rb
virtus-1.0.5 spec/unit/virtus/attribute_set/element_reference_spec.rb
virtus-1.0.4 spec/unit/virtus/attribute_set/element_reference_spec.rb