Sha256: 08c6e08762ee20355e27a1338e4cfc3917db906142870abc2c982c244f0a747d
Contents?: true
Size: 903 Bytes
Versions: 2
Compression:
Stored size: 903 Bytes
Contents
shared_examples_for 'a #freeze method' do let(:sample_exception) do begin object.dup.freeze.instance_variable_set(:@foo,:bar) rescue => exception exception end end let(:expected_exception_class) do # Ruby 1.8 blows up with TypeError Ruby 1.9 with RuntimeError sample_exception.class end let(:expected_exception_message) do # Ruby 1.8 blows up with a different message than Ruby 1.9 sample_exception.message end it_should_behave_like 'an idempotent method' it 'returns object' do should be(object) end it 'prevents future modifications' do subject expectation = raise_error(expected_exception_class,expected_exception_message) expect { object.instance_variable_set(:@foo,:bar) }.to(expectation) end its(:frozen?) { should be(true) } it 'allows to access attribute' do subject.name.should eql('John') end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
fragrant-0.0.5 | vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/shared/freeze_method_behavior.rb |
virtus-0.5.2 | spec/shared/freeze_method_behavior.rb |