test/context_access_test.rb in surrounded-0.8.1 vs test/context_access_test.rb in surrounded-0.8.2

- old
+ new

@@ -43,13 +43,22 @@ it 'excludes triggers when not allowed' do refute context.triggers.include?(:if_ready) end - it 'raises errors when trigger method not allowed' do - error = assert_raises(::Surrounded::Context::AccessError){ + it 'raises error specific to the context class when trigger method not allowed' do + error = assert_raises(::FilteredContext::AccessError){ context.if_ready } + assert_match(/access to FilteredContext#if_ready is not allowed/i, error.message) + end + + it 'supports rescuing from Surrounded defined error when trigger method not allowed' do + begin + context.if_ready + rescue ::Surrounded::Context::AccessError => error + assert "rescued!" + end 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? \ No newline at end of file