Sha256: 0cfb897c73a7dcda58bd6c3bfb19cb3c244f4c466ae175f48cee7c4314304147

Contents?: true

Size: 667 Bytes

Versions: 12

Compression:

Stored size: 667 Bytes

Contents

require 'spec_helper'

describe Virtus::Attribute, '#set' do
  subject { object.set(instance, value) }

  let(:object) { described_class.build(String, options.merge(:name => name)) }

  let(:model)    { Class.new { attr_reader :test } }
  let(:name)     { :test }
  let(:instance) { model.new }
  let(:value)    { 'Jane Doe' }
  let(:options)  { {} }

  it { should be(value) }

  context 'without coercion' do
    specify do
      expect { subject }.to change { instance.test }.to(value)
    end
  end

  context 'with coercion' do
    let(:value) { :'Jane Doe' }

    specify do
      expect { subject }.to change { instance.test }.to('Jane Doe')
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
virtus-1.0.3 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.2 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.1 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.rc2 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.rc1 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.beta8 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.beta7 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.beta6 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.beta5 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.beta4 spec/unit/virtus/attribute/set_spec.rb
virtus-1.0.0.beta3 spec/unit/virtus/attribute/set_spec.rb