controll 0.2.0 → 0.3.0

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 (174) hide show
  1. data/README.md +253 -93
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/controll.gemspec +121 -84
  5. data/lib/controll/assistant/param_assistant.rb +23 -0
  6. data/lib/controll/assistant/session_assistant.rb +23 -0
  7. data/lib/controll/assistant.rb +9 -7
  8. data/lib/controll/commander.rb +16 -3
  9. data/lib/controll/enabler/macros.rb +75 -0
  10. data/lib/controll/enabler/maps.rb +15 -0
  11. data/lib/controll/enabler/notify.rb +43 -0
  12. data/lib/controll/enabler/path_handler.rb +49 -0
  13. data/lib/controll/enabler/path_resolver.rb +47 -0
  14. data/lib/controll/enabler.rb +49 -0
  15. data/lib/controll/engine.rb +9 -0
  16. data/lib/controll/errors.rb +4 -1
  17. data/lib/controll/event/helper.rb +20 -0
  18. data/lib/controll/{helper/event_matcher.rb → event/matcher.rb} +3 -3
  19. data/lib/controll/event.rb +60 -0
  20. data/lib/controll/events.rb +48 -0
  21. data/lib/controll/executor/base.rb +3 -7
  22. data/lib/controll/executor/controlled.rb +36 -0
  23. data/lib/controll/executor/delegator.rb +6 -0
  24. data/lib/controll/executor.rb +8 -1
  25. data/lib/controll/flow/action/base.rb +30 -0
  26. data/lib/controll/flow/action/fallback.rb +25 -0
  27. data/lib/controll/flow/action/path_action.rb +24 -0
  28. data/lib/controll/flow/action.rb +7 -0
  29. data/lib/controll/flow/action_mapper/base.rb +13 -0
  30. data/lib/controll/flow/action_mapper/complex.rb +52 -0
  31. data/lib/controll/flow/action_mapper/simple.rb +54 -0
  32. data/lib/controll/flow/action_mapper.rb +7 -0
  33. data/lib/controll/flow/errors.rb +16 -0
  34. data/lib/controll/flow/event_mapper/path_finder.rb +36 -0
  35. data/lib/controll/flow/event_mapper/util.rb +43 -0
  36. data/lib/controll/flow/event_mapper.rb +6 -0
  37. data/lib/controll/flow/master/executor.rb +57 -0
  38. data/lib/controll/flow/master/macros.rb +66 -0
  39. data/lib/controll/flow/master.rb +70 -0
  40. data/lib/controll/flow.rb +15 -0
  41. data/lib/controll/focused/enabler.rb +31 -0
  42. data/lib/controll/helper.rb +0 -94
  43. data/lib/controll/macros.rb +12 -0
  44. data/lib/controll/notify/base.rb +22 -43
  45. data/lib/controll/notify/flash.rb +3 -3
  46. data/lib/controll/notify/macros.rb +57 -0
  47. data/lib/controll/notify/message/handler.rb +36 -0
  48. data/lib/controll/notify/message/resolver.rb +28 -0
  49. data/lib/controll/notify/message/translator.rb +45 -0
  50. data/lib/controll/notify/message.rb +25 -0
  51. data/lib/controll/notify/typed.rb +13 -22
  52. data/lib/controll/notify.rb +11 -4
  53. data/lib/controll.rb +8 -2
  54. data/lib/generators/controll/assistant_generator.rb +27 -0
  55. data/lib/generators/controll/executor_generator.rb +23 -0
  56. data/lib/generators/controll/flow_handler_generator.rb +21 -0
  57. data/lib/generators/controll/notifier_generator.rb +21 -0
  58. data/lib/generators/controll/setup_generator.rb +37 -0
  59. data/lib/generators/controll/templates/assistant.tt +10 -0
  60. data/lib/generators/controll/templates/commander.tt +15 -0
  61. data/lib/generators/controll/templates/executor.tt +14 -0
  62. data/lib/generators/controll/templates/flow_handler.tt +26 -0
  63. data/lib/generators/controll/templates/notifier.tt +31 -0
  64. data/spec/acceptance/app_test.rb +1 -1
  65. data/spec/controll/assistant/param_assistant_spec.rb +31 -0
  66. data/spec/controll/assistant/session_assistant_spec.rb +31 -0
  67. data/spec/controll/assistant_spec.rb +26 -0
  68. data/spec/controll/command_spec.rb +4 -4
  69. data/spec/controll/enabler/macros_spec.rb +76 -0
  70. data/spec/controll/enabler/maps_spec.rb +31 -0
  71. data/spec/controll/{helper → enabler}/notify_spec.rb +7 -17
  72. data/spec/controll/enabler/path_handler_spec.rb +24 -0
  73. data/spec/controll/enabler/path_resolver_spec.rb +87 -0
  74. data/spec/controll/enabler_spec.rb +30 -0
  75. data/spec/controll/event/helper_spec.rb +33 -0
  76. data/spec/controll/{helper/event_matcher_spec.rb → event/matcher_spec.rb} +4 -3
  77. data/spec/controll/event_spec.rb +66 -0
  78. data/spec/controll/events_spec.rb +23 -0
  79. data/spec/controll/executor/controlled_spec.rb +36 -0
  80. data/spec/controll/executor/{notificator_spec.rb → delegator_spec.rb} +4 -4
  81. data/spec/controll/flow/action_mapper/complex_spec.rb +102 -0
  82. data/spec/controll/flow/action_mapper/fallback_spec.rb +34 -0
  83. data/spec/controll/{flow_handler/render_spec.rb → flow/action_mapper/simple_spec.rb} +25 -22
  84. data/spec/controll/{flow_handler/redirect/action_spec.rb → flow/event_mapper/path_finder_spec.rb} +10 -10
  85. data/spec/controll/{flow_handler/redirect/mapper_spec.rb → flow/event_mapper/util_spec.rb} +9 -9
  86. data/spec/controll/flow/master/executor_spec.rb +56 -0
  87. data/spec/{app/app/models/.gitkeep → controll/flow/master/macros_spec.rb} +0 -0
  88. data/spec/controll/flow/master_spec.rb +157 -0
  89. data/spec/controll/notify/base_spec.rb +6 -12
  90. data/spec/controll/notify/message/handler_spec.rb +27 -0
  91. data/spec/controll/notify/message/resolver_spec.rb +53 -0
  92. data/spec/controll/notify/message/translator_spec.rb +46 -0
  93. data/spec/controll/notify/message_spec.rb +4 -0
  94. data/spec/controll/notify/{message_handler.rb → services_notifier.rb} +3 -5
  95. data/spec/controll/notify/typed_spec.rb +2 -2
  96. data/spec/{app → controll_app}/.gitignore +0 -0
  97. data/spec/{app → controll_app}/Gemfile +0 -0
  98. data/spec/{app → controll_app}/Gemfile.lock +0 -0
  99. data/spec/{app → controll_app}/README.rdoc +0 -0
  100. data/spec/{app → controll_app}/Rakefile +0 -0
  101. data/spec/controll_app/app/controll/commanders/services_commander.rb +5 -0
  102. data/spec/controll_app/app/controll/executors/services_executor.rb +4 -0
  103. data/spec/controll_app/app/controll/flows/create_services.rb +9 -0
  104. data/spec/controll_app/app/controll/notifiers/services_notifier.rb +9 -0
  105. data/spec/{app → controll_app}/app/controllers/application_controller.rb +0 -1
  106. data/spec/controll_app/app/controllers/services_controller.rb +8 -0
  107. data/spec/{app/lib/assets → controll_app/app/models}/.gitkeep +0 -0
  108. data/spec/{app → controll_app}/app/models/post.rb +0 -0
  109. data/spec/{app → controll_app}/app/views/layouts/application.html.erb +0 -0
  110. data/spec/{app → controll_app}/app/views/posts/_form.html.erb +0 -0
  111. data/spec/{app → controll_app}/app/views/posts/edit.html.erb +0 -0
  112. data/spec/{app → controll_app}/app/views/posts/index.html.erb +0 -0
  113. data/spec/{app → controll_app}/app/views/posts/new.html.erb +0 -0
  114. data/spec/{app → controll_app}/app/views/posts/show.html.erb +0 -0
  115. data/spec/{app → controll_app}/config/application.rb +1 -1
  116. data/spec/{app → controll_app}/config/boot.rb +0 -0
  117. data/spec/{app → controll_app}/config/environment.rb +0 -0
  118. data/spec/{app → controll_app}/config/environments/development.rb +0 -0
  119. data/spec/{app → controll_app}/config/environments/test.rb +0 -0
  120. data/spec/{app → controll_app}/config/initializers/backtrace_silencers.rb +0 -0
  121. data/spec/{app → controll_app}/config/initializers/inflections.rb +0 -0
  122. data/spec/{app → controll_app}/config/initializers/mime_types.rb +0 -0
  123. data/spec/{app → controll_app}/config/initializers/secret_token.rb +0 -0
  124. data/spec/{app → controll_app}/config/initializers/session_store.rb +0 -0
  125. data/spec/{app → controll_app}/config/locales/en.yml +0 -0
  126. data/spec/controll_app/config/routes.rb +5 -0
  127. data/spec/{app → controll_app}/config.ru +0 -0
  128. data/spec/{app → controll_app}/db/seeds.rb +0 -0
  129. data/spec/{app/lib/tasks → controll_app/log}/.gitkeep +0 -0
  130. data/spec/{app → controll_app}/public/404.html +0 -0
  131. data/spec/{app → controll_app}/public/422.html +0 -0
  132. data/spec/{app → controll_app}/public/500.html +0 -0
  133. data/spec/{app → controll_app}/public/favicon.ico +0 -0
  134. data/spec/{app → controll_app}/public/index.html +0 -0
  135. data/spec/{app → controll_app}/public/javascripts/application.js +0 -0
  136. data/spec/{app → controll_app}/public/robots.txt +0 -0
  137. data/spec/{app → controll_app}/public/stylesheets/application.css +0 -0
  138. metadata +122 -85
  139. data/lib/controll/executor/notificator.rb +0 -12
  140. data/lib/controll/flow_handler/base.rb +0 -19
  141. data/lib/controll/flow_handler/control.rb +0 -85
  142. data/lib/controll/flow_handler/errors.rb +0 -5
  143. data/lib/controll/flow_handler/event_helper.rb +0 -18
  144. data/lib/controll/flow_handler/redirect/action.rb +0 -45
  145. data/lib/controll/flow_handler/redirect/mapper.rb +0 -41
  146. data/lib/controll/flow_handler/redirect.rb +0 -51
  147. data/lib/controll/flow_handler/render.rb +0 -51
  148. data/lib/controll/flow_handler.rb +0 -11
  149. data/lib/controll/helper/notify.rb +0 -74
  150. data/lib/controll/helper/path_resolver.rb +0 -45
  151. data/spec/app/app/controllers/posts_controller.rb +0 -52
  152. data/spec/app/config/routes.rb +0 -62
  153. data/spec/app/log/.gitkeep +0 -0
  154. data/spec/app/script/rails +0 -6
  155. data/spec/app/spec/controllers/posts_controller_spec.rb +0 -59
  156. data/spec/app/spec/isolated_spec_helper.rb +0 -6
  157. data/spec/app/spec/spec_helper.rb +0 -5
  158. data/spec/app/spec/unit/controllers/posts_controller_isolated_spec.rb +0 -63
  159. data/spec/app/spec/unit/controllers/posts_controller_spec.rb +0 -59
  160. data/spec/app/test/functional/.gitkeep +0 -0
  161. data/spec/app/test/functional/posts_controller_test.rb +0 -67
  162. data/spec/app/test/isolated_test_helper.rb +0 -7
  163. data/spec/app/test/test_helper.rb +0 -6
  164. data/spec/app/test/unit/.gitkeep +0 -0
  165. data/spec/app/test/unit/controllers/posts_controller_isolated_test.rb +0 -71
  166. data/spec/app/test/unit/controllers/posts_controller_test.rb +0 -67
  167. data/spec/app/vendor/assets/javascripts/.gitkeep +0 -0
  168. data/spec/app/vendor/assets/stylesheets/.gitkeep +0 -0
  169. data/spec/app/vendor/plugins/.gitkeep +0 -0
  170. data/spec/controll/asssistant_spec.rb +0 -5
  171. data/spec/controll/flow_handler/control_spec.rb +0 -159
  172. data/spec/controll/flow_handler/redirect_spec.rb +0 -93
  173. data/spec/controll/helper/path_resolver_spec.rb +0 -49
  174. data/spec/controll/helper_spec.rb +0 -108
@@ -1,63 +0,0 @@
1
- require 'isolated_spec_helper'
2
- require APP_ROOT + '/controllers/application_controller'
3
- require APP_ROOT + '/controllers/posts_controller'
4
- require APP_ROOT + '/models/post'
5
-
6
- describe PostsController do
7
- include FocusedController::RSpecHelper
8
- stub_url :post, :posts
9
-
10
- before do
11
- @post = Post.create(:title => 'Hello', :body => 'Omg')
12
- end
13
-
14
- describe PostsController::Index do
15
- it "should get index" do
16
- req
17
- response.should be_success
18
- subject.posts.should_not be(:nil)
19
- end
20
- end
21
-
22
- describe PostsController::New do
23
- it "should get new" do
24
- req
25
- response.should be_success
26
- end
27
- end
28
-
29
- describe PostsController::Create do
30
- it "should create post" do
31
- expect { req :post => @post.attributes }.to change(Post, :count).by(1)
32
- response.should redirect_to(post_url(subject.post))
33
- end
34
- end
35
-
36
- describe PostsController::Show do
37
- it "should show post" do
38
- req :id => @post.id
39
- response.should be_success
40
- end
41
- end
42
-
43
- describe PostsController::Edit do
44
- it "should get edit" do
45
- req :id => @post.id
46
- response.should be_success
47
- end
48
- end
49
-
50
- describe PostsController::Update do
51
- it "should update post" do
52
- req :id => @post.id
53
- response.should redirect_to(post_url(subject.post))
54
- end
55
- end
56
-
57
- describe PostsController::Destroy do
58
- it "should destroy post" do
59
- expect { req :id => @post.id }.to change(Post, :count).by(-1)
60
- response.should redirect_to(posts_url)
61
- end
62
- end
63
- end
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PostsController do
4
- include FocusedController::RSpecHelper
5
-
6
- before do
7
- @post = Post.create(:title => 'Hello', :body => 'Omg')
8
- end
9
-
10
- describe PostsController::Index do
11
- it "should get index" do
12
- req
13
- response.should be_success
14
- subject.posts.should_not be(:nil)
15
- end
16
- end
17
-
18
- describe PostsController::New do
19
- it "should get new" do
20
- req
21
- response.should be_success
22
- end
23
- end
24
-
25
- describe PostsController::Create do
26
- it "should create post" do
27
- expect { req :post => @post.attributes }.to change(Post, :count).by(1)
28
- response.should redirect_to(post_path(subject.post))
29
- end
30
- end
31
-
32
- describe PostsController::Show do
33
- it "should show post" do
34
- req :id => @post.id
35
- response.should be_success
36
- end
37
- end
38
-
39
- describe PostsController::Edit do
40
- it "should get edit" do
41
- req :id => @post.id
42
- response.should be_success
43
- end
44
- end
45
-
46
- describe PostsController::Update do
47
- it "should update post" do
48
- req :id => @post.id
49
- response.should redirect_to(post_path(subject.post))
50
- end
51
- end
52
-
53
- describe PostsController::Destroy do
54
- it "should destroy post" do
55
- expect { req :id => @post.id }.to change(Post, :count).by(-1)
56
- response.should redirect_to(posts_path)
57
- end
58
- end
59
- end
File without changes
@@ -1,67 +0,0 @@
1
- require 'test_helper'
2
-
3
- module PostsController
4
- class TestCase < ActionController::TestCase
5
- include FocusedController::FunctionalTestHelper
6
-
7
- setup do
8
- @post = Post.create(:title => 'Hello', :body => 'Omg')
9
- end
10
- end
11
-
12
- class IndexTest < TestCase
13
- test "should get index" do
14
- get
15
- assert_response :success
16
- assert_not_nil @controller.posts
17
- end
18
- end
19
-
20
- class NewTest < TestCase
21
- test "should get new" do
22
- get
23
- assert_response :success
24
- end
25
- end
26
-
27
- class CreateTest < TestCase
28
- test "should create post" do
29
- assert_difference('Post.count') do
30
- post :post => @post.attributes
31
- end
32
-
33
- assert_redirected_to post_path(@controller.post)
34
- end
35
- end
36
-
37
- class ShowTest < TestCase
38
- test "should show post" do
39
- get :id => @post.id
40
- assert_response :success
41
- end
42
- end
43
-
44
- class EditTest < TestCase
45
- test "should get edit" do
46
- get :id => @post.id
47
- assert_response :success
48
- end
49
- end
50
-
51
- class UpdateTest < TestCase
52
- test "should update post" do
53
- put :id => @post.id, :post => @post.attributes
54
- assert_redirected_to post_path(@controller.post)
55
- end
56
- end
57
-
58
- class DestroyTest < TestCase
59
- test "should destroy post" do
60
- assert_difference('Post.count', -1) do
61
- delete :id => @post.id
62
- end
63
-
64
- assert_redirected_to posts_path
65
- end
66
- end
67
- end
@@ -1,7 +0,0 @@
1
- require 'bundler/setup'
2
- require 'test/unit'
3
- require 'active_support/test_case'
4
- require 'focused_controller/test_helper'
5
-
6
- APP_ROOT = File.expand_path('../../app', __FILE__)
7
- POSTS = []
@@ -1,6 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rails/test_help'
4
-
5
- require 'focused_controller/functional_test_helper'
6
- require 'focused_controller/test_helper'
File without changes
@@ -1,71 +0,0 @@
1
- require 'isolated_test_helper'
2
- require APP_ROOT + '/controllers/application_controller'
3
- require APP_ROOT + '/controllers/posts_controller'
4
- require APP_ROOT + '/models/post'
5
-
6
- module PostsController
7
- class TestCase < ActiveSupport::TestCase
8
- include FocusedController::TestHelper
9
- stub_url :post, :posts
10
-
11
- setup do
12
- @post = Post.create(:title => 'Hello', :body => 'Omg')
13
- end
14
- end
15
-
16
- class IndexTest < TestCase
17
- test "should get index" do
18
- req
19
- assert_response :success
20
- assert_not_nil controller.posts
21
- end
22
- end
23
-
24
- class NewTest < TestCase
25
- test "should get new" do
26
- req
27
- assert_response :success
28
- end
29
- end
30
-
31
- class CreateTest < TestCase
32
- test "should create post" do
33
- assert_difference('Post.count') do
34
- req :post => @post.attributes
35
- end
36
-
37
- assert_redirected_to post_url(controller.post)
38
- end
39
- end
40
-
41
- class ShowTest < TestCase
42
- test "should show post" do
43
- req :id => @post.id
44
- assert_response :success
45
- end
46
- end
47
-
48
- class EditTest < TestCase
49
- test "should get edit" do
50
- req :id => @post.id
51
- assert_response :success
52
- end
53
- end
54
-
55
- class UpdateTest < TestCase
56
- test "should update post" do
57
- req :id => @post.id
58
- assert_redirected_to post_url(controller.post)
59
- end
60
- end
61
-
62
- class DestroyTest < TestCase
63
- test "should destroy post" do
64
- assert_difference('Post.count', -1) do
65
- req :id => @post.id
66
- end
67
-
68
- assert_redirected_to posts_url
69
- end
70
- end
71
- end
@@ -1,67 +0,0 @@
1
- require 'test_helper'
2
-
3
- module PostsController
4
- class TestCase < ActiveSupport::TestCase
5
- include FocusedController::TestHelper
6
-
7
- setup do
8
- @post = Post.create(:title => 'Hello', :body => 'Omg')
9
- end
10
- end
11
-
12
- class IndexTest < TestCase
13
- test "should get index" do
14
- req
15
- assert_response :success
16
- assert_not_nil controller.posts
17
- end
18
- end
19
-
20
- class NewTest < TestCase
21
- test "should get new" do
22
- req
23
- assert_response :success
24
- end
25
- end
26
-
27
- class CreateTest < TestCase
28
- test "should create post" do
29
- assert_difference('Post.count') do
30
- req :post => @post.attributes
31
- end
32
-
33
- assert_redirected_to post_path(controller.post)
34
- end
35
- end
36
-
37
- class ShowTest < TestCase
38
- test "should show post" do
39
- req :id => @post.id
40
- assert_response :success
41
- end
42
- end
43
-
44
- class EditTest < TestCase
45
- test "should get edit" do
46
- req :id => @post.id
47
- assert_response :success
48
- end
49
- end
50
-
51
- class UpdateTest < TestCase
52
- test "should update post" do
53
- req :id => @post.id
54
- assert_redirected_to post_path(controller.post)
55
- end
56
- end
57
-
58
- class DestroyTest < TestCase
59
- test "should destroy post" do
60
- assert_difference('Post.count', -1) do
61
- req :id => @post.id
62
- end
63
-
64
- assert_redirected_to posts_path
65
- end
66
- end
67
- end
File without changes
File without changes
File without changes
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Controll::Assistant do
4
- pending 'TODO'
5
- end
@@ -1,159 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module MyController
4
- class Update
5
- def render path
6
- send(path) if path
7
- end
8
-
9
- def default
10
- 'default'
11
- end
12
- end
13
- end
14
-
15
- class EmptyEventFlowHandler < Controll::FlowHandler::Control
16
- def event
17
- end
18
- end
19
-
20
- class UpdateEventWithoutHandlerMapping < Controll::FlowHandler::Control
21
- def event
22
- :update
23
- end
24
- end
25
-
26
- class UpdateEventFlowHandler < Controll::FlowHandler::Control
27
- def event
28
- :update
29
- end
30
-
31
- class Render < Controll::FlowHandler::Render
32
- set_events :update
33
- set_default_path 'default'
34
- end
35
- end
36
-
37
- class UpdateEventNoMatchFlowHandler < Controll::FlowHandler::Control
38
- def event
39
- :update
40
- end
41
-
42
- class Render < Controll::FlowHandler::Render
43
- set_events :create
44
- set_default_path '/default'
45
- end
46
- end
47
-
48
-
49
-
50
- describe Controll::FlowHandler::Control do
51
- context 'use directly without sublclassing' do
52
- subject { flow_handler.new controller }
53
-
54
- let(:flow_handler) { Controll::FlowHandler::Control }
55
- let(:controller) { MyController::Update.new }
56
-
57
- describe '.initialize' do
58
- specify do
59
- subject.controller.should == controller
60
- end
61
- end
62
-
63
- describe '.execute' do
64
- specify do
65
- expect { subject.execute }.to_not raise_error
66
- end
67
- end
68
- end
69
-
70
- context 'A Control FlowHandler with empty #event method' do
71
- subject { flow_handler.new controller }
72
-
73
- let(:flow_handler) { EmptyEventFlowHandler }
74
- let(:controller) { MyController::Update.new }
75
-
76
- describe '.initialize' do
77
- specify do
78
- subject.controller.should == controller
79
- end
80
- end
81
-
82
- describe '.execute' do
83
- specify do
84
- expect { subject.execute }.to_not raise_error(NotImplementedError)
85
- end
86
-
87
- # since event returns nil
88
- specify do
89
- expect { subject.execute }.to_not raise_error
90
- end
91
- end
92
- end
93
-
94
- context 'A Control FlowHandler where #event returns :update notice event' do
95
- subject { flow_handler.new controller }
96
-
97
- let(:flow_handler) { UpdateEventWithoutHandlerMapping }
98
- let(:controller) { MyController::Update.new }
99
-
100
- describe '.initialize' do
101
- specify do
102
- subject.controller.should == controller
103
- end
104
- end
105
-
106
- describe '.execute' do
107
- # since event returns nil
108
- specify do
109
- expect { subject.execute }.to_not raise_error
110
- end
111
- end
112
- end
113
-
114
- context 'A Control FlowHandler where #event returns :update notice event and has a Render class with matching mapping' do
115
- subject { flow_handler.new controller }
116
-
117
- let(:flow_handler) { UpdateEventFlowHandler }
118
- let(:controller) { MyController::Update.new }
119
-
120
- describe '.initialize' do
121
- specify do
122
- subject.controller.should == controller
123
- end
124
- end
125
-
126
- describe '.execute' do
127
- # since event returns nil
128
- specify do
129
- expect { subject.execute }.to_not raise_error(Controll::FlowHandler::Control::ActionEventError)
130
- end
131
-
132
- specify do
133
- subject.execute
134
- subject.executed?.should be_true
135
- end
136
- end
137
- end
138
-
139
- context 'A Control FlowHandler where #event returns :update notice event and has a Render class with NO matching mapping' do
140
- subject { flow_handler.new controller }
141
-
142
- let(:flow_handler) { UpdateEventNoMatchFlowHandler }
143
- let(:controller) { MyController::Update.new }
144
-
145
- describe '.initialize' do
146
- specify do
147
- subject.controller.should == controller
148
- end
149
- end
150
-
151
- describe '.execute' do
152
- # since event returns nil
153
- specify do
154
- expect { subject.execute }.to_not raise_error
155
- end
156
- end
157
- end
158
-
159
- end
@@ -1,93 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class HelloToWelcomeRedirect < Controll::FlowHandler::Redirect
4
- set_redirections :welcome => [:hello, :hi]
5
- end
6
-
7
- class ErrorBadRedirect < Controll::FlowHandler::Redirect
8
- set_redirections :error, bad: ['bad_payment', 'wrong_payment']
9
- end
10
-
11
- def notification name
12
- Hashie::Mash.new(name: name.to_sym, type: :notice)
13
- end
14
-
15
- def error name
16
- Hashie::Mash.new(name: name.to_sym, type: :error)
17
- end
18
-
19
- describe Controll::FlowHandler::Redirect do
20
-
21
- describe 'class macros' do
22
- before :all do
23
- ErrorBadRedirect.set_redirections :error, crap: ['bad_payment', 'wrong_payment']
24
- end
25
-
26
- specify {
27
- ErrorBadRedirect.redirections_for(:error).should == {crap: ['bad_payment', 'wrong_payment']}
28
- }
29
-
30
- specify {
31
- ErrorBadRedirect.redirections.should == {error: {crap: ['bad_payment', 'wrong_payment']} }
32
- }
33
- end
34
-
35
- # context 'use directly without subclassing' do
36
- # subject { clazz.new '/' }
37
-
38
- # let(:clazz) { Controll::FlowHandler::Redirect }
39
-
40
- # let(:hello) { notification :hello }
41
-
42
- # describe '.action event' do
43
- # specify do
44
- # expect { clazz.action(:hello) }.to raise_error(Controll::FlowHandler::Redirect::NoRedirectionFoundError)
45
- # end
46
- # end
47
- # end
48
-
49
- # context 'HelloToWelcomeRedirect subclass' do
50
- # subject { clazz.new '/' }
51
-
52
- # let(:clazz) { HelloToWelcomeRedirect }
53
-
54
- # context 'has redirections' do
55
- # describe '.action event' do
56
- # specify do
57
- # expect { clazz.action(:hello) }.to_not raise_error(Controll::FlowHandler::Redirect::NoRedirectionFoundError)
58
- # end
59
-
60
- # specify do
61
- # clazz.action(:hello).should be_a HelloToWelcomeRedirect
62
- # end
63
-
64
- # specify do
65
- # clazz.action(:hi).path.should == 'welcome'
66
- # end
67
- # end
68
- # end
69
- # end
70
-
71
- context 'ErrorBadRedirect subclass' do
72
- subject { clazz.new '/' }
73
-
74
- let(:clazz) { ErrorBadRedirect }
75
-
76
- context 'has error redirections' do
77
- describe '.action event' do
78
- specify do
79
- expect { clazz.action(:hello) }.to raise_error(Controll::FlowHandler::NoRedirectionFoundError)
80
- end
81
-
82
- specify do
83
- clazz.action(error :bad_payment).should be_a ErrorBadRedirect
84
- end
85
-
86
- specify do
87
- clazz.action(error :wrong_payment).path.should == 'crap'
88
- end
89
- end
90
- end
91
- end
92
-
93
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class MySweetController
4
- include Controll::Helper
5
-
6
- redirect_map :index => %w{success}
7
-
8
- render_map :show => %w{success}
9
-
10
- # Mocking!
11
- def render path
12
- path
13
- end
14
- alias_method :redirect_to, :render
15
- end
16
-
17
- describe Controll::Helper::PathResolver do
18
- subject { Controll::Helper::PathResolver.new controller }
19
-
20
- let(:controller) { MySweetController.new }
21
-
22
- describe '.extract_path' do
23
- describe ':redirect_map' do
24
- specify do
25
- subject.extract_path(:redirect_map).should == 'index'
26
- end
27
- end
28
-
29
- describe ':render_paths' do
30
- specify do
31
- subject.extract_path(:render_paths).should == 'show'
32
- end
33
- end
34
- end
35
-
36
- describe '.resolve_path' do
37
- describe ':redirect_map' do
38
- specify do
39
- subject.resolve_path(:redirect_map).should == 'index'
40
- end
41
- end
42
-
43
- describe ':render_paths' do
44
- specify do
45
- subject.resolve_path(:render_paths).should == 'show'
46
- end
47
- end
48
- end
49
- end