Sha256: 3a5e15c65ad054552164987b4825d694a9b2a26b986c48e7f028dec679ce8a3d
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'test_helper' ActiveValidators.activate(:respond_to) describe "Respond To Validation" do def build_respond_to_record attrs = {} TestRecord.reset_callbacks(:validate) TestRecord.validates :responder, :respond_to => { :call => true, :if => :local_condition }, :if => :global_condition TestRecord.new attrs end it "respond_to?" do subject = build_respond_to_record subject.responder = lambda {} subject.global_condition = true subject.local_condition = true _(subject.valid?).must_equal(true) _(subject.errors.size).must_equal(0) end describe "when does not respond_to?" do it "rejects the responder" do subject = build_respond_to_record :responder => 42, :global_condition => true, :local_condition => true _(subject.valid?).must_equal(false) _(subject.errors.size).must_equal(1) end it "generates an error message of type invalid" do subject = build_respond_to_record :responder => 42, :global_condition => true, :local_condition => true _(subject.valid?).must_equal(false) _(subject.errors[:responder].include?(subject.errors.generate_message(:responder, :invalid))).must_equal(true) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activevalidators-6.0.0 | test/validations/respond_to_test.rb |