Sha256: b34bd0366734e96af1604561e1528d2f6346c9241f87abd525078e25b668e916

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

require 'spec_helper'

describe Grape::Middleware::Prefixer do
  let(:app){ lambda{|env| [200, {}, env['PATH_INFO']]} }
  subject{ Grape::Middleware::Prefixer.new(app, @options || {}) }

  it 'should lop off a prefix (without a slash)' do
    @options = {:prefix => 'monkey'}
    subject.call('PATH_INFO' => '/monkey/beeswax').last.should == '/beeswax'
  end
  
  it 'should lop off a prefix (with a slash)' do
    @options = {:prefix => '/banana'}
    subject.call('PATH_INFO' => '/banana/peel').last.should == '/peel'
  end
  
  it 'should not lop off non-prefixes' do
    @options = {:prefix => '/monkey'}
    subject.call('PATH_INFO' => '/banana/peel').last.should == '/banana/peel'
  end
  
  it 'should pass through unaltered if there is no prefix' do
    subject.call('PATH_INFO' => '/awesome').last.should == '/awesome'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grape-0.0.0.alpha.2 spec/grape/middleware/prefixer_spec.rb
grape-0.0.0.alpha.1 spec/grape/middleware/prefixer_spec.rb