apotomo 1.2.3 → 1.2.4

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -3
  3. data/.travis.yml +6 -8
  4. data/CHANGES.textile +9 -5
  5. data/README.md +211 -0
  6. data/apotomo.gemspec +4 -4
  7. data/config/routes.rb +1 -1
  8. data/gemfiles/Gemfile.rails3-0 +6 -0
  9. data/gemfiles/Gemfile.rails3-1 +6 -0
  10. data/gemfiles/Gemfile.rails3-2 +6 -0
  11. data/gemfiles/Gemfile.rails4-0 +6 -0
  12. data/lib/apotomo/javascript_generator.rb +3 -3
  13. data/lib/apotomo/test_case.rb +14 -8
  14. data/lib/apotomo/version.rb +1 -1
  15. data/lib/apotomo/widget/javascript_methods.rb +3 -3
  16. data/lib/apotomo/widget/tree_node.rb +1 -1
  17. data/lib/apotomo/widget.rb +3 -3
  18. data/lib/generators/apotomo/widget_generator.rb +1 -1
  19. data/lib/generators/templates/view.slim +3 -4
  20. data/test/apotomo_test.rb +25 -14
  21. data/test/dummy/config/routes.rb +2 -57
  22. data/test/event_handler_test.rb +30 -60
  23. data/test/event_methods_test.rb +62 -62
  24. data/test/event_test.rb +11 -11
  25. data/test/invoke_event_handler_test.rb +59 -0
  26. data/test/javascript_generator_test.rb +57 -72
  27. data/test/rails/caching_test.rb +11 -11
  28. data/test/rails/controller_methods_test.rb +63 -57
  29. data/test/rails/rails_integration_test.rb +47 -47
  30. data/test/rails/view_helper_test.rb +31 -26
  31. data/test/rails/widget_generator_test.rb +16 -16
  32. data/test/render_test.rb +50 -50
  33. data/test/request_processor_test.rb +74 -74
  34. data/test/test_case_test.rb +45 -45
  35. data/test/test_helper.rb +14 -10
  36. data/test/tree_node_test.rb +5 -10
  37. data/test/widget_shortcuts_test.rb +25 -25
  38. data/test/widget_test.rb +82 -80
  39. metadata +73 -49
  40. data/README.rdoc +0 -205
  41. data/TODO +0 -36
  42. data/lib/apotomo/proc_event_handler.rb +0 -18
  43. data/test/onfire_integration_test.rb +0 -22
@@ -3,61 +3,61 @@ require 'test_helper'
3
3
  class MumWidget < MouseWidget; end
4
4
  class MouseTabsWidget;end
5
5
 
6
- class WidgetShortcutsTest < Test::Unit::TestCase
7
- context "FactoryProxy" do
8
- setup do
6
+ class WidgetShortcutsTest < MiniTest::Spec
7
+ describe "FactoryProxy" do
8
+ before do
9
9
  @factory = Apotomo::WidgetShortcuts::FactoryProxy
10
10
  end
11
-
12
- context "#constant_for" do
13
- setup do
11
+
12
+ describe "#constant_for" do
13
+ before do
14
14
  @dsl = @factory.new(:class, :id)
15
15
  end
16
-
17
- should "constantize symbols" do
16
+
17
+ it "constantize symbols" do
18
18
  assert_equal MouseWidget, @dsl.send(:constant_for, :mouse)
19
19
  end
20
-
21
- should "not try to singularize the widget class" do
20
+
21
+ it "not try to singularize the widget class" do
22
22
  assert_equal MouseTabsWidget, @dsl.send(:constant_for, :mouse_tabs)
23
23
  end
24
24
  end
25
-
26
- context "#widget and #<<" do
27
- setup do
25
+
26
+ describe "#widget and #<<" do
27
+ before do
28
28
  @root = Apotomo::Widget.new(nil, :root)
29
29
  end
30
-
31
- context "with all arguments" do
32
- should "create a MumWidget instance with options" do
30
+
31
+ describe "with all arguments" do
32
+ it "create a MumWidget instance with options" do
33
33
  proxy = widget(:mum, :mummy, :eating, :color => 'grey', :type => :hungry)
34
34
  @root << proxy
35
-
35
+
36
36
  assert_kind_of MumWidget, @root[:mummy]
37
37
  assert_equal :mummy, @root[:mummy].name
38
38
  assert_equal({:color => "grey", :type => :hungry}, @root[:mummy].options)
39
39
  end
40
40
  end
41
-
42
- should "not set options with 2 arguments" do
41
+
42
+ it "not set options with 2 arguments" do
43
43
  @root << widget(:mum, :mummy)
44
44
  @mum = @root[:mummy]
45
-
45
+
46
46
  assert_kind_of MumWidget, @mum
47
47
  assert_equal :mummy, @mum.widget_id
48
48
  assert_equal({}, @mum.options)
49
49
  end
50
-
51
- should "set defaults with prefix, only" do
50
+
51
+ it "set defaults with prefix, only" do
52
52
  @root << widget(:mum)
53
53
  @mum = @root[:mum]
54
-
54
+
55
55
  assert_kind_of MumWidget, @mum
56
56
  assert_equal :mum, @mum.name
57
57
  assert_equal({}, @mum.options)
58
58
  end
59
-
60
- should "yield itself" do
59
+
60
+ it "yield itself" do
61
61
  ficken = widget(:mum) do |mum|
62
62
  mum << widget(:mouse, :kid)
63
63
  end
data/test/widget_test.rb CHANGED
@@ -1,191 +1,193 @@
1
1
  require 'test_helper'
2
2
 
3
- class WidgetTest < ActiveSupport::TestCase
3
+ class WidgetTest < MiniTest::Spec
4
4
  include Apotomo::TestCaseMethods::TestController
5
-
6
- context "The constructor" do
7
- should "accept the parent_controller as first arg" do
5
+
6
+ describe "The constructor" do
7
+ it "accept the parent_controller as first arg" do
8
8
  assert_kind_of ActionController::Base, @controller
9
9
  @mum = Apotomo::Widget.new(@controller, 'mum', :squeak)
10
10
  end
11
11
  end
12
12
 
13
- context "Widget.has_widgets" do
14
- setup do
13
+ describe "Widget.has_widgets" do
14
+ before do
15
15
  @mum = Class.new(MouseWidget) do
16
16
  has_widgets do |me|
17
17
  me << widget(:mouse, :baby)
18
18
  #MouseWidget.new(me, :baby) # this is also possible.
19
19
  end
20
20
  end.new(@controller, 'mum')
21
-
21
+
22
22
  @kid = Class.new(@mum.class).new(@controller, 'mum')
23
23
  end
24
-
25
- should "setup the widget family at creation time" do
24
+
25
+ it "before the widget family at creation time" do
26
26
  assert_equal 1, @mum.children.size
27
27
  assert_kind_of MouseWidget, @mum[:baby]
28
28
  end
29
-
30
- should "inherit trees for now" do
29
+
30
+ it "inherit trees for now" do
31
31
  assert_equal 1, @mum.children.size
32
32
  assert_kind_of MouseWidget, @mum[:baby]
33
33
  end
34
34
  end
35
-
36
-
37
- context "A widget" do
38
- setup do
35
+
36
+
37
+ describe "A widget" do
38
+ before do
39
39
  @mum = Apotomo::Widget.new(@controller, 'mum', :squeak)
40
40
  end
41
-
42
- context "responding to #address_for_event" do
43
- should "accept an event :type" do
41
+
42
+ describe "responding to #address_for_event" do
43
+ it "accept an event :type" do
44
44
  assert_equal({:source=>"mum", :type=>:squeak, :controller=>"barn"}, @mum.address_for_event(:squeak))
45
45
  end
46
-
47
- should "accept a :source" do
46
+
47
+ it "accept a :source" do
48
48
  assert_equal({:source=>"kid", :type=>:squeak, :controller=>"barn"}, @mum.address_for_event(:squeak, :source => 'kid'))
49
49
  end
50
-
51
- should "accept arbitrary options" do
50
+
51
+ it "accept arbitrary options" do
52
52
  assert_equal({:volume=>"loud", :source=>"mum", :type=>:squeak, :controller=>"barn"}, @mum.address_for_event(:squeak, :volume => 'loud'))
53
53
  end
54
-
55
- should "work with controller namespaces" do
54
+
55
+ it "work with controller namespaces" do
56
56
  @mum = Apotomo::Widget.new(namespaced_controller, 'mum', :squeak)
57
57
  assert_equal({:source=>"mum", :type=>:squeak, :controller=>"farm/barn"}, @mum.address_for_event(:squeak))
58
58
  end
59
59
  end
60
-
61
- context "implementing visibility" do
62
- should "per default respond to #visible?" do
60
+
61
+ describe "implementing visibility" do
62
+ it "per default respond to #visible?" do
63
63
  assert @mum.visible?
64
64
  end
65
-
66
- should "expose a setter therefore" do
65
+
66
+ it "expose a setter therefore" do
67
67
  @mum.visible = false
68
68
  assert_not @mum.visible?
69
69
  end
70
70
  end
71
-
72
- context "#find_widget" do
73
- setup do
71
+
72
+ describe "#find_widget" do
73
+ before do
74
74
  mum_and_kid!
75
75
  end
76
-
77
- should "find itself" do
76
+
77
+ it "find itself" do
78
78
  assert_equal @mum, @mum.find_widget('mum')
79
79
  end
80
-
81
- should "return nil for not-existant widgets" do
80
+
81
+ it "return nil for not-existant widgets" do
82
82
  assert_nil @mum.find_widget('pet')
83
83
  end
84
-
85
- should "find children" do
84
+
85
+ it "find children" do
86
86
  assert_equal @kid, @mum.find_widget('kid')
87
87
  end
88
-
89
- should "find treat 'id' and :id the same" do
88
+
89
+ it "find treat 'id' and :id the same" do
90
90
  assert_equal @mum.find_widget(:kid), @mum.find_widget('kid')
91
91
  end
92
92
  end
93
-
94
- should "respond to the WidgetShortcuts methods, like #widget" do
93
+
94
+ it "respond to the WidgetShortcuts methods, like #widget" do
95
95
  assert_respond_to @mum, :widget
96
96
  end
97
-
98
- should "respond to #parent_controller and return the AC in root" do
97
+
98
+ it "respond to #parent_controller and return the AC in root" do
99
99
  @mum << mouse_mock(:kid)
100
100
  assert_equal @controller, @mum.parent_controller
101
101
  assert_equal @controller, @mum[:kid].parent_controller
102
102
  end
103
-
104
- should "alias #widget_id to #name" do
103
+
104
+ it "alias #widget_id to #name" do
105
105
  assert_equal @mum.name, @mum.widget_id
106
106
  end
107
-
108
- should "respond to DEFAULT_VIEW_PATHS" do
107
+
108
+ it "respond to DEFAULT_VIEW_PATHS" do
109
109
  assert_equal ["app/widgets"], Apotomo::Widget::DEFAULT_VIEW_PATHS
110
110
  end
111
-
112
- should "respond to .view_paths" do
113
- if Cells.rails3_2_or_more?
111
+
112
+ it "respond to .view_paths" do
113
+ if Cell.rails3_2_or_more?
114
114
  assert_equal ActionView::PathSet.new(Apotomo::Widget::DEFAULT_VIEW_PATHS + ["test/widgets"]).paths, Apotomo::Widget.view_paths.paths
115
+ elsif Cell.rails4_0_or_more?
116
+ Apotomo::Widget.view_paths.paths.to_s.must_match("app/widgets")
115
117
  else
116
118
  assert_equal ActionView::PathSet.new(Apotomo::Widget::DEFAULT_VIEW_PATHS + ["test/widgets"]), Apotomo::Widget.view_paths
117
119
  end
118
120
  end
119
-
120
- should "respond to .controller_path" do
121
+
122
+ it "respond to .controller_path" do
121
123
  assert_equal "mouse", MouseWidget.controller_path
122
124
  end
123
-
125
+
124
126
  # internal_methods:
125
- should "not list internal methods in action_methods" do
127
+ it "not list internal methods in action_methods" do
126
128
  # FIXME: puts "WTF is wrong again with AC.action_methods godamn, I HATE this magic shit!"
127
- unless Cells.rails3_1_or_more?
128
- assert_equal [], Class.new(Apotomo::Widget).action_methods
129
+ unless Cell.rails3_1_or_more?
130
+ assert Class.new(Apotomo::Widget).action_methods.empty?
129
131
  end
130
132
  end
131
-
132
- should "list both local and inherited states in Widget.action_methods" do
133
+
134
+ it "list both local and inherited states in Widget.action_methods" do
133
135
  assert MouseWidget.action_methods.collect{ |m| m.to_s }.include?("squeak")
134
136
  assert Class.new(MouseWidget).action_methods.collect{ |m| m.to_s }.include?("squeak")
135
137
  end
136
-
137
- should "not list #display in internal_methods although it's defined in Object" do
138
+
139
+ it "not list #display in internal_methods although it's defined in Object" do
138
140
  assert_not Apotomo::Widget.internal_methods.include?(:display)
139
141
  end
140
142
  end
141
143
  end
142
-
144
+
143
145
 
144
146
  class RenderWidgetTest < ActiveSupport::TestCase
145
147
  include Apotomo::TestCaseMethods::TestController
146
-
147
- context "#render_widget" do
148
- should "allow passing widget id" do
148
+
149
+ describe "#render_widget" do
150
+ it "allow passing widget id" do
149
151
  assert_equal "squeak!", mouse.render_widget('mouse', :squeak)
150
152
  end
151
-
152
- should "allow passing widget instance" do
153
+
154
+ it "allow passing widget instance" do
153
155
  assert_equal 'squeak!', mouse.render_widget(mouse(:mum), :squeak)
154
156
  end
155
-
156
- should "use :display as standard state" do
157
+
158
+ it "use :display as standard state" do
157
159
  mum = mouse('Mum') do
158
160
  def display
159
161
  render :text => "#{widget_id}, that's me!"
160
162
  end
161
163
  end
162
-
164
+
163
165
  assert_equal "Mum, that's me!", mouse.render_widget(mum)
164
166
  end
165
-
166
- should "raise an exception when a non-existent widget id is passed" do
167
+
168
+ it "raise an exception when a non-existent widget id is passed" do
167
169
  e = assert_raises RuntimeError do
168
170
  mouse.render_widget('mummy')
169
171
  end
170
-
172
+
171
173
  assert_equal "Couldn't render non-existent widget `mummy`", e.message
172
174
  end
173
-
174
- should "pass options as state-args" do
175
+
176
+ it "pass options as state-args" do
175
177
  mum = mouse do
176
178
  def display(color="grey")
177
179
  render :text => "I'm #{color}"
178
180
  end
179
181
  end
180
-
182
+
181
183
  assert_equal("I'm grey", mouse.render_widget(mum), "default value in state-arg didn't work")
182
184
  assert_equal("I'm black", mouse.render_widget(mum, :display, "black"))
183
185
  end
184
-
185
- should "use #find_widget from self to find the passed widget id" do
186
+
187
+ it "use #find_widget from self to find the passed widget id" do
186
188
  mum = mouse << mouse_mock(:kid)
187
-
189
+
188
190
  assert_equal "<div id=\"kid\">burp!</div>\n", mum.render_widget(:kid, :eat)
189
- end
191
+ end
190
192
  end
191
193
  end
metadata CHANGED
@@ -1,104 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apotomo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
5
- prerelease:
4
+ version: 1.2.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nick Sutterer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-05-08 00:00:00.000000000 Z
11
+ date: 2013-10-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: cells
16
- requirement: &74978860 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.6.7
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *74978860
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.6.7
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: onfire
27
- requirement: &74978510 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: 0.2.0
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *74978510
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: hooks
38
- requirement: &74978060 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
- version: 0.2.0
47
+ version: 0.3.0
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *74978060
47
- - !ruby/object:Gem::Dependency
48
- name: shoulda
49
- requirement: &74977250 !ruby/object:Gem::Requirement
50
- none: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *74977250
54
+ version: 0.3.0
58
55
  - !ruby/object:Gem::Dependency
59
56
  name: rake
60
- requirement: &74976840 !ruby/object:Gem::Requirement
61
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
62
58
  requirements:
63
- - - ! '>='
59
+ - - '>='
64
60
  - !ruby/object:Gem::Version
65
61
  version: '0'
66
62
  type: :development
67
63
  prerelease: false
68
- version_requirements: *74976840
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: slim
71
- requirement: &74966910 !ruby/object:Gem::Requirement
72
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
73
72
  requirements:
74
- - - ! '>='
73
+ - - '>='
75
74
  - !ruby/object:Gem::Version
76
75
  version: '0'
77
76
  type: :development
78
77
  prerelease: false
79
- version_requirements: *74966910
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
80
83
  - !ruby/object:Gem::Dependency
81
84
  name: haml
82
- requirement: &74966580 !ruby/object:Gem::Requirement
83
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
84
86
  requirements:
85
- - - ! '>='
87
+ - - '>='
86
88
  - !ruby/object:Gem::Version
87
89
  version: '0'
88
90
  type: :development
89
91
  prerelease: false
90
- version_requirements: *74966580
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
91
97
  - !ruby/object:Gem::Dependency
92
98
  name: tzinfo
93
- requirement: &74966340 !ruby/object:Gem::Requirement
94
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
95
100
  requirements:
96
- - - ! '>='
101
+ - - '>='
97
102
  - !ruby/object:Gem::Version
98
103
  version: '0'
99
104
  type: :development
100
105
  prerelease: false
101
- version_requirements: *74966340
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 4.7.5
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 4.7.5
102
125
  description: Web component framework for Rails providing widgets that trigger events
103
126
  and know when and how to update themselves with AJAX.
104
127
  email:
@@ -111,11 +134,14 @@ files:
111
134
  - .travis.yml
112
135
  - CHANGES.textile
113
136
  - Gemfile
114
- - README.rdoc
137
+ - README.md
115
138
  - Rakefile
116
- - TODO
117
139
  - apotomo.gemspec
118
140
  - config/routes.rb
141
+ - gemfiles/Gemfile.rails3-0
142
+ - gemfiles/Gemfile.rails3-1
143
+ - gemfiles/Gemfile.rails3-2
144
+ - gemfiles/Gemfile.rails4-0
119
145
  - lib/apotomo.rb
120
146
  - lib/apotomo/apotomo.rake
121
147
  - lib/apotomo/debugging.rb
@@ -123,7 +149,6 @@ files:
123
149
  - lib/apotomo/event_handler.rb
124
150
  - lib/apotomo/invoke_event_handler.rb
125
151
  - lib/apotomo/javascript_generator.rb
126
- - lib/apotomo/proc_event_handler.rb
127
152
  - lib/apotomo/rails/controller_methods.rb
128
153
  - lib/apotomo/rails/view_helper.rb
129
154
  - lib/apotomo/railtie.rb
@@ -175,8 +200,8 @@ files:
175
200
  - test/event_handler_test.rb
176
201
  - test/event_methods_test.rb
177
202
  - test/event_test.rb
203
+ - test/invoke_event_handler_test.rb
178
204
  - test/javascript_generator_test.rb
179
- - test/onfire_integration_test.rb
180
205
  - test/rails/caching_test.rb
181
206
  - test/rails/controller_methods_test.rb
182
207
  - test/rails/rails_integration_test.rb
@@ -198,26 +223,25 @@ files:
198
223
  - test/widgets/mouse/snuggle.html.erb
199
224
  homepage: http://github.com/apotonick/apotomo
200
225
  licenses: []
226
+ metadata: {}
201
227
  post_install_message:
202
228
  rdoc_options: []
203
229
  require_paths:
204
230
  - lib
205
231
  required_ruby_version: !ruby/object:Gem::Requirement
206
- none: false
207
232
  requirements:
208
- - - ! '>='
233
+ - - '>='
209
234
  - !ruby/object:Gem::Version
210
235
  version: '0'
211
236
  required_rubygems_version: !ruby/object:Gem::Requirement
212
- none: false
213
237
  requirements:
214
- - - ! '>='
238
+ - - '>='
215
239
  - !ruby/object:Gem::Version
216
240
  version: '0'
217
241
  requirements: []
218
242
  rubyforge_project:
219
- rubygems_version: 1.8.10
243
+ rubygems_version: 2.0.3
220
244
  signing_key:
221
- specification_version: 3
245
+ specification_version: 4
222
246
  summary: Web components for Rails.
223
247
  test_files: []