apotomo 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -3
- data/.travis.yml +6 -8
- data/CHANGES.textile +9 -5
- data/README.md +211 -0
- data/apotomo.gemspec +4 -4
- data/config/routes.rb +1 -1
- data/gemfiles/Gemfile.rails3-0 +6 -0
- data/gemfiles/Gemfile.rails3-1 +6 -0
- data/gemfiles/Gemfile.rails3-2 +6 -0
- data/gemfiles/Gemfile.rails4-0 +6 -0
- data/lib/apotomo/javascript_generator.rb +3 -3
- data/lib/apotomo/test_case.rb +14 -8
- data/lib/apotomo/version.rb +1 -1
- data/lib/apotomo/widget/javascript_methods.rb +3 -3
- data/lib/apotomo/widget/tree_node.rb +1 -1
- data/lib/apotomo/widget.rb +3 -3
- data/lib/generators/apotomo/widget_generator.rb +1 -1
- data/lib/generators/templates/view.slim +3 -4
- data/test/apotomo_test.rb +25 -14
- data/test/dummy/config/routes.rb +2 -57
- data/test/event_handler_test.rb +30 -60
- data/test/event_methods_test.rb +62 -62
- data/test/event_test.rb +11 -11
- data/test/invoke_event_handler_test.rb +59 -0
- data/test/javascript_generator_test.rb +57 -72
- data/test/rails/caching_test.rb +11 -11
- data/test/rails/controller_methods_test.rb +63 -57
- data/test/rails/rails_integration_test.rb +47 -47
- data/test/rails/view_helper_test.rb +31 -26
- data/test/rails/widget_generator_test.rb +16 -16
- data/test/render_test.rb +50 -50
- data/test/request_processor_test.rb +74 -74
- data/test/test_case_test.rb +45 -45
- data/test/test_helper.rb +14 -10
- data/test/tree_node_test.rb +5 -10
- data/test/widget_shortcuts_test.rb +25 -25
- data/test/widget_test.rb +82 -80
- metadata +73 -49
- data/README.rdoc +0 -205
- data/TODO +0 -36
- data/lib/apotomo/proc_event_handler.rb +0 -18
- data/test/onfire_integration_test.rb +0 -22
data/test/render_test.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class RenderTest <
|
3
|
+
class RenderTest < MiniTest::Spec
|
4
4
|
include Apotomo::TestCaseMethods::TestController
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
|
6
|
+
describe "#render" do
|
7
|
+
before do
|
8
8
|
@mum = mouse('mum')
|
9
9
|
end
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
it "per default display the state content framed in a div" do
|
12
12
|
assert_equal '<div id="mum">burp!</div>', @mum.invoke(:eating)
|
13
13
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
|
15
|
+
describe "with :text" do
|
16
|
+
before do
|
17
17
|
@mum.instance_eval { def eating; render :text => "burp!!!"; end }
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
it "render the :text" do
|
21
21
|
assert_equal "burp!!!", @mum.invoke(:eating)
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
|
-
|
24
|
+
|
25
|
+
it "accept :state and options" do
|
26
26
|
@mum.instance_eval { def eat(what); render :text => "#{what} today?"; end }
|
27
|
-
|
27
|
+
|
28
28
|
assert_equal "Rice today?", @mum.render({:state => :eat}, "Rice")
|
29
29
|
assert_match "Rice today?", @mum.update({:state => :eat}, "Rice")
|
30
30
|
assert_match "Rice today?", @mum.replace({:state => :eat}, "Rice")
|
31
31
|
end
|
32
|
-
|
33
|
-
|
32
|
+
|
33
|
+
it "expose its instance variables in the rendered view" do
|
34
34
|
@mum = mouse('mum') do
|
35
35
|
def educate
|
36
36
|
@who = "the cat"
|
@@ -40,95 +40,95 @@ class RenderTest < ActionView::TestCase
|
|
40
40
|
end
|
41
41
|
assert_equal 'If you see the cat do run away!', @mum.invoke(:educate)
|
42
42
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
|
44
|
+
describe "with #render" do
|
45
|
+
describe "and :text" do
|
46
|
+
before do
|
47
47
|
@mum.instance_eval do
|
48
48
|
def squeak
|
49
49
|
render :text => "squeak();"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
|
-
|
53
|
+
|
54
|
+
it "just return the plain :text" do
|
55
55
|
assert_equal 'squeak();', @mum.invoke(:squeak)
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
|
59
|
+
describe "and no options" do
|
60
|
+
before do
|
61
61
|
@mum.instance_eval do
|
62
62
|
def squeak
|
63
63
|
render
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
68
|
-
|
67
|
+
|
68
|
+
it "render the view" do
|
69
69
|
assert_equal "<div id=\"mum\">burp!</div>", @mum.invoke(:eating)
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
|
73
|
+
describe "and :view" do
|
74
|
+
before do
|
75
75
|
@mum.instance_eval do
|
76
76
|
def squeak
|
77
77
|
render :view => :eating
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
82
|
-
|
81
|
+
|
82
|
+
it "render the :view" do
|
83
83
|
assert_equal "<div id=\"mum\">burp!</div>", @mum.invoke(:squeak)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
|
88
|
+
describe "#update" do
|
89
|
+
it "wrap the :text in an update statement" do
|
90
90
|
@mum.instance_eval do
|
91
91
|
def squeak
|
92
92
|
update :text => "squeak!"
|
93
93
|
end
|
94
94
|
end
|
95
|
-
assert_equal "
|
95
|
+
assert_equal "jQuery(\"#mum\").html(\"squeak!\");", @mum.invoke(:squeak)
|
96
96
|
end
|
97
|
-
|
98
|
-
|
97
|
+
|
98
|
+
it "accept a selector" do
|
99
99
|
@mum.instance_eval do
|
100
100
|
def squeak
|
101
101
|
update "div#mouse", :text => '<div id="mum">squeak!</div>'
|
102
102
|
end
|
103
103
|
end
|
104
|
-
assert_equal "
|
104
|
+
assert_equal "jQuery(\"div#mouse\").html(\"<div id=\\\"mum\\\">squeak!<\\/div>\");", @mum.invoke(:squeak)
|
105
105
|
end
|
106
106
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
|
108
|
+
describe "#replace" do
|
109
|
+
it "wrap the :text in a replace statement" do
|
110
110
|
@mum.instance_eval do
|
111
111
|
def squeak
|
112
112
|
replace :text => '<div id="mum">squeak!</div>'
|
113
113
|
end
|
114
114
|
end
|
115
|
-
assert_equal "
|
115
|
+
assert_equal "jQuery(\"#mum\").replaceWith(\"<div id=\\\"mum\\\">squeak!<\\/div>\");", @mum.invoke(:squeak)
|
116
116
|
end
|
117
|
-
|
118
|
-
|
117
|
+
|
118
|
+
it "accept a selector" do
|
119
119
|
@mum.instance_eval do
|
120
120
|
def squeak
|
121
121
|
replace "div#mouse", :text => '<div id="mum">squeak!</div>'
|
122
122
|
end
|
123
123
|
end
|
124
|
-
assert_equal "
|
124
|
+
assert_equal "jQuery(\"div#mouse\").replaceWith(\"<div id=\\\"mum\\\">squeak!<\\/div>\");", @mum.invoke(:squeak)
|
125
125
|
end
|
126
126
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
|
128
|
+
describe "#escape_js" do
|
129
|
+
it "escape the string" do
|
130
130
|
assert_equal "<div id=\\\"mum\\\">squeak!<\\/div>", @mum.escape_js('<div id="mum">squeak!</div>')
|
131
131
|
end
|
132
132
|
end
|
133
|
-
end
|
133
|
+
end
|
134
134
|
end
|
@@ -1,131 +1,131 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class RequestProcessorTest <
|
3
|
+
class RequestProcessorTest < MiniTest::Spec
|
4
4
|
include Apotomo::TestCaseMethods::TestController
|
5
|
-
|
5
|
+
|
6
6
|
def root_mum_and_kid!
|
7
7
|
mum_and_kid!
|
8
|
-
|
8
|
+
|
9
9
|
@root = Apotomo::Widget.new(parent_controller, 'root', :display)
|
10
10
|
@root << @mum
|
11
11
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
|
13
|
+
|
14
|
+
describe "RequestProcessor" do
|
15
|
+
before do
|
16
16
|
@processor = Apotomo::RequestProcessor.new(parent_controller)
|
17
17
|
root = @processor.root
|
18
18
|
root << mouse_mock
|
19
19
|
end
|
20
|
-
|
21
|
-
|
20
|
+
|
21
|
+
it "allow external modification of the tree" do
|
22
22
|
root = @processor.root
|
23
23
|
assert_equal 2, @processor.root.size
|
24
24
|
end
|
25
|
-
|
26
|
-
|
25
|
+
|
26
|
+
it "delegate #render_widget_for to #root" do
|
27
27
|
assert_equal 'squeak!', @processor.render_widget_for('mouse', :squeak)
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
|
31
|
+
describe "#attach_stateless_blocks_for" do
|
32
|
+
before do
|
33
33
|
@processor = Apotomo::RequestProcessor.new(parent_controller)
|
34
34
|
@root = @processor.root
|
35
35
|
assert_equal @root.size, 1
|
36
36
|
end
|
37
|
-
|
38
|
-
|
37
|
+
|
38
|
+
it "allow has_widgets blocks with root parameter" do
|
39
39
|
@processor.send(:attach_stateless_blocks_for, [Proc.new{ |root|
|
40
|
-
root << widget(:mouse, 'mouse')
|
40
|
+
root << widget(:mouse, 'mouse')
|
41
41
|
}], @root, parent_controller)
|
42
|
-
|
42
|
+
|
43
43
|
assert_equal 'mouse', @processor.root['mouse'].name
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
|
47
|
+
describe "option processing at construction time" do
|
48
|
+
describe "with empty options" do
|
49
|
+
before do
|
50
50
|
@processor = Apotomo::RequestProcessor.new(parent_controller)
|
51
51
|
end
|
52
|
-
|
53
|
-
|
52
|
+
|
53
|
+
it "provide a single root-node for #root" do
|
54
54
|
assert_equal 1, @processor.root.size
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
|
58
|
+
describe "with controller" do
|
59
|
+
it "attach the passed parent_controller to root" do
|
60
60
|
assert_equal parent_controller, Apotomo::RequestProcessor.new(parent_controller, {}, []).root.parent_controller
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
|
65
|
+
|
66
|
+
describe "#process_for" do
|
67
|
+
before do
|
68
68
|
class KidWidget < Apotomo::Widget
|
69
69
|
responds_to_event :doorSlam, :with => :flight
|
70
70
|
responds_to_event :doorSlam, :with => :squeak
|
71
71
|
def flight; render :text => "away from here!"; end
|
72
72
|
def squeak; render :text => "squeak!"; end
|
73
73
|
end
|
74
|
-
|
75
|
-
procs = [Proc.new{ |root|
|
76
|
-
root << widget(:mouse, 'mum')
|
74
|
+
|
75
|
+
procs = [Proc.new{ |root|
|
76
|
+
root << widget(:mouse, 'mum')
|
77
77
|
KidWidget.new(root['mum'], 'kid')
|
78
78
|
}]
|
79
|
-
|
79
|
+
|
80
80
|
@processor = Apotomo::RequestProcessor.new(parent_controller, {:js_framework => :prototype}, procs)
|
81
81
|
end
|
82
|
-
|
83
|
-
|
82
|
+
|
83
|
+
it "return an empty array if nothing was triggered" do
|
84
84
|
assert_equal [], @processor.process_for({:type => :mouseClick, :source => 'kid'})
|
85
85
|
end
|
86
|
-
|
87
|
-
|
86
|
+
|
87
|
+
it "return 2 page updates when @kid squeaks" do
|
88
88
|
assert_equal ["away from here!", "squeak!"], @processor.process_for({:type => :doorSlam, :source => 'kid'})
|
89
89
|
end
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
it "append the params hash to the triggered event" do
|
92
92
|
KidWidget.class_eval do
|
93
93
|
def squeak(evt); render :text => evt.data.inspect; end
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
assert_equal ["away from here!", "{:type=>:doorSlam, :source=>\"kid\"}"], @processor.process_for({:type => :doorSlam, :source => 'kid'})
|
97
97
|
end
|
98
|
-
|
99
|
-
|
98
|
+
|
99
|
+
it "raise an exception when :source is unknown" do
|
100
100
|
assert_raises Apotomo::RequestProcessor::InvalidSourceWidget do
|
101
101
|
@processor.process_for({:type => :squeak, :source => 'tom'})
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
describe "invoking #address_for" do
|
110
|
+
before do
|
111
111
|
@processor = Apotomo::RequestProcessor.new(parent_controller)
|
112
112
|
end
|
113
|
-
|
114
|
-
|
113
|
+
|
114
|
+
it "accept an event :type" do
|
115
115
|
assert_equal({:type => :squeak, :source => 'mum'}, @processor.address_for(:type => :squeak, :source => 'mum'))
|
116
116
|
end
|
117
|
-
|
118
|
-
|
117
|
+
|
118
|
+
it "accept arbitrary options" do
|
119
119
|
assert_equal({:type => :squeak, :volume => 'loud', :source => 'mum'}, @processor.address_for(:type => :squeak, :volume => 'loud', :source => 'mum'))
|
120
120
|
end
|
121
|
-
|
122
|
-
|
121
|
+
|
122
|
+
it "complain if no type given" do
|
123
123
|
assert_raises RuntimeError do
|
124
124
|
@processor.address_for(:source => 'mum')
|
125
125
|
end
|
126
126
|
end
|
127
|
-
|
128
|
-
|
127
|
+
|
128
|
+
it "complain if no source given" do
|
129
129
|
assert_raises RuntimeError do
|
130
130
|
@processor.address_for(:type => :footsteps)
|
131
131
|
end
|
@@ -133,12 +133,12 @@ class RequestProcessorTest < ActiveSupport::TestCase
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
class RequestProcessorHooksTest <
|
136
|
+
class RequestProcessorHooksTest < MiniTest::Spec
|
137
137
|
include Apotomo::TestCaseMethods::TestController
|
138
138
|
include Apotomo::TestCaseMethods
|
139
|
-
|
140
|
-
|
141
|
-
|
139
|
+
|
140
|
+
describe "Hooks in RequestProcessor" do
|
141
|
+
before do
|
142
142
|
@kid = mouse_mock(:kid)
|
143
143
|
@class = Class.new(Apotomo::RequestProcessor)
|
144
144
|
@class.instance_eval do
|
@@ -147,31 +147,31 @@ class RequestProcessorHooksTest < ActiveSupport::TestCase
|
|
147
147
|
end
|
148
148
|
@class.kid = @kid
|
149
149
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
150
|
+
|
151
|
+
describe ":after_initialize hook" do
|
152
|
+
it "be called after the has_widgets blocks invokation" do
|
153
153
|
@class.after_initialize do |r|
|
154
154
|
r.root[:mum] << self.class.kid # requires that :mum is there, yet.
|
155
155
|
end
|
156
|
-
|
157
|
-
@r = @class.new(parent_controller, {},
|
156
|
+
|
157
|
+
@r = @class.new(parent_controller, {},
|
158
158
|
[Proc.new { |root| root << widget(:mouse, :mum) }])
|
159
|
-
|
159
|
+
|
160
160
|
assert @r.root[:mum][:kid]
|
161
161
|
end
|
162
162
|
end
|
163
|
-
|
164
|
-
|
165
|
-
|
163
|
+
|
164
|
+
describe ":after_fire hook" do
|
165
|
+
it "be called in #process_for after fire" do
|
166
166
|
@class.after_fire do |r|
|
167
167
|
r.root[:mum] << self.class.kid
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
# DISCUSS: maybe add a trigger test here?
|
171
|
-
@r = @class.new(parent_controller, {},
|
171
|
+
@r = @class.new(parent_controller, {},
|
172
172
|
[Proc.new { |root| root << widget(:mouse, :mum) }])
|
173
173
|
@r.process_for(:source => "root", :type => :noop) # calls ~after_fire.
|
174
|
-
|
174
|
+
|
175
175
|
assert @r.root[:mum][:kid]
|
176
176
|
end
|
177
177
|
end
|
data/test/test_case_test.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'apotomo/test_case'
|
3
3
|
|
4
|
-
class TestCaseTest <
|
5
|
-
|
4
|
+
class TestCaseTest < MiniTest::Spec
|
5
|
+
|
6
6
|
class CommentsWidgetTest < Apotomo::TestCase
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
class CommentsWidget < Apotomo::Widget
|
10
10
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
|
12
|
+
describe "TestCase" do
|
13
|
+
|
14
|
+
describe "responding to #root" do
|
15
15
|
class MouseWidgetTest < Apotomo::TestCase
|
16
16
|
end
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
before do
|
19
19
|
@klass = MouseWidgetTest
|
20
20
|
@test = @klass.new(:widget).tap{ |t| t.setup }
|
21
21
|
@klass.has_widgets { |r| r << widget(:mouse, 'mum', :eating) }
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
|
24
|
+
it "respond to #root" do
|
25
25
|
assert_equal ['root', 'mum'], @test.root.collect { |w| w.name }
|
26
26
|
end
|
27
|
-
|
28
|
-
|
27
|
+
|
28
|
+
it "raise an error if no has_widgets block given" do
|
29
29
|
exc = assert_raises RuntimeError do
|
30
30
|
@test = Class.new(Apotomo::TestCase).new(:widget).tap{ |t| t.setup }
|
31
31
|
@test.root
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
assert_equal "Please setup a widget tree using has_widgets()", exc.message
|
35
35
|
end
|
36
|
-
|
37
|
-
|
36
|
+
|
37
|
+
it "memorize root" do
|
38
38
|
@test.root.visible=false
|
39
39
|
assert_equal false, @test.root.visible?
|
40
40
|
end
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
it "respond to #render_widget" do
|
43
43
|
assert_equal "<div id=\"mum\">burp!</div>\n", @test.render_widget('mum', :eat)
|
44
44
|
assert_equal "<div id=\"mum\">burp!</div>\n", @test.last_invoke
|
45
45
|
end
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
it "respond to #assert_select" do
|
48
48
|
@test.render_widget('mum', :eat)
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
|
50
|
+
@test.assert_select("div#mum", "burp!")
|
51
|
+
|
52
52
|
exc = assert_raises( MiniTest::Assertion){ @test.assert_select("div#mummy", "burp!"); }
|
53
|
-
|
53
|
+
assert_match /Expected at least 1 element matching "div#mummy", found 0/, exc.message
|
54
54
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
|
56
|
+
describe "using events" do
|
57
|
+
before do
|
58
58
|
@mum = @test.root['mum']
|
59
59
|
@mum.respond_to_event :footsteps, :with => :squeak
|
60
60
|
@mum.instance_eval do
|
@@ -63,28 +63,28 @@ class TestCaseTest < Test::Unit::TestCase
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
it "respond to #trigger" do
|
68
68
|
assert_equal ["{}"], @test.trigger(:footsteps, 'mum')
|
69
69
|
end
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
it "pass options from #trigger to the evt" do
|
72
72
|
assert_equal(["{:direction=>:kitchen}"] , @test.trigger(:footsteps, 'mum', :direction => :kitchen))
|
73
73
|
end
|
74
|
-
|
75
|
-
|
74
|
+
|
75
|
+
it "respond to #assert_response" do
|
76
76
|
@test.trigger(:footsteps, 'mum')
|
77
77
|
assert @test.assert_response("{}")
|
78
78
|
end
|
79
79
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
|
81
|
+
describe "#view_assigns" do
|
82
|
+
it "be emtpy when nothing was set" do
|
83
83
|
@test.render_widget('mum')
|
84
84
|
assert_equal({}, @test.view_assigns)
|
85
85
|
end
|
86
|
-
|
87
|
-
|
86
|
+
|
87
|
+
it "return the instance variables from the last #render_widget" do
|
88
88
|
@mum = @test.root['mum']
|
89
89
|
@mum.instance_eval do
|
90
90
|
def sleep
|
@@ -96,17 +96,17 @@ class TestCaseTest < Test::Unit::TestCase
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
|
100
|
+
describe "responding to parent_controller" do
|
101
|
+
before do
|
102
102
|
@test = Apotomo::TestCase.new(:widget).tap{ |t| t.setup }
|
103
103
|
end
|
104
|
-
|
105
|
-
|
104
|
+
|
105
|
+
it "provide a test controller" do
|
106
106
|
assert_kind_of ActionController::Base, @test.parent_controller
|
107
107
|
end
|
108
|
-
|
109
|
-
|
108
|
+
|
109
|
+
it "respond to #controller_path" do
|
110
110
|
assert_equal "barn", @test.parent_controller.controller_path
|
111
111
|
end
|
112
112
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
|
-
Bundler.setup
|
5
|
-
|
6
|
-
require 'shoulda'
|
1
|
+
require 'minitest/autorun'
|
7
2
|
|
8
3
|
ENV['RAILS_ENV'] = 'test'
|
9
4
|
require "dummy/config/environment"
|
@@ -18,10 +13,19 @@ Apotomo::Widget.append_view_path(File.expand_path(File.dirname(__FILE__) + "/wid
|
|
18
13
|
require "test_case_methods"
|
19
14
|
|
20
15
|
|
21
|
-
|
16
|
+
MiniTest::Spec.class_eval do
|
17
|
+
include Apotomo::WidgetShortcuts
|
18
|
+
include Apotomo::TestCaseMethods
|
19
|
+
|
20
|
+
def assert_not(assertion)
|
21
|
+
assert !assertion
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
ActiveSupport::TestCase.class_eval do
|
22
26
|
include Apotomo::WidgetShortcuts
|
23
27
|
include Apotomo::TestCaseMethods
|
24
|
-
|
28
|
+
|
25
29
|
def assert_not(assertion)
|
26
30
|
assert !assertion
|
27
31
|
end
|
@@ -30,7 +34,7 @@ end
|
|
30
34
|
class ApotomoController < ActionController::Base
|
31
35
|
include Apotomo::Rails::ControllerMethods
|
32
36
|
include Rails.application.routes.url_helpers
|
33
|
-
|
37
|
+
|
34
38
|
def mum
|
35
39
|
end
|
36
40
|
end
|
@@ -50,7 +54,7 @@ class MouseWidget < Apotomo::Widget
|
|
50
54
|
def eat
|
51
55
|
render
|
52
56
|
end
|
53
|
-
|
57
|
+
|
54
58
|
def display
|
55
59
|
end
|
56
60
|
end
|
data/test/tree_node_test.rb
CHANGED
@@ -1,19 +1,14 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class TreeNodeTest <
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
should "return true for #root? without parent" do
|
3
|
+
class TreeNodeTest < MiniTest::Spec
|
4
|
+
describe "initialization" do
|
5
|
+
it "return true for #root? without parent" do
|
10
6
|
assert MouseWidget.new(nil, :mum).root?
|
11
7
|
end
|
12
|
-
|
13
|
-
|
8
|
+
|
9
|
+
it "return false for #root? with parent" do
|
14
10
|
@mum = MouseWidget.new(nil, :mum)
|
15
11
|
assert_not MouseWidget.new(@mum, :kid).root?
|
16
12
|
end
|
17
|
-
|
18
13
|
end
|
19
14
|
end
|