Sha256: 0ed27128f0d0d4a335d248019250ec7b03cd2bdf4c44b59171b0c8309251000b

Contents?: true

Size: 739 Bytes

Versions: 8

Compression:

Stored size: 739 Bytes

Contents

require 'spec/helper'
require 'ramaze/contrib/addressable_route'

class SpecAddressableRoute < Ramaze::Controller
  map '/'

  def order__show(*args)
    [args, request.params].inspect
  end
end

describe 'addressable routing' do
  behaves_like :rack_test

  RAR = Ramaze::AddressableRoute
  RAR.map('/customer/{customer_id}/order/{order_id}', '/order/show')

  Ramaze.middleware! :spec do |m|
    m.use RAR
    m.run Ramaze::AppMap
  end

  it 'should route based on URI template' do
    body = eval(get('/customer/12/order/15').body)
    body.should == [[], {'customer_id' => '12', 'order_id' => '15'}]
  end

  it "should not route URIs that don't match" do
    get('/order/nothing/15')
    last_response.status.should == 404
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
manveru-ramaze-2009.06.04 spec/contrib/addressable_route.rb
manveru-ramaze-2009.06.12 spec/contrib/addressable_route.rb
manveru-ramaze-2009.06 spec/contrib/addressable_route.rb
rjspotter-ramaze-2009.06.29 spec/contrib/addressable_route.rb
rjspotter-ramaze-2009.06.31 spec/contrib/addressable_route.rb
ramaze-2009.06 spec/contrib/addressable_route.rb
ramaze-2009.06.12 spec/contrib/addressable_route.rb
ramaze-2009.06.04 spec/contrib/addressable_route.rb