Sha256: e5b468b1e56c2f0713471858f89f266dded0bd7a0752bcc6664c570f2c6c4c6a

Contents?: true

Size: 939 Bytes

Versions: 24

Compression:

Stored size: 939 Bytes

Contents

require 'spec_helper'

describe "RedirectRouter" do
  before do
    @router = Rad::Router::BasicRouter.new
  end
  
  it "skip" do
    @router.skip(/\/fs/)
    
    halt = catch :halt do
      @router.decode("/users/all", {})
      nil
    end
    halt.should be_nil
    
    halt = catch :halt do
      @router.decode("/fs/user/avatar", {})
      nil
    end
    halt.should_not be_nil
  end
    
  it "redirect" do            
    workspace = Rad::Conveyors::Workspace.new
    workspace.response = Rad::Http::Response.new
    @router.stub!(:workspace).and_return(workspace)
    
    @router.redirect(/^\/([^\/]+)$/, "/\\1/Items")
    
    halt = catch :halt do
      @router.decode("/default/Items", {})
      nil
    end
    halt.should be_nil
    
    halt = catch :halt do
      @router.decode("/default", {})
      nil
    end
    halt.should_not be_nil
    workspace.response.headers['Location'].should == '/default/Items'
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rad_core-0.2.6 spec/router/basic_router_spec.rb
rad_core-0.2.5 spec/router/basic_router_spec.rb
rad_core-0.2.4 spec/router/basic_router_spec.rb
rad_core-0.2.3 spec/router/basic_router_spec.rb
rad_core-0.2.2 spec/router/basic_router_spec.rb
rad_core-0.2.1 spec/router/basic_router_spec.rb
rad_core-0.2.0 spec/router/basic_router_spec.rb
rad_core-0.0.30 spec/router/basic_router_spec.rb
rad_core-0.0.29 spec/router/basic_router_spec.rb
rad_core-0.0.28 spec/router/basic_router_spec.rb
rad_core-0.0.27 spec/router/basic_router_spec.rb
rad_core-0.0.26 spec/router/basic_router_spec.rb
rad_core-0.0.25 spec/router/basic_router_spec.rb
rad_core-0.0.24 spec/router/basic_router_spec.rb
rad_core-0.0.23 spec/router/basic_router_spec.rb
rad_core-0.0.22 spec/router/basic_router_spec.rb
rad_core-0.0.21 spec/router/basic_router_spec.rb
rad_core-0.0.20 spec/router/basic_router_spec.rb
rad_core-0.0.19 spec/router/basic_router_spec.rb
rad_core-0.0.18 spec/router/basic_router_spec.rb