Sha256: 42aac80a702d88a3cfec353eb0049dc14467a187ba892c081414cd3ddb83f49a
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 "Restorm::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 |
---|---|
restorm-1.0.0 | spec/model/validations_spec.rb |