test/errors_test.rb in reform-1.2.0.beta1 vs test/errors_test.rb in reform-1.2.0.beta2

- old
+ new

@@ -13,15 +13,22 @@ property :title validates :title, :presence => true end property :band do # yepp, people do crazy stuff like that. + property :name property :label do property :name validates :name, :presence => true end # TODO: make band a required object. + + validate :validate_musical_taste + + def validate_musical_taste + errors.add(:base, "You are a bad person") if name == 'Nickelback' + end end validates :title, :presence => true end @@ -103,9 +110,15 @@ it { @result.must_equal false } it { form.errors.messages.must_equal({:"songs.title"=>["can't be blank"], :"band.label.name"=>["can't be blank"]}) } end + describe "#validate with nested form using :base invalid" do + before { @result = form.validate("songs"=>[{"title" => "Someday"}], "band" => {"name" => "Nickelback", "label" => {"name" => "Roadrunner Records"}}) } + + it { @result.must_equal false } + it { form.errors.messages.must_equal({:base=>["You are a bad person"]}) } + end describe "correct #validate" do before { @result = form.validate( "hit" => {"title" => "Sacrifice"}, "title" => "Second Heat", \ No newline at end of file