sinatra 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sinatra might be problematic. Click here for more details.

Files changed (95) hide show
  1. data/CHANGELOG +1 -8
  2. data/Manifest +42 -49
  3. data/README.rdoc +430 -0
  4. data/Rakefile +22 -28
  5. data/images/404.png +0 -0
  6. data/images/500.png +0 -0
  7. data/index.html +9 -0
  8. data/lib/sinatra.rb +1144 -46
  9. data/lib/sinatra/test/methods.rb +56 -0
  10. data/lib/sinatra/test/spec.rb +10 -0
  11. data/lib/sinatra/test/unit.rb +13 -0
  12. data/sinatra.gemspec +44 -40
  13. data/test/app_test.rb +150 -0
  14. data/test/application_test.rb +175 -0
  15. data/test/builder_test.rb +101 -0
  16. data/test/custom_error_test.rb +67 -0
  17. data/test/diddy_test.rb +41 -0
  18. data/test/erb_test.rb +116 -0
  19. data/test/event_context_test.rb +15 -0
  20. data/test/events_test.rb +50 -0
  21. data/test/haml_test.rb +181 -0
  22. data/test/helper.rb +3 -16
  23. data/test/mapped_error_test.rb +61 -0
  24. data/test/public/foo.xml +1 -0
  25. data/test/rest_test.rb +16 -0
  26. data/test/sass_test.rb +57 -0
  27. data/test/sessions_test.rb +40 -0
  28. data/test/streaming_test.rb +112 -0
  29. data/test/sym_params_test.rb +19 -0
  30. data/test/template_test.rb +30 -0
  31. data/test/use_in_file_templates_test.rb +48 -0
  32. data/test/views/foo.builder +1 -0
  33. data/test/views/foo.erb +1 -0
  34. data/test/views/foo.haml +1 -0
  35. data/test/views/foo.sass +2 -0
  36. data/test/views/foo_layout.erb +2 -0
  37. data/test/views/foo_layout.haml +2 -0
  38. data/test/views/layout_test/foo.builder +1 -0
  39. data/test/views/layout_test/foo.erb +1 -0
  40. data/test/views/layout_test/foo.haml +1 -0
  41. data/test/views/layout_test/foo.sass +2 -0
  42. data/test/views/layout_test/layout.builder +3 -0
  43. data/test/views/layout_test/layout.erb +1 -0
  44. data/test/views/layout_test/layout.haml +1 -0
  45. data/test/views/layout_test/layout.sass +2 -0
  46. data/test/views/no_layout/no_layout.builder +1 -0
  47. data/test/views/no_layout/no_layout.haml +1 -0
  48. metadata +122 -98
  49. data/LICENSE +0 -22
  50. data/README +0 -100
  51. data/RakeFile +0 -35
  52. data/examples/hello/hello.rb +0 -28
  53. data/examples/hello/views/hello.erb +0 -1
  54. data/examples/todo/todo.rb +0 -38
  55. data/files/default_index.erb +0 -42
  56. data/files/error.erb +0 -9
  57. data/files/logo.png +0 -0
  58. data/files/not_found.erb +0 -52
  59. data/lib/sinatra/context.rb +0 -88
  60. data/lib/sinatra/context/renderer.rb +0 -75
  61. data/lib/sinatra/core_ext/array.rb +0 -5
  62. data/lib/sinatra/core_ext/class.rb +0 -49
  63. data/lib/sinatra/core_ext/hash.rb +0 -7
  64. data/lib/sinatra/core_ext/kernel.rb +0 -16
  65. data/lib/sinatra/core_ext/metaid.rb +0 -18
  66. data/lib/sinatra/core_ext/module.rb +0 -11
  67. data/lib/sinatra/core_ext/symbol.rb +0 -5
  68. data/lib/sinatra/dispatcher.rb +0 -27
  69. data/lib/sinatra/dsl.rb +0 -176
  70. data/lib/sinatra/environment.rb +0 -15
  71. data/lib/sinatra/event.rb +0 -238
  72. data/lib/sinatra/irb.rb +0 -56
  73. data/lib/sinatra/loader.rb +0 -31
  74. data/lib/sinatra/logger.rb +0 -22
  75. data/lib/sinatra/options.rb +0 -49
  76. data/lib/sinatra/rack_ext/request.rb +0 -15
  77. data/lib/sinatra/route.rb +0 -65
  78. data/lib/sinatra/server.rb +0 -57
  79. data/lib/sinatra/sessions.rb +0 -21
  80. data/lib/sinatra/test_methods.rb +0 -55
  81. data/site/index.htm +0 -104
  82. data/site/index.html +0 -104
  83. data/site/logo.png +0 -0
  84. data/test/sinatra/dispatcher_test.rb +0 -91
  85. data/test/sinatra/event_test.rb +0 -46
  86. data/test/sinatra/renderer_test.rb +0 -47
  87. data/test/sinatra/request_test.rb +0 -21
  88. data/test/sinatra/route_test.rb +0 -21
  89. data/test/sinatra/static_files/foo.txt +0 -1
  90. data/test/sinatra/static_files_test.rb +0 -48
  91. data/test/sinatra/url_test.rb +0 -18
  92. data/vendor/erb/init.rb +0 -3
  93. data/vendor/erb/lib/erb.rb +0 -41
  94. data/vendor/haml/init.rb +0 -3
  95. data/vendor/haml/lib/haml.rb +0 -41
@@ -0,0 +1,56 @@
1
+ class Rack::MockRequest
2
+ class << self
3
+ alias :env_for_without_env :env_for
4
+ def env_for(uri = "", opts = {})
5
+ env = { 'HTTP_USER_AGENT' => opts.delete(:agent) }
6
+ env_for_without_env(uri, opts).merge(env)
7
+ end
8
+ end
9
+ end
10
+
11
+ module Sinatra
12
+
13
+ module Test
14
+
15
+ module Methods
16
+
17
+ def easy_env_map
18
+ {
19
+ :accept => 'HTTP_ACCEPT',
20
+ :agent => 'HTTP_AGENT',
21
+ :host => 'HTTP_POST'
22
+ }
23
+ end
24
+
25
+ def map_easys(params)
26
+ easy_env_map.inject(params.dup) do |m, (from, to)|
27
+ m[to] = m.delete(from) if m.has_key?(from); m
28
+ end
29
+ end
30
+
31
+ %w(get head post put delete).each do |m|
32
+ define_method("#{m}_it") do |path, *args|
33
+ request = Rack::MockRequest.new(Sinatra.build_application)
34
+ env, input = if args.size == 2
35
+ [args.last, args.first]
36
+ elsif args.size == 1
37
+ data = args.first
38
+ data.is_a?(Hash) ? [data.delete(:env), data.to_params] : [nil, data]
39
+ end
40
+ @response = request.request(m.upcase, path, {:input => input}.merge(env || {}))
41
+ end
42
+ end
43
+
44
+ def follow!
45
+ get_it(@response.location)
46
+ end
47
+
48
+ def method_missing(name, *args)
49
+ @response.send(name, *args)
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/unit'
2
+ require 'test/spec'
3
+
4
+ class Test::Unit::TestCase
5
+
6
+ def should
7
+ @response.should
8
+ end
9
+
10
+ end
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/methods'
3
+
4
+ Test::Unit::TestCase.send(:include, Sinatra::Test::Methods)
5
+
6
+ Sinatra::Application.default_options.merge!(
7
+ :env => :test,
8
+ :run => false,
9
+ :raise_errors => true,
10
+ :logging => false
11
+ )
12
+
13
+ Sinatra.application.options = nil
@@ -1,59 +1,63 @@
1
1
 
2
- # Gem::Specification for Sinatra-0.1.7
2
+ # Gem::Specification for Sinatra-0.2.0
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{sinatra}
7
- s.version = "0.1.7"
8
- s.date = %q{2007-10-23}
9
- s.summary = %q{Sinatra is a classy web-framework dressed in a DSL}
10
- s.email = %q{blake.mizerany@gmail.com}
11
- s.homepage = %q{http://sinatra.rubyforge.org/}
12
- s.rubyforge_project = %q{sinatra}
13
- s.description = %q{Sinatra is a classy web-framework dressed in a DSL}
14
- s.has_rdoc = true
7
+ s.version = "0.2.0"
8
+
9
+ s.specification_version = 2 if s.respond_to? :specification_version=
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
15
12
  s.authors = ["Blake Mizerany"]
16
- s.files = ["CHANGELOG", "examples/hello/hello.rb", "examples/hello/views/hello.erb", "examples/todo/todo.rb", "files/default_index.erb", "files/error.erb", "files/logo.png", "files/not_found.erb", "lib/sinatra/context/renderer.rb", "lib/sinatra/context.rb", "lib/sinatra/core_ext/array.rb", "lib/sinatra/core_ext/class.rb", "lib/sinatra/core_ext/hash.rb", "lib/sinatra/core_ext/kernel.rb", "lib/sinatra/core_ext/metaid.rb", "lib/sinatra/core_ext/module.rb", "lib/sinatra/core_ext/symbol.rb", "lib/sinatra/dispatcher.rb", "lib/sinatra/dsl.rb", "lib/sinatra/environment.rb", "lib/sinatra/event.rb", "lib/sinatra/irb.rb", "lib/sinatra/loader.rb", "lib/sinatra/logger.rb", "lib/sinatra/options.rb", "lib/sinatra/rack_ext/request.rb", "lib/sinatra/route.rb", "lib/sinatra/server.rb", "lib/sinatra/sessions.rb", "lib/sinatra/test_methods.rb", "lib/sinatra.rb", "LICENSE", "Manifest", "RakeFile", "README", "site/index.htm", "site/index.html", "site/logo.png", "test/helper.rb", "test/sinatra/dispatcher_test.rb", "test/sinatra/event_test.rb", "test/sinatra/renderer_test.rb", "test/sinatra/request_test.rb", "test/sinatra/route_test.rb", "test/sinatra/static_files/foo.txt", "test/sinatra/static_files_test.rb", "test/sinatra/url_test.rb", "vendor/erb/init.rb", "vendor/erb/lib/erb.rb", "vendor/haml/init.rb", "vendor/haml/lib/haml.rb", "Rakefile", "sinatra.gemspec"]
17
- s.test_files = ["test/sinatra/dispatcher_test.rb", "test/sinatra/event_test.rb", "test/sinatra/renderer_test.rb", "test/sinatra/request_test.rb", "test/sinatra/route_test.rb", "test/sinatra/static_files_test.rb", "test/sinatra/url_test.rb"]
13
+ s.date = %q{2008-04-11}
14
+ s.description = %q{Classy web-development dressed in a DSL}
15
+ s.email = %q{}
16
+ s.extra_rdoc_files = ["CHANGELOG", "lib/sinatra/test/methods.rb", "lib/sinatra/test/spec.rb", "lib/sinatra/test/unit.rb", "lib/sinatra.rb", "README.rdoc"]
17
+ s.files = ["CHANGELOG", "images/404.png", "images/500.png", "index.html", "lib/sinatra/test/methods.rb", "lib/sinatra/test/spec.rb", "lib/sinatra/test/unit.rb", "lib/sinatra.rb", "README.rdoc", "test/app_test.rb", "test/application_test.rb", "test/builder_test.rb", "test/custom_error_test.rb", "test/diddy_test.rb", "test/erb_test.rb", "test/event_context_test.rb", "test/events_test.rb", "test/haml_test.rb", "test/helper.rb", "test/mapped_error_test.rb", "test/public/foo.xml", "test/rest_test.rb", "test/sass_test.rb", "test/sessions_test.rb", "test/streaming_test.rb", "test/sym_params_test.rb", "test/template_test.rb", "test/use_in_file_templates_test.rb", "test/views/foo.builder", "test/views/foo.erb", "test/views/foo.haml", "test/views/foo.sass", "test/views/foo_layout.erb", "test/views/foo_layout.haml", "test/views/layout_test/foo.builder", "test/views/layout_test/foo.erb", "test/views/layout_test/foo.haml", "test/views/layout_test/foo.sass", "test/views/layout_test/layout.builder", "test/views/layout_test/layout.erb", "test/views/layout_test/layout.haml", "test/views/layout_test/layout.sass", "test/views/no_layout/no_layout.builder", "test/views/no_layout/no_layout.haml", "Manifest", "sinatra.gemspec", "Rakefile"]
18
+ s.has_rdoc = true
19
+ s.homepage = %q{http://www.sinatrarb.com}
20
+ s.post_install_message = %q{*** Be sure to checkout the site for helpful tips! sinatrarb.com ***}
21
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra", "--main", "README.rdoc"]
22
+ s.require_paths = ["lib"]
23
+ s.rubyforge_project = %q{sinatra}
24
+ s.rubygems_version = %q{1.0.1}
25
+ s.summary = %q{Classy web-development dressed in a DSL}
26
+ s.test_files = ["test/app_test.rb", "test/application_test.rb", "test/builder_test.rb", "test/custom_error_test.rb", "test/diddy_test.rb", "test/erb_test.rb", "test/event_context_test.rb", "test/events_test.rb", "test/haml_test.rb", "test/mapped_error_test.rb", "test/rest_test.rb", "test/sass_test.rb", "test/sessions_test.rb", "test/streaming_test.rb", "test/sym_params_test.rb", "test/template_test.rb", "test/use_in_file_templates_test.rb"]
27
+
18
28
  s.add_dependency(%q<mongrel>, [">= 1.0.1"])
19
- s.add_dependency(%q<rack>, [">= 0.2.0"])
29
+ s.add_dependency(%q<rack>, [">= 0", "= 0.3.0"])
20
30
  end
21
31
 
22
32
 
23
33
  # # Original Rakefile source (requires the Echoe gem):
24
34
  #
35
+ # require 'rubygems'
25
36
  # require 'rake/testtask'
26
- # require 'ftools'
27
- #
28
- # Version = '0.1.0'
37
+ # require 'rake/rdoctask'
38
+ # require 'echoe'
29
39
  #
30
- # begin
31
- # require 'rubygems'
32
- # gem 'echoe'
33
- # ENV['RUBY_FLAGS'] = ""
34
- # require 'echoe'
40
+ # task :default => :test
35
41
  #
36
- # Echoe.new('sinatra') do |p|
37
- # p.rubyforge_name = 'sinatra'
38
- # p.dependencies = ['mongrel >=1.0.1', 'rack >=0.2.0']
39
- # p.summary = "Sinatra is a classy web-framework dressed in a DSL"
40
- # p.description = "Sinatra is a classy web-framework dressed in a DSL"
41
- # p.url = "http://sinatra.rubyforge.org/"
42
- # p.author = 'Blake Mizerany'
43
- # p.email = "blake.mizerany@gmail.com"
44
- # p.test_pattern = 'test/**/*_test.rb'
45
- # p.include_rakefile = true
46
- # p.rdoc_pattern = ['README', 'LICENSE'] + Dir.glob('lib/**/*.rb') + Dir.glob('vendor/**/*.rb')
47
- # p.docs_host = "bmizerany@rubyforge.org:/var/www/gforge-projects/"
48
- # end
42
+ # Rake::RDocTask.new do |rd|
43
+ # rd.main = "README.rdoc"
44
+ # rd.rdoc_files += ["README.rdoc"]
45
+ # rd.rdoc_files += Dir.glob("lib/**/*.rb")
46
+ # rd.rdoc_dir = 'doc'
47
+ # end
49
48
  #
50
- # rescue LoadError
49
+ # Rake::TestTask.new do |t|
50
+ # ENV['SINATRA_ENV'] = 'test'
51
+ # t.pattern = File.dirname(__FILE__) + "/test/*_test.rb"
51
52
  # end
52
53
  #
53
- # desc 'Clear all the log files from here down'
54
- # task :remove_logs do
55
- # Dir.glob(Dir.pwd + '/**/*.log') do |logfile|
56
- # FileUtils.rm(logfile)
57
- # puts 'Removed: %s' % logfile
58
- # end
54
+ # Echoe.new("sinatra") do |p|
55
+ # p.author = "Blake Mizerany"
56
+ # p.summary = "Classy web-development dressed in a DSL"
57
+ # p.url = "http://www.sinatrarb.com"
58
+ # p.docs_host = "sinatrarb.com:/var/www/blakemizerany.com/public/docs/"
59
+ # p.dependencies = ["mongrel >=1.0.1", "rack >= 0.3.0"]
60
+ # p.install_message = "*** Be sure to checkout the site for helpful tips! sinatrarb.com ***"
61
+ # p.include_rakefile = true
59
62
  # end
63
+ #
@@ -0,0 +1,150 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ context "Sinatra" do
4
+
5
+ setup do
6
+ Sinatra.application = nil
7
+ end
8
+
9
+ specify "should handle result of nil" do
10
+ get '/' do
11
+ nil
12
+ end
13
+
14
+ get_it '/'
15
+ should.be.ok
16
+ body.should == ''
17
+ end
18
+
19
+ specify "handles events" do
20
+ get '/:name' do
21
+ 'Hello ' + params["name"]
22
+ end
23
+
24
+ get_it '/Blake'
25
+
26
+ should.be.ok
27
+ body.should.equal 'Hello Blake'
28
+ end
29
+
30
+ specify "follows redirects" do
31
+ get '/' do
32
+ redirect '/blake'
33
+ end
34
+
35
+ get '/blake' do
36
+ 'Mizerany'
37
+ end
38
+
39
+ get_it '/'
40
+ should.be.redirection
41
+ body.should.equal ''
42
+
43
+ follow!
44
+ should.be.ok
45
+ body.should.equal 'Mizerany'
46
+ end
47
+
48
+ specify "renders a body with a redirect" do
49
+ Sinatra::EventContext.any_instance.expects(:foo).returns('blah')
50
+ get "/" do
51
+ redirect 'foo', :foo
52
+ end
53
+ get_it '/'
54
+ should.be.redirection
55
+ headers['Location'].should.equal 'foo'
56
+ body.should.equal 'blah'
57
+ end
58
+
59
+ specify "body sets content and ends event" do
60
+
61
+ Sinatra::EventContext.any_instance.expects(:foo).never
62
+
63
+ get '/set_body' do
64
+ stop 'Hello!'
65
+ stop 'World!'
66
+ foo
67
+ end
68
+
69
+ get_it '/set_body'
70
+
71
+ should.be.ok
72
+ body.should.equal 'Hello!'
73
+
74
+ end
75
+
76
+ specify "should set status then call helper with a var" do
77
+ Sinatra::EventContext.any_instance.expects(:foo).once.with(1).returns('bah!')
78
+
79
+ get '/set_body' do
80
+ stop [404, [:foo, 1]]
81
+ end
82
+
83
+ get_it '/set_body'
84
+
85
+ should.be.not_found
86
+ body.should.equal 'bah!'
87
+
88
+ end
89
+
90
+ specify "delegates HEAD requests to GET handlers" do
91
+ get '/invisible' do
92
+ "I am invisible to the world"
93
+ end
94
+
95
+ head_it '/invisible'
96
+ should.be.ok
97
+ body.should.not.equal "I am invisible to the world"
98
+ body.should.equal ''
99
+ end
100
+
101
+
102
+ specify "put'n with POST" do
103
+ put '/' do
104
+ 'puted'
105
+ end
106
+ post_it '/', :_method => 'PUT'
107
+ assert_equal 'puted', body
108
+ end
109
+
110
+ specify "put'n wth PUT" do
111
+ put '/' do
112
+ 'puted'
113
+ end
114
+ put_it '/'
115
+ assert_equal 'puted', body
116
+ end
117
+
118
+ # Some Ajax libraries downcase the _method parameter value. Make
119
+ # sure we can handle that.
120
+ specify "put'n with POST and lowercase _method param" do
121
+ put '/' do
122
+ 'puted'
123
+ end
124
+ post_it '/', :_method => 'put'
125
+ body.should.equal 'puted'
126
+ end
127
+
128
+ # Ignore any _method parameters specified in GET requests or on the query string in POST requests.
129
+ specify "not put'n with GET" do
130
+ get '/' do
131
+ 'getted'
132
+ end
133
+ get_it '/', :_method => 'put'
134
+ should.be.ok
135
+ body.should.equal 'getted'
136
+ end
137
+
138
+ specify "_method query string parameter ignored on POST" do
139
+ post '/' do
140
+ 'posted'
141
+ end
142
+ put '/' do
143
+ 'booo'
144
+ end
145
+ post_it "/?_method=PUT"
146
+ should.be.ok
147
+ body.should.equal 'posted'
148
+ end
149
+
150
+ end
@@ -0,0 +1,175 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ require 'uri'
4
+
5
+ class TesterWithEach
6
+ def each
7
+ yield 'foo'
8
+ yield 'bar'
9
+ yield 'baz'
10
+ end
11
+ end
12
+
13
+ context "Looking up a request" do
14
+
15
+ setup do
16
+ Sinatra.application = nil
17
+ end
18
+
19
+ specify "returns what's at the end" do
20
+ block = Proc.new { 'Hello' }
21
+ get '/', &block
22
+
23
+ result = Sinatra.application.lookup(
24
+ Rack::Request.new(
25
+ 'REQUEST_METHOD' => 'GET',
26
+ 'PATH_INFO' => '/'
27
+ )
28
+ )
29
+
30
+ result.should.not.be.nil
31
+ result.block.should.be block
32
+ end
33
+
34
+ specify "takes params in path" do
35
+ block = Proc.new { 'Hello' }
36
+ get '/:foo', &block
37
+
38
+ result = Sinatra.application.lookup(
39
+ Rack::Request.new(
40
+ 'REQUEST_METHOD' => 'GET',
41
+ 'PATH_INFO' => '/bar'
42
+ )
43
+ )
44
+
45
+ result.should.not.be.nil
46
+ result.block.should.be block
47
+ result.params.should.equal "foo" => 'bar'
48
+ end
49
+
50
+ end
51
+
52
+ context "An app returns" do
53
+
54
+ setup do
55
+ Sinatra.application = nil
56
+ end
57
+
58
+ specify "404 if no events found" do
59
+ request = Rack::MockRequest.new(@app)
60
+ get_it '/'
61
+ should.be.not_found
62
+ body.should.equal '<h1>Not Found</h1>'
63
+ end
64
+
65
+ specify "200 if success" do
66
+ get '/' do
67
+ 'Hello World'
68
+ end
69
+ get_it '/'
70
+ should.be.ok
71
+ body.should.equal 'Hello World'
72
+ end
73
+
74
+ specify "an objects result from each if it has it" do
75
+
76
+ get '/' do
77
+ TesterWithEach.new
78
+ end
79
+
80
+ get_it '/'
81
+ should.be.ok
82
+ body.should.equal 'foobarbaz'
83
+
84
+ end
85
+
86
+ specify "the body set if set before the last" do
87
+
88
+ get '/' do
89
+ body 'Blake'
90
+ 'Mizerany'
91
+ end
92
+
93
+ get_it '/'
94
+ should.be.ok
95
+ body.should.equal 'Blake'
96
+
97
+ end
98
+
99
+ end
100
+
101
+ context "Events in an app" do
102
+
103
+ setup do
104
+ Sinatra.application = nil
105
+ end
106
+
107
+ specify "evaluate in a clean context" do
108
+ helpers do
109
+ def foo
110
+ 'foo'
111
+ end
112
+ end
113
+
114
+ get '/foo' do
115
+ foo
116
+ end
117
+
118
+ get_it '/foo'
119
+ should.be.ok
120
+ body.should.equal 'foo'
121
+ end
122
+
123
+ specify "get access to request, response, and params" do
124
+ get '/:foo' do
125
+ params["foo"] + params["bar"]
126
+ end
127
+
128
+ get_it '/foo?bar=baz'
129
+ should.be.ok
130
+ body.should.equal 'foobaz'
131
+ end
132
+
133
+ specify "can filters by agent" do
134
+
135
+ get '/', :agent => /Windows/ do
136
+ request.env['HTTP_USER_AGENT']
137
+ end
138
+
139
+ get_it '/', :env => { :agent => 'Windows' }
140
+ should.be.ok
141
+ body.should.equal 'Windows'
142
+
143
+ get_it '/', :agent => 'Mac'
144
+ should.not.be.ok
145
+
146
+ end
147
+
148
+ specify "can filters by agent" do
149
+
150
+ get '/', :agent => /Windows (NT)/ do
151
+ params[:agent].first
152
+ end
153
+
154
+ get_it '/', :env => { :agent => 'Windows NT' }
155
+
156
+ body.should.equal 'NT'
157
+
158
+ end
159
+
160
+ specify "can deal with spaces in paths" do
161
+
162
+ path = '/path with spaces'
163
+
164
+ get path do
165
+ "Look ma, a path with spaces!"
166
+ end
167
+
168
+ get_it URI.encode(path)
169
+
170
+ body.should.equal "Look ma, a path with spaces!"
171
+ end
172
+
173
+ end
174
+
175
+