test/context_access_test.rb in surrounded-0.8.4 vs test/context_access_test.rb in surrounded-0.9.0
- old
+ new
@@ -21,10 +21,14 @@
disallow :check_disallow_behavior do
user.special
end
+ trigger :unguarded do
+ # used for disallow check
+ end
+
role :user do
def special
'special user method'
end
end
@@ -61,7 +65,19 @@
assert_match(/access to FilteredContext#if_ready is not allowed/i, error.message)
end
it 'applies roles in disallow blocks' do
assert_equal 'special user method', context.disallow_check_disallow_behavior?
+ end
+
+ it 'lets you ask if the object will allow a method' do
+ assert context.allow?(:unguarded)
+ refute context.allow?(:check_disallow_behavior)
+ end
+
+ it 'complains if you ask about an undefined method' do
+ error = assert_raises(NoMethodError){
+ context.allow?(:not_a_defined_method)
+ }
+ assert_match(/undefined method `not_a_defined_method' for #<#{context.class}/, error.message)
end
end
\ No newline at end of file