Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (39 sloc) 1.312 kb
22ada43 @rkh import sinatra-decompile
authored
1 require 'backports'
2 require_relative 'spec_helper'
3
4 RSpec::Matchers.define :decompile do |path|
5 match do |app|
6 @compiled, @keys = app.send :compile, path
7 @decompiled = app.decompile(@compiled, @keys)
8 @decompiled.should == path
9 end
10
11 failure_message_for_should do |app|
12 values = [app, @compiled, @keys, path, @decompiled].map(&:inspect)
13 "expected %s to decompile %s with %s to %s, but was %s" % values
14 end
15 end
16
17 describe Sinatra::Decompile do
18 subject { Sinatra::Application }
19 it { should decompile("") }
20 it { should decompile("/") }
21 it { should decompile("/?") }
22 it { should decompile("/foo") }
23 it { should decompile("/:name") }
24 it { should decompile("/:name?") }
25 it { should decompile("/:foo/:bar") }
26 it { should decompile("/page/:id/edit") }
27 it { should decompile("/hello/*") }
28 it { should decompile("/*/foo/*") }
29 it { should decompile("*") }
30 it { should decompile(":name.:format") }
7c4eb00 @rkh have decompile work properly with Sinatra 1.3
authored
31 it { should decompile("a b") }
32 it { should decompile("a+b") }
22ada43 @rkh import sinatra-decompile
authored
33 it { should decompile(/./) }
34 it { should decompile(/f(oo)/) }
35 it { should decompile(/ba+r/) }
36
37 it 'just returns strings' do
38 subject.decompile('/foo').should == '/foo'
39 end
40
41 it 'just decompile simple regexps without keys' do
42 subject.decompile(%r{/foo}).should == '/foo'
43 end
44 end
Something went wrong with that request. Please try again.