File: instance_level_attributes_spec.rb

package info (click to toggle)
ruby-virtus 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: ruby: 4,378; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 506 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'spec_helper'

describe Virtus, 'instance level attributes' do
  subject do
    subject = Object.new
    subject.singleton_class.send(:include, Virtus)
    subject
  end

  let(:attribute) { subject.singleton_class.attribute(:name, String) }

  before do
    pending if RUBY_VERSION < '1.9'
  end

  context 'adding an attribute' do
    it 'allows setting the attribute value on the instance' do
      attribute
      subject.name = 'foo'
      expect(subject.name).to eql('foo')
    end
  end
end