Sha256: 3093ab79eeef77ed39d48cfe5a8045806ce1d5d2223abc9469c34b62f56279d0
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require "test/test_helper" class HasRoleTest < ActiveSupport::TestCase context "Objects that have an aegis role" do setup do @guest = User.new(:role_name => "guest") @student = User.new(:role_name => "student") @student_subclass = UserSubclass.new(:role_name => "student") @admin = User.new(:role_name => "admin") end should "know their role" do assert_equal :guest, @guest.role.name assert_equal :student, @student.role.name assert_equal :student, @student_subclass.role.name assert_equal :admin, @admin.role.name end should "know if they belong to a role" do assert @guest.guest? assert !@guest.student? assert !@guest.admin? assert !@student.guest? assert !@student_subclass.guest? assert @student.student? assert @student_subclass.student? assert !@student.admin? assert !@student_subclass.admin? assert !@admin.guest? assert !@admin.student? assert @admin.admin? end should "still behave as usual when a method ending in a '?' does not map to a role query" do assert_raise NoMethodError do @guest.nonexisting_method? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aegis-1.1.5 | test/has_role_test.rb |