Sha256: 72a5dc59dc6a9720f8b9da0cfb002317a2b7a408bad92e21e81d64a6403cb859
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' describe Yema::Validations, "#valid?" do subject { model.valid? } let(:described_class) do Class.new do include Yema::Validations end end let(:model) { described_class.new } let(:rule) { stub('rule', errors: Set.new(errors)) } before do described_class.rules.add(rule) end context "when valid" do let(:errors) { [] } it { should be_true } specify { model.errors.should be_empty } context "add 1 invalid rule" do let(:invalid_rule) { stub('invalid', errors: Set.new([stub('error')])) } before { described_class.rules.add(invalid_rule) } it { should be_false } specify { model.rules.count.should eql(2) } specify { model.errors.count.should eql(1) } end end context "when invalid" do let(:errors) { [stub('error1'), stub('error2')] } it { should be_false } specify { model.errors.count.should eql(2) } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yema-0.0.3 | spec/unit/validations/valid_spec.rb |
yema-0.0.2 | spec/unit/validations/valid_spec.rb |
yema-0.0.1 | spec/unit/validations/valid_spec.rb |