spec/guard_spec.rb in cuba-api-0.6.2 vs spec/guard_spec.rb in cuba-api-0.6.3

- old
+ new

@@ -79,11 +79,11 @@ guard end describe 'guarded context with nested context' do - it 'should raise error' do + it 'should response forbidden' do env = { 'PATH_INFO' => '/users/accounts', 'SCRIPT_NAME' => '/users/accounts' } user = guard.permission_for( 'users' ) do |u| u.allow_all @@ -92,11 +92,12 @@ a.parent = user a.allow_all end env[ 'REQUEST_METHOD' ] = 'GET' - lambda{ Cuba.call( env ) }.must_raise RuntimeError + status, _, _ = Cuba.call( env ) + status.must.eq 403 end it 'allow all' do env = { 'PATH_INFO' => '/users/accounts', 'SCRIPT_NAME' => '/users/accounts' } @@ -122,13 +123,12 @@ end describe 'guarded context with association' do - let( :env ) do - { 'PATH_INFO' => '/users/42', - 'SCRIPT_NAME' => '/users/42', - } + before do + env[ 'PATH_INFO' ] = '/users/42' + env[ 'SCRIPT_NAME'] = '/users/42' end it 'denies all requests without associated id' do guard.permission_for( 'users' ) do |u| u.allow_all( 42 )