File: custom_collection_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 (29 lines) | stat: -rw-r--r-- 777 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
24
25
26
27
28
29
require 'spec_helper'

describe Virtus::Attribute::Collection, 'custom subclass' do
  subject { attribute_class.build(primitive) }

  let(:primitive) { Class.new  { include Enumerable } }

  after do
    described_class.descendants.delete(attribute_class)
  end

  context 'when primitive is set on the attribute subclass' do
    let(:attribute_class) { Class.new(described_class).primitive(primitive) }

    describe '#primitive' do
      subject { super().primitive }
      it { is_expected.to be(primitive) }
    end
  end

  context 'when primitive is not set on the attribute subclass' do
    let(:attribute_class) { Class.new(described_class) }

    describe '#primitive' do
      subject { super().primitive }
      it { is_expected.to be(primitive) }
    end
  end
end