Sha256: 23f71aa6519901bb24c5cee485df1c0d4db2dbb4225852d616e5092701c60750

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Suhyo::ViewMatchers do
	include Suhyo::ControllerMatchers
	
	describe '#deny_access' do
		before :all do
			Suhyo.config.access_denied_url = 'http://test.host/access_denied'
		end
		
		before :each do
			@response = mock(:status => '200 OK', :redirect? => false, :redirect_url => nil)
		end
		
		it 'matches 403' do
			@response.stub(:status => '403 Forbidden')
			@response.should deny_access
		end
		
		it 'matches a 302 redirect to the access denied URL' do
			@response.stub(:redirect? => true, :status_code => '302 Found', :redirect_url => 'http://test.host/access_denied')
			@response.should deny_access
		end
		
		((
			(100..102).to_a +
			(200..207).to_a +
			(400..450).to_a + 
			(500..530).to_a
		) - [403]).each do |code|
			it "does not match #{code}" do
				@response.stub(:status => code.to_s + ' Code Description')
				@response.should_not deny_access
			end
		end
		
		it 'does not match a 302 redirect to anything other than the access denied URL' do
			@response.stub(:redirect? => true, :status => '302 Found', :redirect_url => 'http://test.host/private')
			@response.should_not deny_access
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
suhyo-0.0.6 spec/controller_matchers_spec.rb
suhyo-0.0.5 spec/controller_matchers_spec.rb
suhyo-0.0.3 spec/controller_matchers_spec.rb
suhyo-0.0.2 spec/controller_matchers_spec.rb
suhyo-0.0.1 spec/controller_matchers_spec.rb