aldous 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.irbrc +3 -0
  4. data/.rspec +3 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +591 -0
  9. data/Rakefile +1 -0
  10. data/aldous.gemspec +24 -0
  11. data/examples/basic_todo/.foreman +1 -0
  12. data/examples/basic_todo/.gitignore +16 -0
  13. data/examples/basic_todo/.rspec +3 -0
  14. data/examples/basic_todo/.ruby-version +2 -0
  15. data/examples/basic_todo/Gemfile +52 -0
  16. data/examples/basic_todo/Procfile +1 -0
  17. data/examples/basic_todo/README.rdoc +28 -0
  18. data/examples/basic_todo/Rakefile +6 -0
  19. data/examples/basic_todo/app/assets/images/.keep +0 -0
  20. data/examples/basic_todo/app/assets/javascripts/application.js +13 -0
  21. data/examples/basic_todo/app/assets/stylesheets/application.css +15 -0
  22. data/examples/basic_todo/app/controller_actions/base_action.rb +24 -0
  23. data/examples/basic_todo/app/controller_actions/base_precondition.rb +2 -0
  24. data/examples/basic_todo/app/controller_actions/home_controller/show.rb +8 -0
  25. data/examples/basic_todo/app/controller_actions/shared/ensure_user_not_disabled_precondition.rb +9 -0
  26. data/examples/basic_todo/app/controller_actions/sign_ins_controller/create.rb +24 -0
  27. data/examples/basic_todo/app/controller_actions/sign_ins_controller/destroy.rb +9 -0
  28. data/examples/basic_todo/app/controller_actions/sign_ins_controller/new.rb +7 -0
  29. data/examples/basic_todo/app/controller_actions/sign_ins_controller/user_params.rb +9 -0
  30. data/examples/basic_todo/app/controller_actions/sign_ups_controller/create.rb +23 -0
  31. data/examples/basic_todo/app/controller_actions/sign_ups_controller/new.rb +7 -0
  32. data/examples/basic_todo/app/controller_actions/sign_ups_controller/user_params.rb +9 -0
  33. data/examples/basic_todo/app/controller_actions/todos/all_completed_controller/destroy.rb +17 -0
  34. data/examples/basic_todo/app/controller_actions/todos/completed_controller/create.rb +29 -0
  35. data/examples/basic_todo/app/controller_actions/todos_controller/create.rb +26 -0
  36. data/examples/basic_todo/app/controller_actions/todos_controller/destroy.rb +21 -0
  37. data/examples/basic_todo/app/controller_actions/todos_controller/edit.rb +19 -0
  38. data/examples/basic_todo/app/controller_actions/todos_controller/index.rb +19 -0
  39. data/examples/basic_todo/app/controller_actions/todos_controller/new.rb +17 -0
  40. data/examples/basic_todo/app/controller_actions/todos_controller/todo_params.rb +9 -0
  41. data/examples/basic_todo/app/controller_actions/todos_controller/update.rb +28 -0
  42. data/examples/basic_todo/app/controller_actions/users_controller/index.rb +19 -0
  43. data/examples/basic_todo/app/controllers/application_controller.rb +9 -0
  44. data/examples/basic_todo/app/controllers/home_controller.rb +5 -0
  45. data/examples/basic_todo/app/controllers/sign_ins_controller.rb +5 -0
  46. data/examples/basic_todo/app/controllers/sign_ups_controller.rb +5 -0
  47. data/examples/basic_todo/app/controllers/todos/all_completed_controller.rb +5 -0
  48. data/examples/basic_todo/app/controllers/todos/completed_controller.rb +5 -0
  49. data/examples/basic_todo/app/controllers/todos_controller.rb +5 -0
  50. data/examples/basic_todo/app/controllers/users_controller.rb +5 -0
  51. data/examples/basic_todo/app/helpers/application_helper.rb +2 -0
  52. data/examples/basic_todo/app/mailers/.keep +0 -0
  53. data/examples/basic_todo/app/models/ability.rb +27 -0
  54. data/examples/basic_todo/app/models/role.rb +5 -0
  55. data/examples/basic_todo/app/models/todo.rb +5 -0
  56. data/examples/basic_todo/app/models/user.rb +12 -0
  57. data/examples/basic_todo/app/models/user_role.rb +5 -0
  58. data/examples/basic_todo/app/services/create_user_service.rb +26 -0
  59. data/examples/basic_todo/app/services/find_current_user_service.rb +29 -0
  60. data/examples/basic_todo/app/services/sign_in_service.rb +13 -0
  61. data/examples/basic_todo/app/services/sign_out_service.rb +12 -0
  62. data/examples/basic_todo/app/views/base_view.rb +18 -0
  63. data/examples/basic_todo/app/views/defaults/bad_request.html.slim +12 -0
  64. data/examples/basic_todo/app/views/defaults/bad_request_view.rb +15 -0
  65. data/examples/basic_todo/app/views/defaults/forbidden.html.slim +6 -0
  66. data/examples/basic_todo/app/views/defaults/forbidden_view.rb +14 -0
  67. data/examples/basic_todo/app/views/defaults/server_error.html.slim +12 -0
  68. data/examples/basic_todo/app/views/defaults/server_error_view.rb +14 -0
  69. data/examples/basic_todo/app/views/home/show.html.slim +5 -0
  70. data/examples/basic_todo/app/views/home/show_redirect.rb +5 -0
  71. data/examples/basic_todo/app/views/home/show_view.rb +7 -0
  72. data/examples/basic_todo/app/views/layouts/application.html.slim +18 -0
  73. data/examples/basic_todo/app/views/modules/_header.html.slim +13 -0
  74. data/examples/basic_todo/app/views/modules/header_view.rb +7 -0
  75. data/examples/basic_todo/app/views/sign_ins/new.html.slim +14 -0
  76. data/examples/basic_todo/app/views/sign_ins/new_view.rb +10 -0
  77. data/examples/basic_todo/app/views/sign_ups/new.html.slim +13 -0
  78. data/examples/basic_todo/app/views/sign_ups/new_view.rb +10 -0
  79. data/examples/basic_todo/app/views/todos/edit.html.slim +14 -0
  80. data/examples/basic_todo/app/views/todos/edit_view.rb +10 -0
  81. data/examples/basic_todo/app/views/todos/index.html.slim +12 -0
  82. data/examples/basic_todo/app/views/todos/index_redirect.rb +5 -0
  83. data/examples/basic_todo/app/views/todos/index_view/_todo.html.slim +8 -0
  84. data/examples/basic_todo/app/views/todos/index_view/todo_view.rb +28 -0
  85. data/examples/basic_todo/app/views/todos/index_view.rb +26 -0
  86. data/examples/basic_todo/app/views/todos/new.html.slim +14 -0
  87. data/examples/basic_todo/app/views/todos/new_view.rb +10 -0
  88. data/examples/basic_todo/app/views/todos/not_found.html.slim +6 -0
  89. data/examples/basic_todo/app/views/todos/not_found_view.rb +15 -0
  90. data/examples/basic_todo/app/views/users/index.html.slim +7 -0
  91. data/examples/basic_todo/app/views/users/index_redirect.rb +5 -0
  92. data/examples/basic_todo/app/views/users/index_view/_user.html.slim +2 -0
  93. data/examples/basic_todo/app/views/users/index_view/user_view.rb +22 -0
  94. data/examples/basic_todo/app/views/users/index_view.rb +26 -0
  95. data/examples/basic_todo/bin/bundle +3 -0
  96. data/examples/basic_todo/bin/rails +8 -0
  97. data/examples/basic_todo/bin/rake +8 -0
  98. data/examples/basic_todo/bin/rspec +7 -0
  99. data/examples/basic_todo/bin/spring +15 -0
  100. data/examples/basic_todo/config/application.rb +41 -0
  101. data/examples/basic_todo/config/boot.rb +4 -0
  102. data/examples/basic_todo/config/database.yml +25 -0
  103. data/examples/basic_todo/config/environment.rb +5 -0
  104. data/examples/basic_todo/config/environments/development.rb +37 -0
  105. data/examples/basic_todo/config/environments/production.rb +78 -0
  106. data/examples/basic_todo/config/environments/test.rb +39 -0
  107. data/examples/basic_todo/config/initializers/aldous.rb +3 -0
  108. data/examples/basic_todo/config/initializers/assets.rb +8 -0
  109. data/examples/basic_todo/config/initializers/backtrace_silencers.rb +7 -0
  110. data/examples/basic_todo/config/initializers/cookies_serializer.rb +3 -0
  111. data/examples/basic_todo/config/initializers/filter_parameter_logging.rb +4 -0
  112. data/examples/basic_todo/config/initializers/inflections.rb +16 -0
  113. data/examples/basic_todo/config/initializers/mime_types.rb +4 -0
  114. data/examples/basic_todo/config/initializers/session_store.rb +3 -0
  115. data/examples/basic_todo/config/initializers/wrap_parameters.rb +14 -0
  116. data/examples/basic_todo/config/locales/en.yml +23 -0
  117. data/examples/basic_todo/config/routes.rb +18 -0
  118. data/examples/basic_todo/config/secrets.yml +22 -0
  119. data/examples/basic_todo/config.ru +4 -0
  120. data/examples/basic_todo/db/migrate/20150226035524_create_user.rb +10 -0
  121. data/examples/basic_todo/db/migrate/20150227004411_create_todo.rb +11 -0
  122. data/examples/basic_todo/db/migrate/20150301110126_roles.rb +22 -0
  123. data/examples/basic_todo/db/migrate/20150301121923_add_user_disabled_column.rb +5 -0
  124. data/examples/basic_todo/db/schema.rb +45 -0
  125. data/examples/basic_todo/db/seeds.rb +7 -0
  126. data/examples/basic_todo/lib/assets/.keep +0 -0
  127. data/examples/basic_todo/lib/tasks/.keep +0 -0
  128. data/examples/basic_todo/log/.keep +0 -0
  129. data/examples/basic_todo/public/404.html +67 -0
  130. data/examples/basic_todo/public/422.html +67 -0
  131. data/examples/basic_todo/public/500.html +66 -0
  132. data/examples/basic_todo/public/favicon.ico +0 -0
  133. data/examples/basic_todo/public/robots.txt +5 -0
  134. data/examples/basic_todo/test/controllers/.keep +0 -0
  135. data/examples/basic_todo/test/fixtures/.keep +0 -0
  136. data/examples/basic_todo/test/helpers/.keep +0 -0
  137. data/examples/basic_todo/test/integration/.keep +0 -0
  138. data/examples/basic_todo/test/mailers/.keep +0 -0
  139. data/examples/basic_todo/test/models/.keep +0 -0
  140. data/examples/basic_todo/test/test_helper.rb +10 -0
  141. data/examples/basic_todo/vendor/assets/javascripts/.keep +0 -0
  142. data/examples/basic_todo/vendor/assets/stylesheets/.keep +0 -0
  143. data/lib/aldous/build_respondable_service.rb +23 -0
  144. data/lib/aldous/configuration.rb +18 -0
  145. data/lib/aldous/controller/action/precondition/wrapper.rb +32 -0
  146. data/lib/aldous/controller/action/precondition.rb +52 -0
  147. data/lib/aldous/controller/action/result_execution_service.rb +27 -0
  148. data/lib/aldous/controller/action/wrapper.rb +34 -0
  149. data/lib/aldous/controller/action_execution_service.rb +42 -0
  150. data/lib/aldous/controller/preconditions_execution_service.rb +32 -0
  151. data/lib/aldous/controller.rb +21 -0
  152. data/lib/aldous/controller_action.rb +63 -0
  153. data/lib/aldous/dummy_error_reporter.rb +9 -0
  154. data/lib/aldous/dummy_logger.rb +8 -0
  155. data/lib/aldous/errors/user_error.rb +6 -0
  156. data/lib/aldous/logging_wrapper.rb +16 -0
  157. data/lib/aldous/params.rb +34 -0
  158. data/lib/aldous/respondable/base.rb +32 -0
  159. data/lib/aldous/respondable/headable.rb +30 -0
  160. data/lib/aldous/respondable/redirectable.rb +38 -0
  161. data/lib/aldous/respondable/renderable.rb +50 -0
  162. data/lib/aldous/respondable/request_http_basic_authentication.rb +23 -0
  163. data/lib/aldous/respondable/send_data.rb +36 -0
  164. data/lib/aldous/respondable/shared/flash.rb +24 -0
  165. data/lib/aldous/service/result/base/predicate_methods_for_inheritance.rb +44 -0
  166. data/lib/aldous/service/result/base.rb +13 -0
  167. data/lib/aldous/service/result/failure.rb +11 -0
  168. data/lib/aldous/service/result/success.rb +11 -0
  169. data/lib/aldous/service/wrapper.rb +48 -0
  170. data/lib/aldous/service.rb +34 -0
  171. data/lib/aldous/simple_dto.rb +47 -0
  172. data/lib/aldous/stdout_logger.rb +9 -0
  173. data/lib/aldous/version.rb +3 -0
  174. data/lib/aldous/view/blank/atom_view.rb +12 -0
  175. data/lib/aldous/view/blank/html_view.rb +16 -0
  176. data/lib/aldous/view/blank/json_view.rb +16 -0
  177. data/lib/aldous.rb +40 -0
  178. data/spec/aldous/build_respondable_service_spec.rb +48 -0
  179. data/spec/aldous/configuration_spec.rb +15 -0
  180. data/spec/aldous/controller/action/precondition/wrapper_spec.rb +48 -0
  181. data/spec/aldous/controller/action/precondition_spec.rb +81 -0
  182. data/spec/aldous/controller/action/result_execution_service_spec.rb +43 -0
  183. data/spec/aldous/controller/action/wrapper_spec.rb +46 -0
  184. data/spec/aldous/controller/action_execution_service_spec.rb +79 -0
  185. data/spec/aldous/controller/preconditions_execution_service_spec.rb +45 -0
  186. data/spec/aldous/controller_action_spec.rb +97 -0
  187. data/spec/aldous/controller_spec.rb +25 -0
  188. data/spec/aldous/dummy_error_reporter_spec.rb +10 -0
  189. data/spec/aldous/dummy_logger_spec.rb +7 -0
  190. data/spec/aldous/logging_wrapper_spec.rb +55 -0
  191. data/spec/aldous/params_spec.rb +39 -0
  192. data/spec/aldous/respondable/base_spec.rb +11 -0
  193. data/spec/aldous/respondable/headable/head_action_spec.rb +17 -0
  194. data/spec/aldous/respondable/headable_spec.rb +20 -0
  195. data/spec/aldous/respondable/redirectable/redirect_action_spec.rb +34 -0
  196. data/spec/aldous/respondable/redirectable_spec.rb +26 -0
  197. data/spec/aldous/respondable/renderable/render_action_spec.rb +34 -0
  198. data/spec/aldous/respondable/renderable_spec.rb +46 -0
  199. data/spec/aldous/respondable/request_http_basic_authentication_spec.rb +0 -0
  200. data/spec/aldous/respondable/send_data/send_data_action_spec.rb +15 -0
  201. data/spec/aldous/respondable/send_data_spec.rb +30 -0
  202. data/spec/aldous/respondable/shared/flash_spec.rb +30 -0
  203. data/spec/aldous/service/result/failure_spec.rb +11 -0
  204. data/spec/aldous/service/result/success_spec.rb +11 -0
  205. data/spec/aldous/service/wrapper_spec.rb +110 -0
  206. data/spec/aldous/service_spec.rb +101 -0
  207. data/spec/aldous/simple_dto_spec.rb +40 -0
  208. data/spec/aldous/view/blank/atom_view_spec.rb +15 -0
  209. data/spec/aldous/view/blank/html_view_spec.rb +15 -0
  210. data/spec/aldous/view/blank/json_view_spec.rb +15 -0
  211. data/spec/spec_helper.rb +26 -0
  212. metadata +330 -0
@@ -0,0 +1,110 @@
1
+ RSpec.describe Aldous::Service::Wrapper do
2
+ let(:wrapper) { described_class.new service }
3
+
4
+ let(:service) { double 'service', perform: service_result, default_result_data: default_result_data, raisable_error: raisable_error }
5
+ let(:service_result) { Aldous::Service::Result::Success.new service_result_data }
6
+ let(:default_result_data) { { default_result_data: true } }
7
+ let(:service_result_data) { { service_result_data: true } }
8
+ let(:raisable_error) { Aldous::Errors::UserError }
9
+
10
+ before do
11
+ allow(Aldous.config.error_reporter).to receive(:report)
12
+ end
13
+
14
+ describe '#perform!' do
15
+ subject(:perform!) { wrapper.perform! }
16
+
17
+ it 'calls perform on the service' do
18
+ expect(service).to receive(:perform)
19
+ perform!
20
+ end
21
+
22
+ it 'returns a result of same type as result returned by service' do
23
+ expect(perform!.class).to be service_result.class
24
+ end
25
+
26
+ it 'includes default result data in result' do
27
+ expect(perform!.default_result_data).to eq true
28
+ end
29
+
30
+ it 'includes service result data in result' do
31
+ expect(perform!.service_result_data).to eq true
32
+ end
33
+
34
+ context 'when service returns a value that is not an Aldous result' do
35
+ let(:service_result) { 'uh oh' }
36
+
37
+ it 'raises raisable error' do
38
+ expect { perform! }.to raise_error(raisable_error, "Return value of #perform must be a type of #{::Aldous::Service::Result::Base}")
39
+ end
40
+ end
41
+
42
+ context 'when service raises an error' do
43
+ let(:e) { StandardError.new 'message' }
44
+
45
+ before do
46
+ allow(service).to receive(:perform).and_raise(e)
47
+ end
48
+
49
+ it 'raises raisable error with original error message' do
50
+ expect { perform! }.to raise_error(raisable_error, e.message)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '#perform' do
56
+ subject(:perform) { wrapper.perform }
57
+
58
+ before do
59
+ Aldous.configuration.logger = Aldous::DummyLogger
60
+ end
61
+
62
+ context 'when perform! does not raise an error' do
63
+ let(:result) { Aldous::Service::Result::Success.new }
64
+ before do
65
+ allow(wrapper).to receive(:perform!) { result }
66
+ end
67
+
68
+ it 'returns the result' do
69
+ expect(perform).to eq result
70
+ end
71
+ end
72
+
73
+ context 'when perform! raises an error' do
74
+ let(:e) { raisable_error.new }
75
+
76
+ before do
77
+ allow(wrapper).to receive(:perform!).and_raise(e)
78
+ end
79
+
80
+ it 'returns a failure result' do
81
+ expect(perform).to be_failure
82
+ end
83
+
84
+ it 'includes default result data in result' do
85
+ expect(perform.default_result_data).to eq true
86
+ end
87
+
88
+ it 'includes error in result' do
89
+ expect(perform.errors).to eq [e]
90
+ end
91
+
92
+ it 'reports the error' do
93
+ expect(Aldous::LoggingWrapper).to receive(:log).with(e)
94
+ perform
95
+ end
96
+
97
+ context 'when error cause is another error' do
98
+ let(:cause) { StandardError.new }
99
+ before do
100
+ allow(e).to receive(:cause) { cause }
101
+ end
102
+
103
+ it 'reports the error cause' do
104
+ expect(Aldous::LoggingWrapper).to receive(:log).with(cause)
105
+ perform
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,101 @@
1
+ describe Aldous::Service do
2
+ before do
3
+ class ExampleService < Aldous::Service
4
+ end
5
+ end
6
+
7
+ after do
8
+ Object.send :remove_const, 'ExampleService'
9
+ end
10
+
11
+ describe '.build' do
12
+ subject(:build) { ExampleService.build argument }
13
+
14
+ let(:argument) { 'argument' }
15
+ let(:service) { instance_double ExampleService }
16
+
17
+ before do
18
+ allow(ExampleService).to receive(:new) { service }
19
+ end
20
+
21
+ it 'instantiates a new service with arguments' do
22
+ expect(ExampleService).to receive(:new).with(argument)
23
+ build
24
+ end
25
+
26
+ it 'instantiates a service wrapper with service' do
27
+ expect(Aldous::Service::Wrapper).to receive(:new).with(service)
28
+ build
29
+ end
30
+ end
31
+
32
+ describe '.perform' do
33
+ subject(:perform) { ExampleService.perform argument }
34
+
35
+ let(:argument) { 'argument' }
36
+ let(:wrapper) { instance_double Aldous::Service::Wrapper, perform: nil }
37
+
38
+ before do
39
+ allow(ExampleService).to receive(:build) { wrapper }
40
+ end
41
+
42
+ it 'builds wrapper with arguments' do
43
+ expect(ExampleService).to receive(:build).with(argument)
44
+ perform
45
+ end
46
+
47
+ it 'calls perform on the wrapper' do
48
+ expect(wrapper).to receive(:perform)
49
+ perform
50
+ end
51
+ end
52
+
53
+ describe '.perform!' do
54
+ subject(:perform!) { ExampleService.perform! argument }
55
+
56
+ let(:argument) { 'argument' }
57
+ let(:wrapper) { instance_double Aldous::Service::Wrapper, perform!: nil }
58
+
59
+ before do
60
+ allow(ExampleService).to receive(:build) { wrapper }
61
+ end
62
+
63
+ it 'builds wrapper with arguments' do
64
+ expect(ExampleService).to receive(:build).with(argument)
65
+ perform!
66
+ end
67
+
68
+ it 'calls perform! on the wrapper' do
69
+ expect(wrapper).to receive(:perform!)
70
+ perform!
71
+ end
72
+ end
73
+
74
+ describe '#perform' do
75
+ let(:service) { ExampleService.new }
76
+ subject(:perform) { service.perform }
77
+
78
+ it 'raises a NotImplementedError' do
79
+ expect { perform }.to raise_error(NotImplementedError, "ExampleService must implement method #perform")
80
+ end
81
+ end
82
+
83
+ describe '#raisable_error' do
84
+ let(:service) { ExampleService.new }
85
+ subject(:raisable_error) { service.raisable_error }
86
+
87
+ it 'defaults to Aldous::Errors::UserError' do
88
+ expect(raisable_error).to eq Aldous::Errors::UserError
89
+ end
90
+ end
91
+
92
+ describe '#default_result_data' do
93
+ let(:service) { ExampleService.new }
94
+
95
+ subject(:default_result_data) { service.default_result_data }
96
+
97
+ it 'defaults to {}' do
98
+ expect(default_result_data).to eq({})
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,40 @@
1
+ RSpec.describe Aldous::SimpleDto do
2
+ let(:dto) {described_class.new(data)}
3
+ let(:data) {Hash.new}
4
+
5
+ context "errors passed in are available as errors list" do
6
+ let(:data) { {errors: 'hello'} }
7
+
8
+ it "can get the right error" do
9
+ expect(dto.errors.first).to eq 'hello'
10
+ end
11
+ end
12
+
13
+ context "messages passed in are available as messages list" do
14
+ let(:data) { {messages: 'hello'} }
15
+
16
+ it "can get the right message" do
17
+ expect(dto.messages.first).to eq 'hello'
18
+ end
19
+ end
20
+
21
+ context "all data passed in is available to get it out again" do
22
+ let(:data) { {hello: 1} }
23
+
24
+ it "can get access to the original data" do
25
+ expect(dto._data).to eq data
26
+ end
27
+ end
28
+
29
+ context "all keys passed in are available via accessors" do
30
+ let(:data) { {foo: 1, bar: 2} }
31
+
32
+ it "can get :foo via method" do
33
+ expect(dto.foo).to eq 1
34
+ end
35
+
36
+ it "can get :bar via method" do
37
+ expect(dto.bar).to eq 2
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ RSpec.describe Aldous::View::Blank::AtomView do
2
+ subject(:view) {described_class.new(status, view_data, view_context)}
3
+
4
+ let(:status) {nil}
5
+ let(:view_data) {double("result")}
6
+ let(:view_context) {double("view context")}
7
+
8
+ it "inherits from Renderable" do
9
+ expect(described_class.ancestors.include?(Aldous::Respondable::Renderable)).to be_truthy
10
+ end
11
+
12
+ it "implements the 'template' method" do
13
+ expect{ view.template }.to_not raise_error
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ RSpec.describe Aldous::View::Blank::HtmlView do
2
+ subject(:view) {described_class.new(status, view_data, view_context)}
3
+
4
+ let(:status) {nil}
5
+ let(:view_data) {double("result")}
6
+ let(:view_context) {double("view context")}
7
+
8
+ it "inherits from Renderable" do
9
+ expect(described_class.ancestors.include?(Aldous::Respondable::Renderable)).to be_truthy
10
+ end
11
+
12
+ it "implements the 'template' method" do
13
+ expect{ view.template }.to_not raise_error
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ RSpec.describe Aldous::View::Blank::JsonView do
2
+ subject(:view) {described_class.new(status, view_data, view_context)}
3
+
4
+ let(:status) {nil}
5
+ let(:view_data) {double("result")}
6
+ let(:view_context) {double("view context")}
7
+
8
+ it "inherits from Renderable" do
9
+ expect(described_class.ancestors.include?(Aldous::Respondable::Renderable)).to be_truthy
10
+ end
11
+
12
+ it "implements the 'template' method" do
13
+ expect{ view.template }.to_not raise_error
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ require 'aldous'
2
+
3
+ Dir[File.join(File.dirname(__FILE__), 'support', '**', "*.rb").to_s].each {|file| require file }
4
+
5
+ RSpec.configure do |config|
6
+ config.filter_run :focus
7
+ config.run_all_when_everything_filtered = true
8
+
9
+ if config.files_to_run.one?
10
+ config.default_formatter = 'doc'
11
+ end
12
+
13
+ config.profile_examples = 2
14
+ config.order = :random
15
+
16
+ Kernel.srand config.seed
17
+
18
+ config.expect_with :rspec do |expectations|
19
+ expectations.syntax = :expect
20
+ end
21
+
22
+ config.mock_with :rspec do |mocks|
23
+ mocks.syntax = :expect
24
+ mocks.verify_partial_doubles = true
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,330 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aldous
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alan Skorkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Rails brave new world
56
+ email:
57
+ - alan@skorks.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".irbrc"
64
+ - ".rspec"
65
+ - ".ruby-version"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - aldous.gemspec
71
+ - examples/basic_todo/.foreman
72
+ - examples/basic_todo/.gitignore
73
+ - examples/basic_todo/.rspec
74
+ - examples/basic_todo/.ruby-version
75
+ - examples/basic_todo/Gemfile
76
+ - examples/basic_todo/Procfile
77
+ - examples/basic_todo/README.rdoc
78
+ - examples/basic_todo/Rakefile
79
+ - examples/basic_todo/app/assets/images/.keep
80
+ - examples/basic_todo/app/assets/javascripts/application.js
81
+ - examples/basic_todo/app/assets/stylesheets/application.css
82
+ - examples/basic_todo/app/controller_actions/base_action.rb
83
+ - examples/basic_todo/app/controller_actions/base_precondition.rb
84
+ - examples/basic_todo/app/controller_actions/home_controller/show.rb
85
+ - examples/basic_todo/app/controller_actions/shared/ensure_user_not_disabled_precondition.rb
86
+ - examples/basic_todo/app/controller_actions/sign_ins_controller/create.rb
87
+ - examples/basic_todo/app/controller_actions/sign_ins_controller/destroy.rb
88
+ - examples/basic_todo/app/controller_actions/sign_ins_controller/new.rb
89
+ - examples/basic_todo/app/controller_actions/sign_ins_controller/user_params.rb
90
+ - examples/basic_todo/app/controller_actions/sign_ups_controller/create.rb
91
+ - examples/basic_todo/app/controller_actions/sign_ups_controller/new.rb
92
+ - examples/basic_todo/app/controller_actions/sign_ups_controller/user_params.rb
93
+ - examples/basic_todo/app/controller_actions/todos/all_completed_controller/destroy.rb
94
+ - examples/basic_todo/app/controller_actions/todos/completed_controller/create.rb
95
+ - examples/basic_todo/app/controller_actions/todos_controller/create.rb
96
+ - examples/basic_todo/app/controller_actions/todos_controller/destroy.rb
97
+ - examples/basic_todo/app/controller_actions/todos_controller/edit.rb
98
+ - examples/basic_todo/app/controller_actions/todos_controller/index.rb
99
+ - examples/basic_todo/app/controller_actions/todos_controller/new.rb
100
+ - examples/basic_todo/app/controller_actions/todos_controller/todo_params.rb
101
+ - examples/basic_todo/app/controller_actions/todos_controller/update.rb
102
+ - examples/basic_todo/app/controller_actions/users_controller/index.rb
103
+ - examples/basic_todo/app/controllers/application_controller.rb
104
+ - examples/basic_todo/app/controllers/home_controller.rb
105
+ - examples/basic_todo/app/controllers/sign_ins_controller.rb
106
+ - examples/basic_todo/app/controllers/sign_ups_controller.rb
107
+ - examples/basic_todo/app/controllers/todos/all_completed_controller.rb
108
+ - examples/basic_todo/app/controllers/todos/completed_controller.rb
109
+ - examples/basic_todo/app/controllers/todos_controller.rb
110
+ - examples/basic_todo/app/controllers/users_controller.rb
111
+ - examples/basic_todo/app/helpers/application_helper.rb
112
+ - examples/basic_todo/app/mailers/.keep
113
+ - examples/basic_todo/app/models/ability.rb
114
+ - examples/basic_todo/app/models/role.rb
115
+ - examples/basic_todo/app/models/todo.rb
116
+ - examples/basic_todo/app/models/user.rb
117
+ - examples/basic_todo/app/models/user_role.rb
118
+ - examples/basic_todo/app/services/create_user_service.rb
119
+ - examples/basic_todo/app/services/find_current_user_service.rb
120
+ - examples/basic_todo/app/services/sign_in_service.rb
121
+ - examples/basic_todo/app/services/sign_out_service.rb
122
+ - examples/basic_todo/app/views/base_view.rb
123
+ - examples/basic_todo/app/views/defaults/bad_request.html.slim
124
+ - examples/basic_todo/app/views/defaults/bad_request_view.rb
125
+ - examples/basic_todo/app/views/defaults/forbidden.html.slim
126
+ - examples/basic_todo/app/views/defaults/forbidden_view.rb
127
+ - examples/basic_todo/app/views/defaults/server_error.html.slim
128
+ - examples/basic_todo/app/views/defaults/server_error_view.rb
129
+ - examples/basic_todo/app/views/home/show.html.slim
130
+ - examples/basic_todo/app/views/home/show_redirect.rb
131
+ - examples/basic_todo/app/views/home/show_view.rb
132
+ - examples/basic_todo/app/views/layouts/application.html.slim
133
+ - examples/basic_todo/app/views/modules/_header.html.slim
134
+ - examples/basic_todo/app/views/modules/header_view.rb
135
+ - examples/basic_todo/app/views/sign_ins/new.html.slim
136
+ - examples/basic_todo/app/views/sign_ins/new_view.rb
137
+ - examples/basic_todo/app/views/sign_ups/new.html.slim
138
+ - examples/basic_todo/app/views/sign_ups/new_view.rb
139
+ - examples/basic_todo/app/views/todos/edit.html.slim
140
+ - examples/basic_todo/app/views/todos/edit_view.rb
141
+ - examples/basic_todo/app/views/todos/index.html.slim
142
+ - examples/basic_todo/app/views/todos/index_redirect.rb
143
+ - examples/basic_todo/app/views/todos/index_view.rb
144
+ - examples/basic_todo/app/views/todos/index_view/_todo.html.slim
145
+ - examples/basic_todo/app/views/todos/index_view/todo_view.rb
146
+ - examples/basic_todo/app/views/todos/new.html.slim
147
+ - examples/basic_todo/app/views/todos/new_view.rb
148
+ - examples/basic_todo/app/views/todos/not_found.html.slim
149
+ - examples/basic_todo/app/views/todos/not_found_view.rb
150
+ - examples/basic_todo/app/views/users/index.html.slim
151
+ - examples/basic_todo/app/views/users/index_redirect.rb
152
+ - examples/basic_todo/app/views/users/index_view.rb
153
+ - examples/basic_todo/app/views/users/index_view/_user.html.slim
154
+ - examples/basic_todo/app/views/users/index_view/user_view.rb
155
+ - examples/basic_todo/bin/bundle
156
+ - examples/basic_todo/bin/rails
157
+ - examples/basic_todo/bin/rake
158
+ - examples/basic_todo/bin/rspec
159
+ - examples/basic_todo/bin/spring
160
+ - examples/basic_todo/config.ru
161
+ - examples/basic_todo/config/application.rb
162
+ - examples/basic_todo/config/boot.rb
163
+ - examples/basic_todo/config/database.yml
164
+ - examples/basic_todo/config/environment.rb
165
+ - examples/basic_todo/config/environments/development.rb
166
+ - examples/basic_todo/config/environments/production.rb
167
+ - examples/basic_todo/config/environments/test.rb
168
+ - examples/basic_todo/config/initializers/aldous.rb
169
+ - examples/basic_todo/config/initializers/assets.rb
170
+ - examples/basic_todo/config/initializers/backtrace_silencers.rb
171
+ - examples/basic_todo/config/initializers/cookies_serializer.rb
172
+ - examples/basic_todo/config/initializers/filter_parameter_logging.rb
173
+ - examples/basic_todo/config/initializers/inflections.rb
174
+ - examples/basic_todo/config/initializers/mime_types.rb
175
+ - examples/basic_todo/config/initializers/session_store.rb
176
+ - examples/basic_todo/config/initializers/wrap_parameters.rb
177
+ - examples/basic_todo/config/locales/en.yml
178
+ - examples/basic_todo/config/routes.rb
179
+ - examples/basic_todo/config/secrets.yml
180
+ - examples/basic_todo/db/migrate/20150226035524_create_user.rb
181
+ - examples/basic_todo/db/migrate/20150227004411_create_todo.rb
182
+ - examples/basic_todo/db/migrate/20150301110126_roles.rb
183
+ - examples/basic_todo/db/migrate/20150301121923_add_user_disabled_column.rb
184
+ - examples/basic_todo/db/schema.rb
185
+ - examples/basic_todo/db/seeds.rb
186
+ - examples/basic_todo/lib/assets/.keep
187
+ - examples/basic_todo/lib/tasks/.keep
188
+ - examples/basic_todo/log/.keep
189
+ - examples/basic_todo/public/404.html
190
+ - examples/basic_todo/public/422.html
191
+ - examples/basic_todo/public/500.html
192
+ - examples/basic_todo/public/favicon.ico
193
+ - examples/basic_todo/public/robots.txt
194
+ - examples/basic_todo/test/controllers/.keep
195
+ - examples/basic_todo/test/fixtures/.keep
196
+ - examples/basic_todo/test/helpers/.keep
197
+ - examples/basic_todo/test/integration/.keep
198
+ - examples/basic_todo/test/mailers/.keep
199
+ - examples/basic_todo/test/models/.keep
200
+ - examples/basic_todo/test/test_helper.rb
201
+ - examples/basic_todo/vendor/assets/javascripts/.keep
202
+ - examples/basic_todo/vendor/assets/stylesheets/.keep
203
+ - lib/aldous.rb
204
+ - lib/aldous/build_respondable_service.rb
205
+ - lib/aldous/configuration.rb
206
+ - lib/aldous/controller.rb
207
+ - lib/aldous/controller/action/precondition.rb
208
+ - lib/aldous/controller/action/precondition/wrapper.rb
209
+ - lib/aldous/controller/action/result_execution_service.rb
210
+ - lib/aldous/controller/action/wrapper.rb
211
+ - lib/aldous/controller/action_execution_service.rb
212
+ - lib/aldous/controller/preconditions_execution_service.rb
213
+ - lib/aldous/controller_action.rb
214
+ - lib/aldous/dummy_error_reporter.rb
215
+ - lib/aldous/dummy_logger.rb
216
+ - lib/aldous/errors/user_error.rb
217
+ - lib/aldous/logging_wrapper.rb
218
+ - lib/aldous/params.rb
219
+ - lib/aldous/respondable/base.rb
220
+ - lib/aldous/respondable/headable.rb
221
+ - lib/aldous/respondable/redirectable.rb
222
+ - lib/aldous/respondable/renderable.rb
223
+ - lib/aldous/respondable/request_http_basic_authentication.rb
224
+ - lib/aldous/respondable/send_data.rb
225
+ - lib/aldous/respondable/shared/flash.rb
226
+ - lib/aldous/service.rb
227
+ - lib/aldous/service/result/base.rb
228
+ - lib/aldous/service/result/base/predicate_methods_for_inheritance.rb
229
+ - lib/aldous/service/result/failure.rb
230
+ - lib/aldous/service/result/success.rb
231
+ - lib/aldous/service/wrapper.rb
232
+ - lib/aldous/simple_dto.rb
233
+ - lib/aldous/stdout_logger.rb
234
+ - lib/aldous/version.rb
235
+ - lib/aldous/view/blank/atom_view.rb
236
+ - lib/aldous/view/blank/html_view.rb
237
+ - lib/aldous/view/blank/json_view.rb
238
+ - spec/aldous/build_respondable_service_spec.rb
239
+ - spec/aldous/configuration_spec.rb
240
+ - spec/aldous/controller/action/precondition/wrapper_spec.rb
241
+ - spec/aldous/controller/action/precondition_spec.rb
242
+ - spec/aldous/controller/action/result_execution_service_spec.rb
243
+ - spec/aldous/controller/action/wrapper_spec.rb
244
+ - spec/aldous/controller/action_execution_service_spec.rb
245
+ - spec/aldous/controller/preconditions_execution_service_spec.rb
246
+ - spec/aldous/controller_action_spec.rb
247
+ - spec/aldous/controller_spec.rb
248
+ - spec/aldous/dummy_error_reporter_spec.rb
249
+ - spec/aldous/dummy_logger_spec.rb
250
+ - spec/aldous/logging_wrapper_spec.rb
251
+ - spec/aldous/params_spec.rb
252
+ - spec/aldous/respondable/base_spec.rb
253
+ - spec/aldous/respondable/headable/head_action_spec.rb
254
+ - spec/aldous/respondable/headable_spec.rb
255
+ - spec/aldous/respondable/redirectable/redirect_action_spec.rb
256
+ - spec/aldous/respondable/redirectable_spec.rb
257
+ - spec/aldous/respondable/renderable/render_action_spec.rb
258
+ - spec/aldous/respondable/renderable_spec.rb
259
+ - spec/aldous/respondable/request_http_basic_authentication_spec.rb
260
+ - spec/aldous/respondable/send_data/send_data_action_spec.rb
261
+ - spec/aldous/respondable/send_data_spec.rb
262
+ - spec/aldous/respondable/shared/flash_spec.rb
263
+ - spec/aldous/service/result/failure_spec.rb
264
+ - spec/aldous/service/result/success_spec.rb
265
+ - spec/aldous/service/wrapper_spec.rb
266
+ - spec/aldous/service_spec.rb
267
+ - spec/aldous/simple_dto_spec.rb
268
+ - spec/aldous/view/blank/atom_view_spec.rb
269
+ - spec/aldous/view/blank/html_view_spec.rb
270
+ - spec/aldous/view/blank/json_view_spec.rb
271
+ - spec/spec_helper.rb
272
+ homepage: ''
273
+ licenses:
274
+ - MIT
275
+ metadata: {}
276
+ post_install_message:
277
+ rdoc_options: []
278
+ require_paths:
279
+ - lib
280
+ required_ruby_version: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - ">="
283
+ - !ruby/object:Gem::Version
284
+ version: '0'
285
+ required_rubygems_version: !ruby/object:Gem::Requirement
286
+ requirements:
287
+ - - ">="
288
+ - !ruby/object:Gem::Version
289
+ version: '0'
290
+ requirements: []
291
+ rubyforge_project:
292
+ rubygems_version: 2.2.2
293
+ signing_key:
294
+ specification_version: 4
295
+ summary: Rails brave new world
296
+ test_files:
297
+ - spec/aldous/build_respondable_service_spec.rb
298
+ - spec/aldous/configuration_spec.rb
299
+ - spec/aldous/controller/action/precondition/wrapper_spec.rb
300
+ - spec/aldous/controller/action/precondition_spec.rb
301
+ - spec/aldous/controller/action/result_execution_service_spec.rb
302
+ - spec/aldous/controller/action/wrapper_spec.rb
303
+ - spec/aldous/controller/action_execution_service_spec.rb
304
+ - spec/aldous/controller/preconditions_execution_service_spec.rb
305
+ - spec/aldous/controller_action_spec.rb
306
+ - spec/aldous/controller_spec.rb
307
+ - spec/aldous/dummy_error_reporter_spec.rb
308
+ - spec/aldous/dummy_logger_spec.rb
309
+ - spec/aldous/logging_wrapper_spec.rb
310
+ - spec/aldous/params_spec.rb
311
+ - spec/aldous/respondable/base_spec.rb
312
+ - spec/aldous/respondable/headable/head_action_spec.rb
313
+ - spec/aldous/respondable/headable_spec.rb
314
+ - spec/aldous/respondable/redirectable/redirect_action_spec.rb
315
+ - spec/aldous/respondable/redirectable_spec.rb
316
+ - spec/aldous/respondable/renderable/render_action_spec.rb
317
+ - spec/aldous/respondable/renderable_spec.rb
318
+ - spec/aldous/respondable/request_http_basic_authentication_spec.rb
319
+ - spec/aldous/respondable/send_data/send_data_action_spec.rb
320
+ - spec/aldous/respondable/send_data_spec.rb
321
+ - spec/aldous/respondable/shared/flash_spec.rb
322
+ - spec/aldous/service/result/failure_spec.rb
323
+ - spec/aldous/service/result/success_spec.rb
324
+ - spec/aldous/service/wrapper_spec.rb
325
+ - spec/aldous/service_spec.rb
326
+ - spec/aldous/simple_dto_spec.rb
327
+ - spec/aldous/view/blank/atom_view_spec.rb
328
+ - spec/aldous/view/blank/html_view_spec.rb
329
+ - spec/aldous/view/blank/json_view_spec.rb
330
+ - spec/spec_helper.rb