Sha256: 473ff339ba7918c5cec77dab1cdcbe0aadde7934d96240079168850a42f95eaa

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe "dummy stuff" do
  before(:all) do

  end
  it 'should get default action' do
    get '/dummy/index'
    response.should be_success
  end
  
  it 'should get dynamic constraint' do
    get root_path, nil, "REMOTE_ADDR" => "127.0.0.1"
    open_session do |sess|
      sess.remote_addr = '127.0.0.1'
      get '/dummy/blocked_by_dynamic'
      response.should be_success
    end
  end
  
  context 'given a good ip' do
    around do |example|
      get root_path, nil, "REMOTE_ADDR" => "10.0.0.45"
      open_session do |sess|
        sess.remote_addr = '10.0.0.45'
        example.run
      end
    end
    
    it 'should get inline constraint' do
        get '/dummy/blocked_by_inline'
        response.should be_success
    end
    
    it 'should get block constraint' do
      get '/dummy/blocked_by_block'
      response.should be_success
    end
  end
  
  context 'given a bad ip' do
    around do |example|
      get root_path, nil, "REMOTE_ADDR" => "55.55.55.55"
      open_session do |sess|
        sess.remote_addr = '55.55.55.55'
        example.run
      end
    end
    
    it 'should not get inline constraint' do
      get '/dummy/blocked_by_inline'
      response.status.should eql 404
    end
    
    it 'should not get block constraint' do
      get '/dummy/blocked_by_block'
      response.status.should eql 404 
    end
    
    it 'should not get dynamic constraint' do
      get '/dummy/blocked_by_dynamic'
      response.status.should eql 404 
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
firewall_constraint-0.0.2 spec/requests/dummy_controller_spec.rb
firewall_constraint-0.0.1 spec/requests/dummy_controller_spec.rb