sinatra 0.3.3 → 0.9.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.
- data/AUTHORS +40 -0
- data/CHANGES +189 -0
- data/README.rdoc +146 -117
- data/Rakefile +33 -10
- data/{test → compat}/app_test.rb +11 -10
- data/{test → compat}/application_test.rb +10 -5
- data/compat/builder_test.rb +101 -0
- data/{test → compat}/custom_error_test.rb +0 -0
- data/compat/erb_test.rb +136 -0
- data/{test → compat}/events_test.rb +16 -3
- data/compat/filter_test.rb +30 -0
- data/compat/haml_test.rb +233 -0
- data/compat/helper.rb +30 -0
- data/compat/mapped_error_test.rb +72 -0
- data/{test → compat}/pipeline_test.rb +9 -4
- data/{test → compat}/public/foo.xml +0 -0
- data/compat/sass_test.rb +57 -0
- data/{test → compat}/sessions_test.rb +0 -0
- data/{test → compat}/streaming_test.rb +4 -1
- data/{test → compat}/sym_params_test.rb +0 -0
- data/{test → compat}/template_test.rb +0 -0
- data/{test → compat}/use_in_file_templates_test.rb +0 -0
- data/{test → compat}/views/foo.builder +0 -0
- data/{test → compat}/views/foo.erb +0 -0
- data/{test → compat}/views/foo.haml +0 -0
- data/{test → compat}/views/foo.sass +0 -0
- data/{test → compat}/views/foo_layout.erb +0 -0
- data/{test → compat}/views/foo_layout.haml +0 -0
- data/{test → compat}/views/layout_test/foo.builder +0 -0
- data/{test → compat}/views/layout_test/foo.erb +0 -0
- data/{test → compat}/views/layout_test/foo.haml +0 -0
- data/{test → compat}/views/layout_test/foo.sass +0 -0
- data/{test → compat}/views/layout_test/layout.builder +0 -0
- data/{test → compat}/views/layout_test/layout.erb +0 -0
- data/{test → compat}/views/layout_test/layout.haml +0 -0
- data/{test → compat}/views/layout_test/layout.sass +0 -0
- data/{test → compat}/views/no_layout/no_layout.builder +0 -0
- data/{test → compat}/views/no_layout/no_layout.haml +0 -0
- data/lib/sinatra.rb +6 -1484
- data/lib/sinatra/base.rb +838 -0
- data/lib/sinatra/compat.rb +239 -0
- data/{images → lib/sinatra/images}/404.png +0 -0
- data/{images → lib/sinatra/images}/500.png +0 -0
- data/lib/sinatra/main.rb +48 -0
- data/lib/sinatra/test.rb +114 -0
- data/lib/sinatra/test/bacon.rb +17 -0
- data/lib/sinatra/test/rspec.rb +7 -8
- data/lib/sinatra/test/spec.rb +3 -4
- data/lib/sinatra/test/unit.rb +3 -5
- data/sinatra.gemspec +68 -35
- data/test/base_test.rb +68 -0
- data/test/builder_test.rb +50 -87
- data/test/data/reload_app_file.rb +3 -0
- data/test/erb_test.rb +38 -124
- data/test/filter_test.rb +27 -22
- data/test/haml_test.rb +51 -216
- data/test/helper.rb +22 -6
- data/test/helpers_test.rb +361 -0
- data/test/mapped_error_test.rb +137 -49
- data/test/middleware_test.rb +58 -0
- data/test/options_test.rb +97 -0
- data/test/reload_test.rb +61 -0
- data/test/request_test.rb +18 -0
- data/test/result_test.rb +88 -0
- data/test/routing_test.rb +391 -0
- data/test/sass_test.rb +27 -48
- data/test/sinatra_test.rb +13 -0
- data/test/static_test.rb +57 -0
- data/test/templates_test.rb +88 -0
- data/test/views/hello.builder +1 -0
- data/test/views/hello.erb +1 -0
- data/test/views/hello.haml +1 -0
- data/test/views/hello.sass +2 -0
- data/test/views/hello.test +1 -0
- data/test/views/layout2.builder +3 -0
- data/test/views/layout2.erb +2 -0
- data/test/views/layout2.haml +2 -0
- data/test/views/layout2.test +1 -0
- metadata +80 -48
- data/ChangeLog +0 -96
- data/lib/sinatra/test/methods.rb +0 -76
- data/test/event_context_test.rb +0 -15
data/lib/sinatra/test/methods.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
module Sinatra
|
2
|
-
|
3
|
-
module Test
|
4
|
-
|
5
|
-
module Methods
|
6
|
-
include Rack::Utils
|
7
|
-
|
8
|
-
ENV_KEY_NAMES = {
|
9
|
-
:accept => "HTTP_ACCEPT",
|
10
|
-
:agent => "HTTP_USER_AGENT",
|
11
|
-
:host => "HTTP_HOST",
|
12
|
-
:session => "HTTP_COOKIE",
|
13
|
-
:cookies => "HTTP_COOKIE",
|
14
|
-
:content_type => "CONTENT_TYPE"
|
15
|
-
}
|
16
|
-
|
17
|
-
def session(data, key = 'rack.session')
|
18
|
-
data = data.from_params if data.respond_to?(:from_params)
|
19
|
-
"#{escape(key)}=#{[Marshal.dump(data)].pack("m*")}"
|
20
|
-
end
|
21
|
-
|
22
|
-
def normalize_rack_environment(env)
|
23
|
-
env.inject({}) do |hash,(k,v)|
|
24
|
-
hash[ENV_KEY_NAMES[k] || k] = v
|
25
|
-
hash
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def hash_to_param_string(hash)
|
30
|
-
hash.map { |pair| pair.map{|v|escape(v)}.join('=') }.join('&')
|
31
|
-
end
|
32
|
-
|
33
|
-
%w(get head post put delete).each do |verb|
|
34
|
-
http_method = verb.upcase
|
35
|
-
define_method("#{verb}_it") do |path, *args|
|
36
|
-
@request = Rack::MockRequest.new(Sinatra.build_application)
|
37
|
-
opts, input =
|
38
|
-
case args.size
|
39
|
-
when 2 # input, env
|
40
|
-
input, env = args
|
41
|
-
[env, input]
|
42
|
-
when 1 # params
|
43
|
-
if (data = args.first).kind_of?(Hash)
|
44
|
-
env = (data.delete(:env) || {})
|
45
|
-
[env, hash_to_param_string(data)]
|
46
|
-
else
|
47
|
-
[{}, data]
|
48
|
-
end
|
49
|
-
when 0
|
50
|
-
[{}, '']
|
51
|
-
else
|
52
|
-
raise ArgumentError, "zero, one, or two arguments expected"
|
53
|
-
end
|
54
|
-
opts = normalize_rack_environment(opts)
|
55
|
-
opts[:input] ||= input
|
56
|
-
@response = @request.request(http_method, path, opts)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def follow!
|
61
|
-
get_it(@response.location)
|
62
|
-
end
|
63
|
-
|
64
|
-
def method_missing(name, *args)
|
65
|
-
if @response.respond_to?(name)
|
66
|
-
@response.send(name, *args)
|
67
|
-
else
|
68
|
-
super
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
data/test/event_context_test.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
context "EventContext" do
|
4
|
-
|
5
|
-
specify "DSLified setters" do
|
6
|
-
|
7
|
-
cx = Sinatra::EventContext.new(stub_everything, Rack::Response.new, {})
|
8
|
-
lambda {
|
9
|
-
cx.status 404
|
10
|
-
}.should.not.raise(ArgumentError)
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|