/
example_unit.rb
94 lines (74 loc) · 1.5 KB
/
example_unit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
module ExampleUnit
include Chanko::Unit
shared(:shared) do |args|
"shared #{args}"
end
scope(:controller) do
function(:test) do
"test"
end
function(:foo) do
"foo"
end
function(:bar) do
"bar"
end
function(:alias) do
"alias"
end
function(:default) do
run_default
end
function(:render) do
render_to_string :partial => "/units/example_unit/test", :locals => { :local => "test" }
end
function(:nesting_locals_outer) do
result = "#{outer_one}."
result += invoke(:example_unit, :nesting_locals_inner, :locals => { :inner_one => "inner_one", :inner_two => "inner_two" }) do
"#{outer_two}.#{run_default}"
end
result += ".#{outer_three}"
result
end
function(:nesting_locals_inner) do
"#{inner_one}.#{run_default}.#{inner_two}"
end
end
scope(:view) do
function(:test) do
"test"
end
function(:self) do
self
end
function(:locals) do
key
end
function(:falsy) do
key.nil?
end
function(:shared) do
shared("args")
end
function(:error) do
raise_no_method_error
end
function(:helper) do
unit.helper
end
function(:respond_to_helper?) do
unit.respond_to?(:helper)
end
function(:render) do
render "/units/example_unit/test", :local => "test"
end
function(:blank) do
" "
end
end
helpers do
def helper
"helper"
end
end
end