Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

65 lines (49 sloc) 1.362 kb
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
Jump to Line
Something went wrong with that request. Please try again.