spec/unit/virtus/model_spec.rb in virtus-1.0.3 vs spec/unit/virtus/model_spec.rb in virtus-1.0.4

- old
+ new

@@ -146,21 +146,52 @@ before do model.send(:include, mod) end - it { should_not respond_to(:attributes) } - it { should_not respond_to(:attributes=) } + it { is_expected.not_to respond_to(:attributes) } + it { is_expected.not_to respond_to(:attributes=) } end context 'with an instance' do subject { model.new } before do subject.extend(mod) end - it { should_not respond_to(:attributes) } - it { should_not respond_to(:attributes=) } + it { is_expected.not_to respond_to(:attributes) } + it { is_expected.not_to respond_to(:attributes=) } + end + end + + context 'when :required is set' do + let(:mod) { Virtus.model(:required => false) } + let(:model) { Class.new } + + context 'with a class' do + subject { model.new } + + before do + model.send(:include, mod) + model.attribute :name, String + end + + it 'has attributes with :required option inherited from module' do + expect(model.attribute_set[:name]).to_not be_required + end + end + + context 'with an instance' do + subject { model.new } + + before do + subject.extend(mod) + subject.attribute :name, String + end + + it 'has attributes with strict set to true' do + expect(subject.send(:attribute_set)[:name]).not_to be_required + end end end end