Sha256: d82deae7cb1907848159a5a10dec2f92e96b3a2691b5d360ce06008c26375beb

Contents?: true

Size: 696 Bytes

Versions: 7

Compression:

Stored size: 696 Bytes

Contents

require 'spec_helper'
require 'set'

describe Virtus::Attribute::Collection, '#value_coerced?' do
  subject { object.value_coerced?(input) }

  let(:object) { described_class.build(Array[Integer]) }

  context 'when input has correctly typed members' do
    let(:input) { [1, 2, 3] }

    it { is_expected.to be(true) }
  end

  context 'when input has incorrectly typed members' do
    let(:input) { [1, 2, '3'] }

    it { is_expected.to be(false) }
  end

  context 'when the collection type is incorrect' do
    let(:input) { Set[1, 2, 3] }

    it { is_expected.to be(false) }
  end

  context 'when the input is empty' do
    let(:input) { [] }
    it { is_expected.to be(true) }
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/spec/unit/virtus/attribute/collection/value_coerced_predicate_spec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/spec/unit/virtus/attribute/collection/value_coerced_predicate_spec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/spec/unit/virtus/attribute/collection/value_coerced_predicate_spec.rb
virtus2-2.1.0 spec/unit/virtus/attribute/collection/value_coerced_predicate_spec.rb
virtus2-2.0.2 spec/unit/virtus/attribute/collection/value_coerced_predicate_spec.rb
virtus2-2.0.1 spec/unit/virtus/attribute/collection/value_coerced_predicate_spec.rb
virtus-2.0.0 spec/unit/virtus/attribute/collection/value_coerced_predicate_spec.rb