Skip to content

Commit 0cf293f

Browse files
committed
Add test cases for custom methods starts with is_ and ends with ?
1 parent 29deed1 commit 0cf293f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

spec/rolify/shared_examples/shared_examples_for_dynamic.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
it { should respond_to(:is_moderator_of?).with(1).arguments }
2323
it { should_not respond_to(:is_god?) }
2424

25+
it { should respond_to(:is_waiting?) }
26+
it { should_not respond_to(:is_awaiting?) }
27+
2528
it { subject.is_admin?.should be(true) }
2629
it { subject.is_admin?.should be(true) }
2730
it { subject.is_admin?.should be(true) }
@@ -49,6 +52,9 @@
4952
it { should_not respond_to(:is_god?) }
5053
it { should_not respond_to(:is_god_of?) }
5154

55+
it { should respond_to(:is_waiting?) }
56+
it { should_not respond_to(:is_awaiting?) }
57+
5258
it { subject.is_moderator?.should be(false) }
5359
it { subject.is_moderator_of?(Forum).should be(false) }
5460
it { subject.is_moderator_of?(Forum.first).should be(true) }
@@ -80,6 +86,9 @@
8086
it { should_not respond_to(:is_god?) }
8187
it { should_not respond_to(:is_god_of?) }
8288

89+
it { should respond_to(:is_waiting?) }
90+
it { should_not respond_to(:is_awaiting?) }
91+
8392
it { subject.is_manager?.should be(false) }
8493
it { subject.is_manager_of?(Forum).should be(true) }
8594
it { subject.is_manager_of?(Forum.first).should be(true) }
@@ -127,6 +136,9 @@
127136
it { should_not respond_to(:is_god?) }
128137
it { should_not respond_to(:is_god_of?) }
129138

139+
it { should respond_to(:is_waiting?) }
140+
it { should_not respond_to(:is_awaiting?) }
141+
130142
it { subject.is_batman?.should be(false) }
131143
it { subject.is_batman_of?(Forum).should be(false) }
132144
it { subject.is_batman_of?(Forum.first).should be(false) }

spec/support/adapters/active_record.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class HumanResource < ActiveRecord::Base
3535
# Custom role and class names
3636
class Customer < ActiveRecord::Base
3737
rolify :role_cname => "Privilege"
38+
39+
def is_waiting?
40+
true
41+
end
3842
end
3943

4044
class Privilege < ActiveRecord::Base
@@ -52,6 +56,10 @@ def self.table_name_prefix
5256

5357
class Moderator < ActiveRecord::Base
5458
rolify :role_cname => "Admin::Right", :role_join_table_name => "moderators_rights"
59+
60+
def is_waiting?
61+
true
62+
end
5563
end
5664

5765
class Right < ActiveRecord::Base

0 commit comments

Comments
 (0)