spec/roles_spec.rb in permissive-0.2.4.alpha vs spec/roles_spec.rb in permissive-0.2.5.alpha
- old
+ new
@@ -59,6 +59,28 @@
user = Permissive::User.create!(:role => 'hero')
user.can?(:fight).should be_true
user.can?(:flee).should be_false
end
end
+
+ describe "for models that store the role" do
+ before :each do
+ PermissiveSpecHelper.db_up
+ end
+
+ it "should, like, actually store it" do
+ user = UserWithRole.create!(:role => 'hungry_person')
+ UserWithRole.find(user.id).role.should == 'hungry_person'
+ end
+
+ it "should meta-program an 'is_role?' method" do
+ user = UserWithRole.create!(:role => 'hungry_person')
+ user.should respond_to :is_hungry_person?
+ end
+
+ it "should return `true` from 'is_role?' when a user has the correct role" do
+ user = UserWithRole.create!(:role => 'hungry_person')
+ user.is_hungry_person?.should be_true
+ user.is_sleepy_person?.should be_false
+ end
+ end
end
\ No newline at end of file