Sha256: dbe726fd6f8ff2073985887d8c309028f7be6531985e5f3f5c865b256c4328e6
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' describe Virtus::InstanceMethods, '#freeze' do subject { object.freeze } let(:object) do described_class.new(attributes) end context 'on class with no defaults' do let(:described_class) do Class.new do include Virtus attribute :name, String end end let(:attributes) { { :name => 'John' } } it_should_behave_like 'a #freeze method' end context 'on class with literal default' do let(:described_class) do Class.new do include Virtus attribute :name, String, :default => 'John' end end context 'when value is provided' do let(:attributes) { { :name => 'John' } } it_should_behave_like 'a #freeze method' end context 'when value is NOT provided' do let(:attributes) {} it_should_behave_like 'a #freeze method' end end context 'on class with computed default' do let(:described_class) do Class.new do include Virtus attribute :name, String, :default => proc { 'John' } end end context 'when value is provided' do let(:attributes) { { :name => 'John' } } it_should_behave_like 'a #freeze method' end context 'when value is NOT provided' do let(:attributes) {} it_should_behave_like 'a #freeze method' end end end
Version data entries
5 entries across 5 versions & 2 rubygems