Sha256: f7a8170c181c2653e51d463976274ddadfaeed0a6dcba73f52e21ee6c539f425

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

require 'kontrol'

describe Kontrol::Router do

  before :each do
    @router = Kontrol::Router.new
  end

  def request(env)
    Rack::Request.new(env)
  end
  
  it "should find a route" do
    @router.test '/test'
    route = @router.__find__(:test)

    route.name.should == :test
    route.pattern.should == '/test'
  end

  it "should recognize a route" do
    request = request('PATH_INFO' => '/test')    
    
    @router.test '/test'
    route, match = @router.__recognize__(request)

    route.name.should == :test
    route.pattern.should == '/test'
  end

  it "should recognize routes in right order" do
    request = request('PATH_INFO' => '/test')
    
    @router.root '/'
    @router.test '/test'
    
    route, match = @router.__recognize__(request)

    route.name.should == :root
    route.pattern.should == '/'
  end
  
  it "should not recognize a not matching route" do
    request = request('PATH_INFO' => '/test')
    
    @router.root '/other'
    
    route, match = @router.__recognize__(request)

    route.should be_nil
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
georgi-kontrol-0.2 test/router_spec.rb
georgi-kontrol-0.3 test/router_spec.rb
kontrol-0.4 test/router_spec.rb
kontrol-0.3.3 test/router_spec.rb
kontrol-0.3.2 test/router_spec.rb
kontrol-0.3.1 test/router_spec.rb
kontrol-0.3 test/router_spec.rb