Sha256: a9dd86e0595cda402fe934ff29cff653875674abb5b4d5b9d433439c11d1c898
Contents?: true
Size: 983 Bytes
Versions: 2
Compression:
Stored size: 983 Bytes
Contents
describe ImmutableValidator do describe 'validation' do subject(:model) do model_class.new(attr: value) end let(:model_class) do Class.new(TestModel) do validates :attr, immutable: true end end let(:value) do 'foo' end context 'on create' do before do allow(model).to receive(:new_record?).and_return(true) allow(model).to receive(:attr_changed?).and_return(true) end it { should be_valid } end context 'on update' do before do allow(model).to receive(:new_record?).and_return(false) end context 'with change' do before do allow(model).to receive(:attr_changed?).and_return(true) end it { should be_invalid } end context 'without change' do before do allow(model).to receive(:attr_changed?).and_return(false) end it { should be_valid } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activemodel-immutable_validator-0.0.2 | spec/immutable_validator_spec.rb |
activemodel-immutable_validator-0.0.1 | spec/immutable_validator_spec.rb |