require 'spec_helper' describe 'Combination' do subject { described_class.new(value).errors } let(:described_class) do Class.new do include Yema::Virtus::Validations attribute :name, String attribute :username, String, required: true, format: /langit/ attribute :salutation, String, within: ['mr', 'ms'] attribute :address, String, strict: :allow_nil attribute :age, Integer, within: 1..26 attribute :height, Integer, required: false, default: 173 attribute :active, Virtus::Attribute::Boolean attribute :pages, Array[String], length: 2..3 attribute :phones, Array self end end it_behaves_like "valid resource", { name: 'handi', username: 'langitbiru', salutation: 'mr', age: '23', active: false, pages: [1, 2, '3a'], phones: [1, 2, '3a'], } describe "check value" do subject { described_class.new(value) } let(:value) do { name: 'handi', username: 'langitbiru', salutation: 'mr', age: '23', pages: [1, 2, 3], phones: [1, 2, 3], } end its(:name) { should eql('handi') } its(:username) { should eql('langitbiru') } its(:salutation) { should eql('mr') } its(:address) { should be_nil } its(:age) { should eql(23) } its(:height) { should eql(173) } its(:active) { should be_false } specify { subject.pages.count.should eql(3) } specify { subject.phones.count.should eql(3) } end end