mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Merge pull request #550 from etehtsea/trailing-whitespaces
Remove trailing whitespaces
This commit is contained in:
commit
69c0d0a144
16 changed files with 66 additions and 66 deletions
|
@ -25,11 +25,11 @@ __END__
|
|||
|
||||
@@ layout
|
||||
<html>
|
||||
<head>
|
||||
<title>Super Simple Chat with Sinatra</title>
|
||||
<head>
|
||||
<title>Super Simple Chat with Sinatra</title>
|
||||
<meta charset="utf-8" />
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
||||
</head>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body><%= yield %></body>
|
||||
</html>
|
||||
|
||||
|
@ -58,4 +58,4 @@ __END__
|
|||
|
||||
<form>
|
||||
<input id='msg' placeholder='type message here...' />
|
||||
</form>
|
||||
</form>
|
||||
|
|
|
@ -1348,7 +1348,7 @@ module Sinatra
|
|||
enc = "(?:#{enc}|#{encoded('+')})" if char == " "
|
||||
enc
|
||||
end
|
||||
|
||||
|
||||
def escaped(char, enc = URI.escape(char))
|
||||
[Regexp.escape(enc), URI.escape(char, /./)]
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
|
||||
class CompileTest < Test::Unit::TestCase
|
||||
|
||||
|
||||
def self.converts pattern, expected_regexp
|
||||
it "generates #{expected_regexp.source} from #{pattern}" do
|
||||
compiled, _ = compiled pattern
|
||||
|
@ -14,7 +14,7 @@ class CompileTest < Test::Unit::TestCase
|
|||
compiled, keys = compiled pattern
|
||||
match = compiled.match(example)
|
||||
fail %Q{"#{example}" does not parse on pattern "#{pattern}".} unless match
|
||||
|
||||
|
||||
# Aggregate e.g. multiple splat values into one array.
|
||||
#
|
||||
params = keys.zip(match.captures).reduce({}) do |hash, mapping|
|
||||
|
@ -26,7 +26,7 @@ class CompileTest < Test::Unit::TestCase
|
|||
end
|
||||
hash
|
||||
end
|
||||
|
||||
|
||||
assert_equal(expected_params, params)
|
||||
end
|
||||
end
|
||||
|
@ -42,13 +42,13 @@ class CompileTest < Test::Unit::TestCase
|
|||
compiled, keys = app.send(:compile, pattern)
|
||||
[compiled, keys]
|
||||
end
|
||||
|
||||
|
||||
converts "/", %r{\A/\z}
|
||||
parses "/", "/", {}
|
||||
|
||||
|
||||
converts "/foo", %r{\A/foo\z}
|
||||
parses "/foo", "/foo", {}
|
||||
|
||||
|
||||
converts "/:foo", %r{\A/([^/?#]+)\z}
|
||||
parses "/:foo", "/foo", "foo" => "foo"
|
||||
parses "/:foo", "/foo.bar", "foo" => "foo.bar"
|
||||
|
@ -57,33 +57,33 @@ class CompileTest < Test::Unit::TestCase
|
|||
fails "/:foo", "/foo/bar"
|
||||
fails "/:foo", "/"
|
||||
fails "/:foo", "/foo/"
|
||||
|
||||
|
||||
converts "/föö", %r{\A/f%C3%B6%C3%B6\z}
|
||||
parses "/föö", "/f%C3%B6%C3%B6", {}
|
||||
|
||||
|
||||
converts "/:foo/:bar", %r{\A/([^/?#]+)/([^/?#]+)\z}
|
||||
parses "/:foo/:bar", "/foo/bar", "foo" => "foo", "bar" => "bar"
|
||||
|
||||
|
||||
converts "/hello/:person", %r{\A/hello/([^/?#]+)\z}
|
||||
parses "/hello/:person", "/hello/Frank", "person" => "Frank"
|
||||
|
||||
|
||||
converts "/?:foo?/?:bar?", %r{\A/?([^/?#]+)?/?([^/?#]+)?\z}
|
||||
parses "/?:foo?/?:bar?", "/hello/world", "foo" => "hello", "bar" => "world"
|
||||
parses "/?:foo?/?:bar?", "/hello", "foo" => "hello", "bar" => nil
|
||||
parses "/?:foo?/?:bar?", "/", "foo" => nil, "bar" => nil
|
||||
parses "/?:foo?/?:bar?", "", "foo" => nil, "bar" => nil
|
||||
|
||||
|
||||
converts "/*", %r{\A/(.*?)\z}
|
||||
parses "/*", "/", "splat" => ""
|
||||
parses "/*", "/foo", "splat" => "foo"
|
||||
parses "/*", "/foo/bar", "splat" => "foo/bar"
|
||||
|
||||
|
||||
converts "/:foo/*", %r{\A/([^/?#]+)/(.*?)\z}
|
||||
parses "/:foo/*", "/foo/bar/baz", "foo" => "foo", "splat" => "bar/baz"
|
||||
|
||||
|
||||
converts "/:foo/:bar", %r{\A/([^/?#]+)/([^/?#]+)\z}
|
||||
parses "/:foo/:bar", "/user@example.com/name", "foo" => "user@example.com", "bar" => "name"
|
||||
|
||||
|
||||
converts "/test$/", %r{\A/test(?:\$|%24)/\z}
|
||||
parses "/test$/", "/test$/", {}
|
||||
|
||||
|
@ -91,45 +91,45 @@ class CompileTest < Test::Unit::TestCase
|
|||
parses "/te+st/", "/te+st/", {}
|
||||
fails "/te+st/", "/test/"
|
||||
fails "/te+st/", "/teeest/"
|
||||
|
||||
|
||||
converts "/test(bar)/", %r{\A/test(?:\(|%28)bar(?:\)|%29)/\z}
|
||||
parses "/test(bar)/", "/test(bar)/", {}
|
||||
|
||||
|
||||
converts "/path with spaces", %r{\A/path(?:%20|(?:\+|%2B))with(?:%20|(?:\+|%2B))spaces\z}
|
||||
parses "/path with spaces", "/path%20with%20spaces", {}
|
||||
parses "/path with spaces", "/path%2Bwith%2Bspaces", {}
|
||||
parses "/path with spaces", "/path+with+spaces", {}
|
||||
|
||||
|
||||
converts "/foo&bar", %r{\A/foo(?:&|%26)bar\z}
|
||||
parses "/foo&bar", "/foo&bar", {}
|
||||
|
||||
|
||||
converts "/:foo/*", %r{\A/([^/?#]+)/(.*?)\z}
|
||||
parses "/:foo/*", "/hello%20world/how%20are%20you", "foo" => "hello%20world", "splat" => "how%20are%20you"
|
||||
|
||||
|
||||
converts "/*/foo/*/*", %r{\A/(.*?)/foo/(.*?)/(.*?)\z}
|
||||
parses "/*/foo/*/*", "/bar/foo/bling/baz/boom", "splat" => ["bar", "bling", "baz/boom"]
|
||||
fails "/*/foo/*/*", "/bar/foo/baz"
|
||||
|
||||
|
||||
converts "/test.bar", %r{\A/test(?:\.|%2E)bar\z}
|
||||
parses "/test.bar", "/test.bar", {}
|
||||
fails "/test.bar", "/test0bar"
|
||||
|
||||
|
||||
converts "/:file.:ext", %r{\A/([^\.%2E/?#]+)(?:\.|%2E)([^\.%2E/?#]+)\z}
|
||||
parses "/:file.:ext", "/pony.jpg", "file" => "pony", "ext" => "jpg"
|
||||
parses "/:file.:ext", "/pony%2Ejpg", "file" => "pony", "ext" => "jpg"
|
||||
fails "/:file.:ext", "/.jpg"
|
||||
|
||||
|
||||
converts "/:name.?:format?", %r{\A/([^\.%2E/?#]+)(?:\.|%2E)?([^\.%2E/?#]+)?\z}
|
||||
parses "/:name.?:format?", "/foo", "name" => "foo", "format" => nil
|
||||
parses "/:name.?:format?", "/foo.bar", "name" => "foo", "format" => "bar"
|
||||
parses "/:name.?:format?", "/foo%2Ebar", "name" => "foo", "format" => "bar"
|
||||
fails "/:name.?:format?", "/.bar"
|
||||
|
||||
|
||||
converts "/:user@?:host?", %r{\A/([^@%40/?#]+)(?:@|%40)?([^@%40/?#]+)?\z}
|
||||
parses "/:user@?:host?", "/foo@bar", "user" => "foo", "host" => "bar"
|
||||
parses "/:user@?:host?", "/foo.foo@bar", "user" => "foo.foo", "host" => "bar"
|
||||
parses "/:user@?:host?", "/foo@bar.bar", "user" => "foo", "host" => "bar.bar"
|
||||
|
||||
|
||||
# From https://gist.github.com/2154980#gistcomment-169469.
|
||||
#
|
||||
# converts "/:name(.:format)?", %r{\A/([^\.%2E/?#]+)(?:\(|%28)(?:\.|%2E)([^\.%2E/?#]+)(?:\)|%29)?\z}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
# Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
|
||||
#
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
|
|
@ -586,21 +586,21 @@ class HelpersTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'sets the Content-Type response header' do
|
||||
attachment_app('test.xml')
|
||||
get '/attachment'
|
||||
assert_equal 'application/xml;charset=utf-8', response['Content-Type']
|
||||
assert_equal '<sinatra></sinatra>', body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it 'sets the Content-Type response header without extname' do
|
||||
attachment_app('test')
|
||||
get '/attachment'
|
||||
assert_equal 'text/html;charset=utf-8', response['Content-Type']
|
||||
assert_equal '<sinatra></sinatra>', body
|
||||
assert_equal '<sinatra></sinatra>', body
|
||||
end
|
||||
|
||||
|
||||
it 'sets the Content-Type response header with extname' do
|
||||
mock_app do
|
||||
get('/attachment') do
|
||||
|
@ -612,9 +612,9 @@ class HelpersTest < Test::Unit::TestCase
|
|||
|
||||
get '/attachment'
|
||||
assert_equal 'application/atom+xml', response['Content-Type']
|
||||
assert_equal '<sinatra></sinatra>', body
|
||||
assert_equal '<sinatra></sinatra>', body
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
describe 'send_file' do
|
||||
|
|
|
@ -44,7 +44,7 @@ class LiquidTest < Test::Unit::TestCase
|
|||
mock_app { get('/') { liquid :no_such_template } }
|
||||
assert_raise(Errno::ENOENT) { get('/') }
|
||||
end
|
||||
|
||||
|
||||
it "allows passing locals" do
|
||||
liquid_app {
|
||||
liquid '{{ value }}', :locals => { :value => 'foo' }
|
||||
|
|
|
@ -211,7 +211,7 @@ class MappedErrorTest < Test::Unit::TestCase
|
|||
assert_equal 500, status
|
||||
end
|
||||
|
||||
it "allows a stack of exception_handlers" do
|
||||
it "allows a stack of exception_handlers" do
|
||||
mock_app do
|
||||
set :raise_errors, false
|
||||
error(FirstError) { 'First!' }
|
||||
|
@ -223,7 +223,7 @@ class MappedErrorTest < Test::Unit::TestCase
|
|||
assert_equal 'Second!', body
|
||||
end
|
||||
|
||||
it "allows an exception handler to pass control to the next exception handler" do
|
||||
it "allows an exception handler to pass control to the next exception handler" do
|
||||
mock_app do
|
||||
set :raise_errors, false
|
||||
error(500, FirstError) { 'First!' }
|
||||
|
|
|
@ -55,7 +55,7 @@ class MarkabyTest < Test::Unit::TestCase
|
|||
assert_equal "<h1>THIS. IS. <em>SPARTA</em></h1>", body
|
||||
end
|
||||
|
||||
it 'renders inline markaby blocks with file layouts' do
|
||||
it 'renders inline markaby blocks with file layouts' do
|
||||
markaby_app { markaby(:layout => :layout2) { text "Hello World" } }
|
||||
assert ok?
|
||||
assert_equal "<h1>Markaby Layout!</h1><p>Hello World</p>", body
|
||||
|
@ -65,7 +65,7 @@ class MarkabyTest < Test::Unit::TestCase
|
|||
mock_app { get('/') { markaby :no_such_template } }
|
||||
assert_raise(Errno::ENOENT) { get('/') }
|
||||
end
|
||||
|
||||
|
||||
it "allows passing locals" do
|
||||
markaby_app {
|
||||
markaby 'text value', :locals => { :value => 'foo' }
|
||||
|
|
|
@ -34,7 +34,7 @@ class RablTest < Test::Unit::TestCase
|
|||
assert ok?
|
||||
assert_equal '{"openstruct":{"bar":"baz"}}', body
|
||||
end
|
||||
|
||||
|
||||
it "renders with file layouts" do
|
||||
rabl_app {
|
||||
@foo = OpenStruct.new(:bar => 'baz')
|
||||
|
@ -43,14 +43,14 @@ class RablTest < Test::Unit::TestCase
|
|||
assert ok?
|
||||
assert_equal '{"qux":{"openstruct":{"bar":"baz"}}}', body
|
||||
end
|
||||
|
||||
|
||||
it "raises error if template not found" do
|
||||
mock_app {
|
||||
get('/') { rabl :no_such_template }
|
||||
}
|
||||
assert_raise(Errno::ENOENT) { get('/') }
|
||||
end
|
||||
|
||||
|
||||
it "passes rabl options to the rabl engine" do
|
||||
mock_app do
|
||||
get('/') do
|
||||
|
@ -65,7 +65,7 @@ class RablTest < Test::Unit::TestCase
|
|||
assert ok?
|
||||
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
|
||||
end
|
||||
|
||||
|
||||
it "passes default rabl options to the rabl engine" do
|
||||
mock_app do
|
||||
set :rabl, :format => 'xml'
|
||||
|
@ -81,7 +81,7 @@ class RablTest < Test::Unit::TestCase
|
|||
assert ok?
|
||||
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
rescue LoadError
|
||||
|
|
|
@ -44,7 +44,7 @@ class RadiusTest < Test::Unit::TestCase
|
|||
mock_app { get('/') { radius :no_such_template } }
|
||||
assert_raise(Errno::ENOENT) { get('/') }
|
||||
end
|
||||
|
||||
|
||||
it "allows passing locals" do
|
||||
radius_app {
|
||||
radius '<r:value />', :locals => { :value => 'foo' }
|
||||
|
|
|
@ -47,13 +47,13 @@ class RouteAddedHookTest < Test::Unit::TestCase
|
|||
assert_equal [["GET", "/"], ["HEAD", "/"]],
|
||||
RouteAddedTest.routes
|
||||
end
|
||||
|
||||
|
||||
it "should pass route blocks as an argument" do
|
||||
mock_app(Class.new(Sinatra::Base)) do
|
||||
register RouteAddedTest
|
||||
get('/') {}
|
||||
end
|
||||
|
||||
assert_kind_of Proc, RouteAddedTest.procs.first
|
||||
assert_kind_of Proc, RouteAddedTest.procs.first
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,9 +75,9 @@ class ScssTest < Test::Unit::TestCase
|
|||
mock_app do
|
||||
set :scss, {:style => :compact} # default scss style is :nested
|
||||
get('/') {
|
||||
scss("#scss {\n background-color: white;\n color: black;\n}")
|
||||
scss("#scss {\n background-color: white;\n color: black;\n}")
|
||||
}
|
||||
end
|
||||
end
|
||||
get '/'
|
||||
assert ok?
|
||||
assert_equal "#scss { background-color: white; color: black; }\n", body
|
||||
|
|
|
@ -5,7 +5,7 @@ class SinatraTest < Test::Unit::TestCase
|
|||
app = Sinatra.new { get('/') { 'Hello World' } }
|
||||
assert_same Sinatra::Base, app.superclass
|
||||
end
|
||||
|
||||
|
||||
it "responds to #template_cache" do
|
||||
assert_kind_of Tilt::Cache, Sinatra::Base.new!.template_cache
|
||||
end
|
||||
|
|
|
@ -17,13 +17,13 @@ class SlimTest < Test::Unit::TestCase
|
|||
assert ok?
|
||||
assert_equal "<h1>Hiya</h1>", body
|
||||
end
|
||||
|
||||
|
||||
it 'renders .slim files in views path' do
|
||||
slim_app { slim :hello }
|
||||
assert ok?
|
||||
assert_equal "<h1>Hello From Slim</h1>", body
|
||||
end
|
||||
|
||||
|
||||
it "renders with inline layouts" do
|
||||
mock_app do
|
||||
layout { %(h1\n | THIS. IS. \n == yield.upcase ) }
|
||||
|
@ -33,27 +33,27 @@ class SlimTest < Test::Unit::TestCase
|
|||
assert ok?
|
||||
assert_equal "<h1>THIS. IS. <EM>SPARTA</EM></h1>", body
|
||||
end
|
||||
|
||||
|
||||
it "renders with file layouts" do
|
||||
slim_app { slim('| Hello World', :layout => :layout2) }
|
||||
assert ok?
|
||||
assert_equal "<h1>Slim Layout!</h1><p>Hello World</p>", body
|
||||
end
|
||||
|
||||
|
||||
it "raises error if template not found" do
|
||||
mock_app { get('/') { slim(:no_such_template) } }
|
||||
assert_raise(Errno::ENOENT) { get('/') }
|
||||
end
|
||||
|
||||
|
||||
HTML4_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
|
||||
|
||||
|
||||
it "passes slim options to the slim engine" do
|
||||
mock_app { get('/') { slim("x foo='bar'", :attr_wrapper => "'") }}
|
||||
get '/'
|
||||
assert ok?
|
||||
assert_body "<x foo='bar'></x>"
|
||||
end
|
||||
|
||||
|
||||
it "passes default slim options to the slim engine" do
|
||||
mock_app do
|
||||
set :slim, :attr_wrapper => "'"
|
||||
|
@ -63,7 +63,7 @@ class SlimTest < Test::Unit::TestCase
|
|||
assert ok?
|
||||
assert_body "<x foo='bar'></x>"
|
||||
end
|
||||
|
||||
|
||||
it "merges the default slim options with the overrides and passes them to the slim engine" do
|
||||
mock_app do
|
||||
set :slim, :attr_wrapper => "'"
|
||||
|
|
|
@ -288,7 +288,7 @@ __END__
|
|||
@@ foo
|
||||
this is foo
|
||||
|
||||
@@ bar
|
||||
@@ bar
|
||||
There's a space after 'bar'!
|
||||
|
||||
@@ foo bar
|
||||
|
|
|
@ -50,7 +50,7 @@ class YajlTest < Test::Unit::TestCase
|
|||
it 'decorates the json with a callback' do
|
||||
yajl_app do
|
||||
yajl(
|
||||
'json = { :foo => "bar" }',
|
||||
'json = { :foo => "bar" }',
|
||||
{ :callback => 'baz' }
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue