Sha256: d2abefb62d787cc7d90bd46b70565885ad1047a6f9b528730e7bcd9479c5e125
Contents?: true
Size: 688 Bytes
Versions: 1
Compression:
Stored size: 688 Bytes
Contents
require "ohm" require_relative "helper" Ohm.redis = Redic.new("redis://localhost:6379") Ohm.redis.call("SELECT", "30") class User < Ohm::Model attribute :email unique :email end class Signup < Scrivener attr_accessor :email def validate assert_unique :email, :User end end prepare do Ohm.flush end test "invalid if attribute is already taken" do user = User.create(email: "aquiles@me.com") signup = Signup.new(email: user.email) assert !(signup.valid?) assert_equal [:not_unique], signup.errors[:email] end test "valid if attribute is not taken" do signup = Signup.new(email: "aquiles@me.com") assert signup.valid? assert signup.errors.empty? end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scrivener-contrib-1.0.0 | test/ohm.rb |