Sha256: b932b9ad63ee71af145c86e2f5bb83716c1453e2df532822f6c034c458b85ab6

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

require 'backports'
require_relative 'spec_helper'

describe Sinatra::MultiRoute do

  it 'does not break normal routing' do
    mock_app do
      register Sinatra::MultiRoute
      get('/') { 'normal' }
    end

    get('/').should be_ok
    body.should be == 'normal'
  end

  it 'supports multiple routes' do
    mock_app do
      register Sinatra::MultiRoute
      get('/foo', '/bar') { 'paths' }
    end

    get('/foo').should be_ok
    body.should be == 'paths'
    get('/bar').should be_ok
    body.should be == 'paths'
  end

  it 'triggers conditions' do
    count = 0
    mock_app do
      register Sinatra::MultiRoute
      set(:some_condition) { |_| count += 1 }
      get('/foo', '/bar', :some_condition => true) { 'paths' }
    end

    count.should be == 4
  end

  it 'supports multiple verbs' do
    mock_app do
      register Sinatra::MultiRoute
      route('PUT', 'POST', '/') { 'verb' }
    end

    post('/').should be_ok
    body.should be == 'verb'
    put('/').should be_ok
    body.should be == 'verb'
  end

  it 'takes symbols as verbs' do
    mock_app do
      register Sinatra::MultiRoute
      route(:get, '/baz') { 'symbol as verb' }
    end

    get('/baz').should be_ok
    body.should be == 'symbol as verb'
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sinatra-contrib-1.4.2 spec/multi_route_spec.rb
sinatra-contrib-1.4.1 spec/multi_route_spec.rb
sinatra-contrib-1.4.0 spec/multi_route_spec.rb
rubycut-sinatra-contrib-1.4.0 spec/multi_route_spec.rb