aldebaran 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +13 -0
- data/.travis.yml +16 -0
- data/.yardopts +4 -0
- data/AUTHORS +4 -0
- data/Gemfile +77 -0
- data/KNOWN_ISSUES +5 -0
- data/LICENSE +22 -0
- data/README.rdoc +1900 -0
- data/Rakefile +175 -0
- data/aldebaran.gemspec +19 -0
- data/lib/aldebaran.rb +7 -0
- data/lib/aldebaran/base.rb +1600 -0
- data/lib/aldebaran/images/404.png +0 -0
- data/lib/aldebaran/images/500.png +0 -0
- data/lib/aldebaran/main.rb +28 -0
- data/lib/aldebaran/showexceptions.rb +340 -0
- data/lib/aldebaran/version.rb +3 -0
- data/test/aldebaran_test.rb +17 -0
- data/test/base_test.rb +160 -0
- data/test/builder_test.rb +95 -0
- data/test/coffee_test.rb +92 -0
- data/test/contest.rb +98 -0
- data/test/creole_test.rb +65 -0
- data/test/delegator_test.rb +162 -0
- data/test/encoding_test.rb +20 -0
- data/test/erb_test.rb +104 -0
- data/test/extensions_test.rb +100 -0
- data/test/filter_test.rb +397 -0
- data/test/haml_test.rb +101 -0
- data/test/helper.rb +115 -0
- data/test/helpers_test.rb +1192 -0
- data/test/less_test.rb +67 -0
- data/test/liquid_test.rb +59 -0
- data/test/mapped_error_test.rb +259 -0
- data/test/markaby_test.rb +80 -0
- data/test/markdown_test.rb +81 -0
- data/test/middleware_test.rb +68 -0
- data/test/nokogiri_test.rb +69 -0
- data/test/public/favicon.ico +0 -0
- data/test/radius_test.rb +59 -0
- data/test/rdoc_test.rb +65 -0
- data/test/readme_test.rb +136 -0
- data/test/request_test.rb +45 -0
- data/test/response_test.rb +61 -0
- data/test/result_test.rb +98 -0
- data/test/route_added_hook_test.rb +59 -0
- data/test/routing_test.rb +1096 -0
- data/test/sass_test.rb +115 -0
- data/test/scss_test.rb +88 -0
- data/test/server_test.rb +48 -0
- data/test/settings_test.rb +493 -0
- data/test/slim_test.rb +98 -0
- data/test/static_test.rb +178 -0
- data/test/streaming_test.rb +100 -0
- data/test/templates_test.rb +298 -0
- data/test/textile_test.rb +65 -0
- data/test/views/a/in_a.str +1 -0
- data/test/views/ascii.erb +2 -0
- data/test/views/b/in_b.str +1 -0
- data/test/views/calc.html.erb +1 -0
- data/test/views/error.builder +3 -0
- data/test/views/error.erb +3 -0
- data/test/views/error.haml +3 -0
- data/test/views/error.sass +2 -0
- data/test/views/explicitly_nested.str +1 -0
- data/test/views/foo/hello.test +1 -0
- data/test/views/hello.builder +1 -0
- data/test/views/hello.coffee +1 -0
- data/test/views/hello.creole +1 -0
- data/test/views/hello.erb +1 -0
- data/test/views/hello.haml +1 -0
- data/test/views/hello.less +5 -0
- data/test/views/hello.liquid +1 -0
- data/test/views/hello.mab +1 -0
- data/test/views/hello.md +1 -0
- data/test/views/hello.nokogiri +1 -0
- data/test/views/hello.radius +1 -0
- data/test/views/hello.rdoc +1 -0
- data/test/views/hello.sass +2 -0
- data/test/views/hello.scss +3 -0
- data/test/views/hello.slim +1 -0
- data/test/views/hello.str +1 -0
- data/test/views/hello.test +1 -0
- data/test/views/hello.textile +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.liquid +2 -0
- data/test/views/layout2.mab +2 -0
- data/test/views/layout2.nokogiri +3 -0
- data/test/views/layout2.radius +2 -0
- data/test/views/layout2.slim +3 -0
- data/test/views/layout2.str +2 -0
- data/test/views/layout2.test +1 -0
- data/test/views/nested.str +1 -0
- data/test/views/utf8.erb +2 -0
- metadata +231 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'builder'
|
5
|
+
|
6
|
+
class BuilderTest < Test::Unit::TestCase
|
7
|
+
def builder_app(options = {}, &block)
|
8
|
+
mock_app {
|
9
|
+
set :views, File.dirname(__FILE__) + '/views'
|
10
|
+
set options
|
11
|
+
get '/', &block
|
12
|
+
}
|
13
|
+
get '/'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'renders inline Builder strings' do
|
17
|
+
builder_app { builder 'xml.instruct!' }
|
18
|
+
assert ok?
|
19
|
+
assert_equal %{<?xml version="1.0" encoding="UTF-8"?>\n}, body
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'defaults content type to xml' do
|
23
|
+
builder_app { builder 'xml.instruct!' }
|
24
|
+
assert ok?
|
25
|
+
assert_equal "application/xml;charset=utf-8", response['Content-Type']
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'defaults allows setting content type per route' do
|
29
|
+
builder_app do
|
30
|
+
content_type :html
|
31
|
+
builder 'xml.instruct!'
|
32
|
+
end
|
33
|
+
assert ok?
|
34
|
+
assert_equal "text/html;charset=utf-8", response['Content-Type']
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'defaults allows setting content type globally' do
|
38
|
+
builder_app(:builder => { :content_type => 'html' }) do
|
39
|
+
builder 'xml.instruct!'
|
40
|
+
end
|
41
|
+
assert ok?
|
42
|
+
assert_equal "text/html;charset=utf-8", response['Content-Type']
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'renders inline blocks' do
|
46
|
+
builder_app {
|
47
|
+
@name = "Frank & Mary"
|
48
|
+
builder do |xml|
|
49
|
+
xml.couple @name
|
50
|
+
end
|
51
|
+
}
|
52
|
+
assert ok?
|
53
|
+
assert_equal "<couple>Frank & Mary</couple>\n", body
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'renders .builder files in views path' do
|
57
|
+
builder_app {
|
58
|
+
@name = "Blue"
|
59
|
+
builder :hello
|
60
|
+
}
|
61
|
+
assert ok?
|
62
|
+
assert_equal %(<exclaim>You're my boy, Blue!</exclaim>\n), body
|
63
|
+
end
|
64
|
+
|
65
|
+
it "renders with inline layouts" do
|
66
|
+
mock_app {
|
67
|
+
layout do
|
68
|
+
%(xml.layout { xml << yield })
|
69
|
+
end
|
70
|
+
get('/') { builder %(xml.em 'Hello World') }
|
71
|
+
}
|
72
|
+
get '/'
|
73
|
+
assert ok?
|
74
|
+
assert_equal "<layout>\n<em>Hello World</em>\n</layout>\n", body
|
75
|
+
end
|
76
|
+
|
77
|
+
it "renders with file layouts" do
|
78
|
+
builder_app {
|
79
|
+
builder %(xml.em 'Hello World'), :layout => :layout2
|
80
|
+
}
|
81
|
+
assert ok?
|
82
|
+
assert_equal "<layout>\n<em>Hello World</em>\n</layout>\n", body
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises error if template not found" do
|
86
|
+
mock_app {
|
87
|
+
get('/') { builder :no_such_template }
|
88
|
+
}
|
89
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
rescue LoadError
|
94
|
+
warn "#{$!.to_s}: skipping builder tests"
|
95
|
+
end
|
data/test/coffee_test.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'coffee-script'
|
5
|
+
require 'execjs'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ExecJS.compile '1'
|
9
|
+
rescue Exception
|
10
|
+
raise LoadError, 'unable to execute JavaScript'
|
11
|
+
end
|
12
|
+
|
13
|
+
class CoffeeTest < Test::Unit::TestCase
|
14
|
+
def coffee_app(options = {}, &block)
|
15
|
+
mock_app {
|
16
|
+
set :views, File.dirname(__FILE__) + '/views'
|
17
|
+
set(options)
|
18
|
+
get '/', &block
|
19
|
+
}
|
20
|
+
get '/'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'renders inline Coffee strings' do
|
24
|
+
coffee_app { coffee "alert 'Aye!'\n" }
|
25
|
+
assert ok?
|
26
|
+
assert body.include?("alert('Aye!');")
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'defaults content type to javascript' do
|
30
|
+
coffee_app { coffee "alert 'Aye!'\n" }
|
31
|
+
assert ok?
|
32
|
+
assert_equal "application/javascript;charset=utf-8", response['Content-Type']
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'defaults allows setting content type per route' do
|
36
|
+
coffee_app do
|
37
|
+
content_type :html
|
38
|
+
coffee "alert 'Aye!'\n"
|
39
|
+
end
|
40
|
+
assert ok?
|
41
|
+
assert_equal "text/html;charset=utf-8", response['Content-Type']
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'defaults allows setting content type globally' do
|
45
|
+
coffee_app(:coffee => { :content_type => 'html' }) do
|
46
|
+
coffee "alert 'Aye!'\n"
|
47
|
+
end
|
48
|
+
assert ok?
|
49
|
+
assert_equal "text/html;charset=utf-8", response['Content-Type']
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'renders .coffee files in views path' do
|
53
|
+
coffee_app { coffee :hello }
|
54
|
+
assert ok?
|
55
|
+
assert_include body, "alert(\"Aye!\");"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'ignores the layout option' do
|
59
|
+
coffee_app { coffee :hello, :layout => :layout2 }
|
60
|
+
assert ok?
|
61
|
+
assert_include body, "alert(\"Aye!\");"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "raises error if template not found" do
|
65
|
+
mock_app {
|
66
|
+
get('/') { coffee :no_such_template }
|
67
|
+
}
|
68
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
69
|
+
end
|
70
|
+
|
71
|
+
it "passes coffee options to the coffee engine" do
|
72
|
+
coffee_app { coffee "alert 'Aye!'\n", :no_wrap => true }
|
73
|
+
assert ok?
|
74
|
+
assert_equal "alert('Aye!');", body
|
75
|
+
end
|
76
|
+
|
77
|
+
it "passes default coffee options to the coffee engine" do
|
78
|
+
mock_app do
|
79
|
+
set :coffee, :no_wrap => true # default coffee style is :nested
|
80
|
+
get '/' do
|
81
|
+
coffee "alert 'Aye!'\n"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
get '/'
|
85
|
+
assert ok?
|
86
|
+
assert_equal "alert('Aye!');", body
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
rescue LoadError
|
91
|
+
warn "#{$!.to_s}: skipping coffee tests"
|
92
|
+
end
|
data/test/contest.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
require "test/unit"
|
21
|
+
|
22
|
+
# Test::Unit loads a default test if the suite is empty, whose purpose is to
|
23
|
+
# fail. Since having empty contexts is a common practice, we decided to
|
24
|
+
# overwrite TestSuite#empty? in order to allow them. Having a failure when no
|
25
|
+
# tests have been defined seems counter-intuitive.
|
26
|
+
class Test::Unit::TestSuite
|
27
|
+
def empty?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Contest adds +teardown+, +test+ and +context+ as class methods, and the
|
33
|
+
# instance methods +setup+ and +teardown+ now iterate on the corresponding
|
34
|
+
# blocks. Note that all setup and teardown blocks must be defined with the
|
35
|
+
# block syntax. Adding setup or teardown instance methods defeats the purpose
|
36
|
+
# of this library.
|
37
|
+
class Test::Unit::TestCase
|
38
|
+
def self.setup(&block) setup_blocks << block end
|
39
|
+
def self.teardown(&block) teardown_blocks << block end
|
40
|
+
def self.setup_blocks() @setup_blocks ||= [] end
|
41
|
+
def self.teardown_blocks() @teardown_blocks ||= [] end
|
42
|
+
|
43
|
+
def setup_blocks(base = self.class)
|
44
|
+
setup_blocks base.superclass if base.superclass.respond_to? :setup_blocks
|
45
|
+
base.setup_blocks.each do |block|
|
46
|
+
instance_eval(&block)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def teardown_blocks(base = self.class)
|
51
|
+
teardown_blocks base.superclass if base.superclass.respond_to? :teardown_blocks
|
52
|
+
base.teardown_blocks.each do |block|
|
53
|
+
instance_eval(&block)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
alias setup setup_blocks
|
58
|
+
alias teardown teardown_blocks
|
59
|
+
|
60
|
+
def self.context(*name, &block)
|
61
|
+
subclass = Class.new(self)
|
62
|
+
remove_tests(subclass)
|
63
|
+
subclass.class_eval(&block) if block_given?
|
64
|
+
const_set(context_name(name.join(" ")), subclass)
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.test(name, &block)
|
68
|
+
define_method(test_name(name), &block)
|
69
|
+
end
|
70
|
+
|
71
|
+
class << self
|
72
|
+
alias_method :should, :test
|
73
|
+
alias_method :describe, :context
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def self.context_name(name)
|
79
|
+
# "Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}".to_sym
|
80
|
+
name = "Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}"
|
81
|
+
name.tr(" ", "_").to_sym
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.test_name(name)
|
85
|
+
"test_#{sanitize_name(name).gsub(/\s+/,'_')}".to_sym
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.sanitize_name(name)
|
89
|
+
# name.gsub(/\W+/, ' ').strip
|
90
|
+
name.gsub(/\W+/, ' ')
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.remove_tests(subclass)
|
94
|
+
subclass.public_instance_methods.grep(/^test_/).each do |meth|
|
95
|
+
subclass.send(:undef_method, meth.to_sym)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/test/creole_test.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'creole'
|
5
|
+
|
6
|
+
class CreoleTest < Test::Unit::TestCase
|
7
|
+
def creole_app(&block)
|
8
|
+
mock_app do
|
9
|
+
set :views, File.dirname(__FILE__) + '/views'
|
10
|
+
get '/', &block
|
11
|
+
end
|
12
|
+
get '/'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'renders inline creole strings' do
|
16
|
+
creole_app { creole '= Hiya' }
|
17
|
+
assert ok?
|
18
|
+
assert_body "<h1>Hiya</h1>"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'renders .creole files in views path' do
|
22
|
+
creole_app { creole :hello }
|
23
|
+
assert ok?
|
24
|
+
assert_body "<h1>Hello From Creole</h1>"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises error if template not found" do
|
28
|
+
mock_app { get('/') { creole :no_such_template } }
|
29
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "renders with inline layouts" do
|
33
|
+
mock_app do
|
34
|
+
layout { 'THIS. IS. #{yield.upcase}!' }
|
35
|
+
get('/') { creole 'Sparta', :layout_engine => :str }
|
36
|
+
end
|
37
|
+
get '/'
|
38
|
+
assert ok?
|
39
|
+
assert_like 'THIS. IS. <P>SPARTA</P>!', body
|
40
|
+
end
|
41
|
+
|
42
|
+
it "renders with file layouts" do
|
43
|
+
creole_app { creole 'Hello World', :layout => :layout2, :layout_engine => :erb }
|
44
|
+
assert ok?
|
45
|
+
assert_body "ERB Layout!\n<p>Hello World</p>"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "can be used in a nested fashion for partials and whatnot" do
|
49
|
+
mock_app do
|
50
|
+
template(:inner) { "hi" }
|
51
|
+
template(:outer) { "<outer><%= creole :inner %></outer>" }
|
52
|
+
get '/' do
|
53
|
+
erb :outer
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
get '/'
|
58
|
+
assert ok?
|
59
|
+
assert_like '<outer><p>hi</p></outer>', body
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
rescue LoadError
|
64
|
+
warn "#{$!.to_s}: skipping creole tests"
|
65
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class DelegatorTest < Test::Unit::TestCase
|
4
|
+
class Mirror
|
5
|
+
attr_reader :last_call
|
6
|
+
def method_missing(*a, &b)
|
7
|
+
@last_call = [*a.map(&:to_s)]
|
8
|
+
@last_call << b if b
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.delegates(name)
|
13
|
+
it "delegates #{name}" do
|
14
|
+
m = mirror { send name }
|
15
|
+
assert_equal [name.to_s], m.last_call
|
16
|
+
end
|
17
|
+
|
18
|
+
it "delegates #{name} with arguments" do
|
19
|
+
m = mirror { send name, "foo", "bar" }
|
20
|
+
assert_equal [name.to_s, "foo", "bar"], m.last_call
|
21
|
+
end
|
22
|
+
|
23
|
+
it "delegates #{name} with block" do
|
24
|
+
block = proc { }
|
25
|
+
m = mirror { send(name, &block) }
|
26
|
+
assert_equal [name.to_s, block], m.last_call
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
setup do
|
31
|
+
@target_was = aldebaran::Delegator.target
|
32
|
+
end
|
33
|
+
|
34
|
+
def teardown
|
35
|
+
aldebaran::Delegator.target = @target_was
|
36
|
+
end
|
37
|
+
|
38
|
+
def delegation_app(&block)
|
39
|
+
mock_app { aldebaran::Delegator.target = self }
|
40
|
+
delegate(&block)
|
41
|
+
end
|
42
|
+
|
43
|
+
def mirror(&block)
|
44
|
+
mirror = Mirror.new
|
45
|
+
aldebaran::Delegator.target = mirror
|
46
|
+
delegate(&block)
|
47
|
+
end
|
48
|
+
|
49
|
+
def delegate(&block)
|
50
|
+
assert aldebaran::Delegator.target != aldebaran::Application
|
51
|
+
Object.new.extend(aldebaran::Delegator).instance_eval(&block) if block
|
52
|
+
aldebaran::Delegator.target
|
53
|
+
end
|
54
|
+
|
55
|
+
def target
|
56
|
+
aldebaran::Delegator.target
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'defaults to aldebaran::Application as target' do
|
60
|
+
assert_equal aldebaran::Application, aldebaran::Delegator.target
|
61
|
+
end
|
62
|
+
|
63
|
+
%w[get put post delete options patch].each do |verb|
|
64
|
+
it "delegates #{verb} correctly" do
|
65
|
+
delegation_app do
|
66
|
+
send verb, '/hello' do
|
67
|
+
'Hello World'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
request = Rack::MockRequest.new(@app)
|
72
|
+
response = request.request(verb.upcase, '/hello', {})
|
73
|
+
assert response.ok?
|
74
|
+
assert_equal 'Hello World', response.body
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "delegates head correctly" do
|
79
|
+
delegation_app do
|
80
|
+
head '/hello' do
|
81
|
+
response['X-Hello'] = 'World!'
|
82
|
+
'remove me'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
request = Rack::MockRequest.new(@app)
|
87
|
+
response = request.request('HEAD', '/hello', {})
|
88
|
+
assert response.ok?
|
89
|
+
assert_equal 'World!', response['X-Hello']
|
90
|
+
assert_equal '', response.body
|
91
|
+
end
|
92
|
+
|
93
|
+
it "registers extensions with the delegation target" do
|
94
|
+
app, mixin = mirror, Module.new
|
95
|
+
aldebaran.register mixin
|
96
|
+
assert_equal ["register", mixin.to_s], app.last_call
|
97
|
+
end
|
98
|
+
|
99
|
+
it "registers helpers with the delegation target" do
|
100
|
+
app, mixin = mirror, Module.new
|
101
|
+
aldebaran.helpers mixin
|
102
|
+
assert_equal ["helpers", mixin.to_s], app.last_call
|
103
|
+
end
|
104
|
+
|
105
|
+
it "registers helpers with the delegation target" do
|
106
|
+
app, mixin = mirror, Module.new
|
107
|
+
aldebaran.use mixin
|
108
|
+
assert_equal ["use", mixin.to_s], app.last_call
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should work with method_missing proxies for options" do
|
112
|
+
mixin = Module.new do
|
113
|
+
def respond_to?(method, *)
|
114
|
+
method.to_sym == :options or super
|
115
|
+
end
|
116
|
+
|
117
|
+
def method_missing(method, *args, &block)
|
118
|
+
return super unless method.to_sym == :options
|
119
|
+
{:some => :option}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
value = nil
|
124
|
+
mirror do
|
125
|
+
extend mixin
|
126
|
+
value = options
|
127
|
+
end
|
128
|
+
|
129
|
+
assert_equal({:some => :option}, value)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "delegates crazy method names" do
|
133
|
+
aldebaran::Delegator.delegate "foo:bar:"
|
134
|
+
method = mirror { send "foo:bar:" }.last_call.first
|
135
|
+
assert_equal "foo:bar:", method
|
136
|
+
end
|
137
|
+
|
138
|
+
delegates 'get'
|
139
|
+
delegates 'patch'
|
140
|
+
delegates 'put'
|
141
|
+
delegates 'post'
|
142
|
+
delegates 'delete'
|
143
|
+
delegates 'head'
|
144
|
+
delegates 'options'
|
145
|
+
delegates 'template'
|
146
|
+
delegates 'layout'
|
147
|
+
delegates 'before'
|
148
|
+
delegates 'after'
|
149
|
+
delegates 'error'
|
150
|
+
delegates 'not_found'
|
151
|
+
delegates 'configure'
|
152
|
+
delegates 'set'
|
153
|
+
delegates 'mime_type'
|
154
|
+
delegates 'enable'
|
155
|
+
delegates 'disable'
|
156
|
+
delegates 'use'
|
157
|
+
delegates 'development?'
|
158
|
+
delegates 'test?'
|
159
|
+
delegates 'production?'
|
160
|
+
delegates 'helpers'
|
161
|
+
delegates 'settings'
|
162
|
+
end
|