Sha256: d59d94f1a6d1eb9511eb42a861ee90550419c576f402d7e4f192eced373b1fcc
Contents?: true
Size: 939 Bytes
Versions: 1
Compression:
Stored size: 939 Bytes
Contents
require 'test_helper' require 'minitest/mock' class FilteredContext extend Surrounded::Context protect_triggers initialize :user, :other_user trigger :if_ready do 'ready' end disallow :if_ready do user.name != 'Amy' end end describe Surrounded::Context, 'access control' do let(:user){ User.new("Jim") } let(:other_user){ User.new("Guille") } let(:context){ FilteredContext.new(user, other_user) } it 'includes triggers when allowed' do context.stub(:disallow_if_ready?, false) do assert context.triggers.include?(:if_ready) end end 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){ context.if_ready } assert_match(/access to FilteredContext#if_ready is not allowed/i, error.message) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
surrounded-0.7.1 | test/context_access_test.rb |