Sha256: 0be0183cc204b6422f2d679226cb3e1e78a0734696f72f5d4045de4858355778
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe "Her::Model and ActiveModel::Validations" do context "validating attributes" do before do spawn_model "Foo::User" do attributes :fullname, :email validates_presence_of :fullname validates_presence_of :email end end it "validates attributes when calling #valid?" do user = Foo::User.new expect(user).not_to be_valid expect(user.errors.full_messages).to include("Fullname can't be blank") expect(user.errors.full_messages).to include("Email can't be blank") user.fullname = "Tobias Fünke" user.email = "tobias@bluthcompany.com" expect(user).to be_valid end end context "handling server errors" do before do spawn_model("Foo::Model") do def errors @response_errors end end class User < Foo::Model; end @spawned_models << :User end it "validates attributes when calling #valid?" do user = User.new(:_errors => ["Email cannot be blank"]) expect(user.errors).to include("Email cannot be blank") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
castle-her-1.0.1 | spec/model/validations_spec.rb |