Sha256: 5a47d9668041bf5dae7606a12301628c11a8cc4614bf01c9bf68a330e81173ae
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yema-0.0.3 | spec/integration/virtus/combination_spec.rb |
yema-0.0.2 | spec/integration/virtus/combination_spec.rb |
yema-0.0.1 | spec/integration/virtus/combination_spec.rb |