journea 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +8 -0
  3. data/README.md +131 -0
  4. data/Rakefile +26 -0
  5. data/app/controllers/journea/engine_controller.rb +19 -0
  6. data/app/controllers/journea/journeys_controller.rb +10 -0
  7. data/app/controllers/journea/steps_controller.rb +52 -0
  8. data/app/helpers/journea/form_helper.rb +25 -0
  9. data/app/models/journea/journey.rb +54 -0
  10. data/app/models/journea/journey_transition.rb +17 -0
  11. data/app/models/journea/keyvalue.rb +5 -0
  12. data/app/views/application/_back_link.html.haml +5 -0
  13. data/config/initializers/simple_form.rb +179 -0
  14. data/config/locales/simple_form.en.yml +31 -0
  15. data/config/routes.rb +5 -0
  16. data/db/migrate/20161201153630_create_journey_transitions.rb +22 -0
  17. data/db/migrate/20161201162349_create_journeys_table.rb +10 -0
  18. data/db/migrate/20161202162350_create_keyvalues_table.rb +11 -0
  19. data/lib/generators/journea/install_generator.rb +76 -0
  20. data/lib/generators/journea/templates/assets/application.js +23 -0
  21. data/lib/generators/journea/templates/assets/application.scss +49 -0
  22. data/lib/generators/journea/templates/config/initializers/journea.rb +23 -0
  23. data/lib/generators/journea/templates/config/initializers/journea2.rb +24 -0
  24. data/lib/generators/journea/templates/controllers/pages_controller.rb.example +2 -0
  25. data/lib/generators/journea/templates/views/application.html.haml +20 -0
  26. data/lib/generators/journea/templates/views/pages/start.html.haml.example +12 -0
  27. data/lib/generators/journea/templates/views/shared/error_messages.html.haml.example +7 -0
  28. data/lib/generators/journea/templates/views/steps/step.html.haml.example +8 -0
  29. data/lib/journea.rb +25 -0
  30. data/lib/journea/data.rb +20 -0
  31. data/lib/journea/engine.rb +27 -0
  32. data/lib/journea/state_machine.rb +40 -0
  33. data/lib/journea/step.rb +32 -0
  34. data/lib/journea/version.rb +3 -0
  35. data/lib/simple_form_object.rb +146 -0
  36. data/lib/tasks/journea_tasks.rake +4 -0
  37. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  38. data/spec/dummy/Rakefile +6 -0
  39. data/spec/dummy/app/assets/config/manifest.js +5 -0
  40. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  41. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  42. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  43. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  44. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  45. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  46. data/spec/dummy/app/controllers/pages_controller.rb +4 -0
  47. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  48. data/spec/dummy/app/jobs/application_job.rb +2 -0
  49. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  50. data/spec/dummy/app/models/application_record.rb +3 -0
  51. data/spec/dummy/app/steps/address_step.rb +4 -0
  52. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  53. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  54. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  55. data/spec/dummy/app/views/pages/start.html.erb +1 -0
  56. data/spec/dummy/app/views/steps/address.html.erb +5 -0
  57. data/spec/dummy/app/views/steps/name.html.erb +5 -0
  58. data/spec/dummy/app/views/steps/phone_number.html.erb +0 -0
  59. data/spec/dummy/bin/bundle +3 -0
  60. data/spec/dummy/bin/rails +4 -0
  61. data/spec/dummy/bin/rake +4 -0
  62. data/spec/dummy/bin/setup +34 -0
  63. data/spec/dummy/bin/update +29 -0
  64. data/spec/dummy/config.ru +5 -0
  65. data/spec/dummy/config/application.rb +14 -0
  66. data/spec/dummy/config/boot.rb +5 -0
  67. data/spec/dummy/config/cable.yml +9 -0
  68. data/spec/dummy/config/database.yml +25 -0
  69. data/spec/dummy/config/environment.rb +5 -0
  70. data/spec/dummy/config/environments/development.rb +54 -0
  71. data/spec/dummy/config/environments/production.rb +86 -0
  72. data/spec/dummy/config/environments/test.rb +42 -0
  73. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  74. data/spec/dummy/config/initializers/assets.rb +11 -0
  75. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  77. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  78. data/spec/dummy/config/initializers/inflections.rb +16 -0
  79. data/spec/dummy/config/initializers/journea.rb +8 -0
  80. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  81. data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
  82. data/spec/dummy/config/initializers/session_store.rb +3 -0
  83. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  84. data/spec/dummy/config/locales/en.yml +23 -0
  85. data/spec/dummy/config/puma.rb +47 -0
  86. data/spec/dummy/config/routes.rb +4 -0
  87. data/spec/dummy/config/secrets.yml +22 -0
  88. data/spec/dummy/config/spring.rb +6 -0
  89. data/spec/dummy/db/development.sqlite3 +0 -0
  90. data/spec/dummy/db/schema.rb +42 -0
  91. data/spec/dummy/db/test.sqlite3 +0 -0
  92. data/spec/dummy/log/development.log +57 -0
  93. data/spec/dummy/log/test.log +448 -0
  94. data/spec/dummy/public/404.html +67 -0
  95. data/spec/dummy/public/422.html +67 -0
  96. data/spec/dummy/public/500.html +66 -0
  97. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  98. data/spec/dummy/public/apple-touch-icon.png +0 -0
  99. data/spec/dummy/public/favicon.ico +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/EA/EAR2KaBsPQau6HwaTGrxV7EGMwAWyS-4C8pGVDU1Z-Q.cache +1 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/JZ/JZuPFgM2mLQgAHB-r7Pt_TdGW3DRWPrplT7xPjnCJSE.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LT/LTt1oE1gi9m65YRwUp78DuufkCOfi3sa3Qa05_ykADk.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lj/LjRKOqtrClPtb97phuIWI7HHA8-p5J5nKHVE_zEycxo.cache +1 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QM/QMxUWUtpFaqwG3RI9t3m38QtFAOvHpiY3LphKJiVRTc.cache +1 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/St/StFuOi5bd69ceiqz2D6EOCmRzHgwY0IxERsMfiCneGM.cache +1 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vj/VjCUmI9pp5eD8BlYATbwJ4ZOk0438rwvtDrsttyWbfQ.cache +0 -0
  107. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wl/WlLcUIADXcUxaOt8Gq59uQbO0mquikyz7jxiJjXjhaI.cache +1 -0
  108. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YH/YHo__TrFq5y8rpx49T8d8ecyvMLbHFbnhz7IBV7pM98.cache +1 -0
  109. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Zu/ZuLXgeX6x_Dx8sCUbzuTtWu42HzQXWe7eooTgsonTnc.cache +0 -0
  110. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aG/aG1tp1pv4kBiSKx9ixZH5xiRXH-rGa0Hi6sdl4SHw6g.cache +3 -0
  111. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aw/awTDtuorxLsRLIGEYCefR-PTN7yptoaGRLEk13vHVLA.cache +1 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/b_/b_Itlk9QZZd7Rvf8kcA4yLP1R5Acu7jB-m1xQiSU0qE.cache +2 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cW/cWHxYOqms7abJ-dzXyrn2G7nadJicU5kkC8SduS06yc.cache +0 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cb/cbX7RFavWZoWojlrsXhsy4FN46UOfMwZYStkLHT5HJw.cache +1 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/eY/eYTHvo0Wl2TD2vipDcJ966HHXGrA4ZlJaiA2DnftKhM.cache +1 -0
  116. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/f4/f4CpFuYmsdh1EvlFVjsl1WmM2QA9_z9AuOebEOw4mts.cache +0 -0
  117. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gH/gHSjqTBRSW22rP9mSj8XW6huEXKpcIOehvF-2fvuShQ.cache +1 -0
  118. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m0/m0smDeM83DcmOVpX9zos6AIX40E9Tf2j26tyvKFgMwc.cache +1 -0
  119. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mW/mWrwQwWUQpAlMCLQ8dGv5VkAXd-TxvAtB5WPg9l09-A.cache +1 -0
  120. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mX/mX1nlsL_SWOB4y22W5FheRX0YEONKyOY7xUeIvRiHco.cache +2 -0
  121. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  122. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  123. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oA/oAtzk5ZeF7lWCwNufspgWqtv_dQN_n5GumFNB4ScfBE.cache +2 -0
  124. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/rA/rACdJeX3jZNkhx4awGhdZeMdOfmARubkoVKVAZdwYog.cache +0 -0
  125. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sC/sCEBZXwTjRpEzThf7YHzHNfkAupMVOx_Ko7WNMAFHS0.cache +0 -0
  126. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7PYh8DJvPykcEqpVab2vcY9-GFz-3cqtoMlRAu94Uc.cache +2 -0
  127. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yT/yTOf3QInGfDlRZlwZNDBLlbma19FQRHM035AKRxcRyw.cache +0 -0
  128. data/spec/features/journey_spec.rb +9 -0
  129. data/spec/lib/simple_form_object/attribute_spec.rb +74 -0
  130. data/spec/lib/simple_form_object/delegation_spec.rb +50 -0
  131. data/spec/lib/simple_form_object/model_spec.rb +90 -0
  132. data/spec/lib/steps_spec.rb +0 -0
  133. data/spec/requests/journeys_spec.rb +6 -0
  134. data/spec/spec_helper.rb +44 -0
  135. metadata +449 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
@@ -0,0 +1 @@
1
+ "%A��G �{h t�l�m�V���NE���f���
@@ -0,0 +1 @@
1
+ "%�aY}�)�vH`�=�T��y��-��0�@��g~�
@@ -0,0 +1 @@
1
+ "%��B�����șo�$'�A�d��L���xR�U
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=b834ff0e585e80ee8f46f65a673aa5fd45563d423752a9c2a77e7fcf3000bb9c:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=56e431bebebede6e565206c634d992c604345d76c88f718aff63510f5cf67e18:ET
@@ -0,0 +1 @@
1
+ "%A�>��N�6�n���f��9��V�~K��
@@ -0,0 +1 @@
1
+ "%��B�����șo�$'�A�d��L���xR�U
@@ -0,0 +1 @@
1
+ "%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash}
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"�file-digest:///Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled/action_cable.js;TTF
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/cable.js?type=application/javascript&pipeline=self&id=9d7c3e35998c510d0e5ece798486ed681ab007a7e088ff998fb36f5faa89a21c:ET
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"�file-digest:///Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled/action_cable.js;TTI"2file-digest://app/assets/javascripts/cable.js;TTI"$file-digest://app/assets/config;TTI"1file-digest://app/assets/config/action_cable;TTI"$file-digest://app/assets/images;TTI"1file-digest://app/assets/images/action_cable;TTI")file-digest://app/assets/javascripts;TTI"6file-digest://app/assets/javascripts/action_cable;TTI")file-digest://app/assets/stylesheets;TTI"6file-digest://app/assets/stylesheets/action_cable;TTI"}file-digest:///Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled;TTI"�file-digest:///Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled/action_cable;TTI"2file-digest://app/assets/javascripts/channels;TTF
@@ -0,0 +1 @@
1
+ "%�<������X���̀#+�����,�(o���
@@ -0,0 +1 @@
1
+ "%�d�-�K���`���8Y��3�͹/Y����a~K
@@ -0,0 +1 @@
1
+ I"�/Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled/action_cable.js?type=application/javascript&pipeline=self&id=80904d458a279200a78b24ba028a84335737ccfa48e21c65c4593ffb40220a1f:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=86081eab4c19fb2f90c687bd1b46160ed80198bfa6bd72e9c10105545005f0b4:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=89fdd3bd8cc5ee441e6c111a7ac329278828845b36c55277a5f96dc780490a1b:ET
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"9file-digest://app/assets/stylesheets/application.css;TTI")file-digest://app/assets/stylesheets;TTF
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"0processors:type=text/css&file_type=text/css;TTI"9file-digest://app/assets/stylesheets/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI")file-digest://app/assets/stylesheets;TTF
@@ -0,0 +1,2 @@
1
+ "%��T���l�
2
+ %�`H�!o��"��}�M�g�
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"2file-digest://app/assets/javascripts/cable.js;TTI"$file-digest://app/assets/config;TTI"1file-digest://app/assets/config/action_cable;TTI"$file-digest://app/assets/images;TTI"1file-digest://app/assets/images/action_cable;TTI")file-digest://app/assets/javascripts;TTI"6file-digest://app/assets/javascripts/action_cable;TTI")file-digest://app/assets/stylesheets;TTI"6file-digest://app/assets/stylesheets/action_cable;TTI"}file-digest:///Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled;TTI"�file-digest:///Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled/action_cable;TTI"�file-digest:///Users/acruikshanks/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled/action_cable.js;TTI"2file-digest://app/assets/javascripts/channels;TTF
@@ -0,0 +1,9 @@
1
+ RSpec.feature "User journeys through steps" do
2
+ scenario "starts with the first step" do
3
+ visit root_path
4
+ click_link "Start now"
5
+ expect(page).to have_content "enter your name"
6
+ click_button "Continue"
7
+ expect(page).to have_content "enter your address"
8
+ end
9
+ end
@@ -0,0 +1,74 @@
1
+ describe SimpleFormObject::Attribute do
2
+ describe "initialization" do
3
+ subject(:attribute) { SimpleFormObject::Attribute.new(name, options, type) }
4
+
5
+ let(:name) { :foo }
6
+ let(:type) { :boolean }
7
+ let(:options) { { default: "hello" } }
8
+
9
+ it "should be initialized with a name, type and options hash" do
10
+ expect(attribute.name).to eq name
11
+ expect(attribute.type).to eq type
12
+ expect(attribute.options).to eq options
13
+ end
14
+
15
+ describe "type" do
16
+ let(:type) { nil }
17
+
18
+ it "is :string when nil or not provided" do
19
+ expect(attribute.type).to eq :string
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "#apply_default_to" do
25
+ let(:name) { :foo }
26
+ let(:type) { :boolean }
27
+ let(:options) { { default: default } }
28
+ let(:default) { true }
29
+ let(:attribute) { SimpleFormObject::Attribute.new(name, options, type) }
30
+ let(:form) { double(foo: nil) }
31
+
32
+ it "should apply the default value to the attribute on the object" do
33
+ expect(form).to receive("#{name}=").with(default)
34
+ attribute.apply_default_to(form)
35
+ end
36
+
37
+ context "with a falsey default" do
38
+ let(:default) { false }
39
+ it "should apply the default value to the attribute on the object" do
40
+ expect(form).to receive("#{name}=").with(default)
41
+ attribute.apply_default_to(form)
42
+ end
43
+ end
44
+
45
+ context "when the form object attribute has a value" do
46
+ let(:form) { double(foo: false) }
47
+
48
+ it "should not apply the default" do
49
+ expect(form).to_not receive("#{name}=").with(default)
50
+ attribute.apply_default_to(form)
51
+ expect(form.foo).to eq false
52
+ end
53
+ end
54
+
55
+ context "with a lambda/proc default" do
56
+ let(:default) { proc { :bar } }
57
+
58
+ it "calls the lambda" do
59
+ expect(form).to receive("#{name}=").with(:bar)
60
+ attribute.apply_default_to(form)
61
+ end
62
+
63
+ context "when the proc references the form" do
64
+ let(:default) { proc { current_foo } }
65
+ let(:form) { double("Form", foo: nil, current_foo: :bar) }
66
+
67
+ it "calls the lambda" do
68
+ expect(form).to receive("#{name}=").with(:bar)
69
+ attribute.apply_default_to(form)
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,50 @@
1
+ describe "SimpleFormObject delegation" do
2
+ let(:base_klass) { Class.new.tap { |k| k.include SimpleFormObject } }
3
+ let(:klass) { base_klass }
4
+ let(:instance) { klass.new }
5
+
6
+ describe ".delegate_all" do
7
+ let(:target) { double }
8
+
9
+ before do
10
+ klass.delegate_all to: target
11
+ end
12
+
13
+ it "should delegate foo to the target" do
14
+ expect(target).to receive(:foo)
15
+ instance.foo
16
+
17
+ expect(target).to receive(:foo).with([1, 2, 3, 4])
18
+ instance.foo([1, 2, 3, 4])
19
+ end
20
+ end
21
+
22
+ describe "a more complex delegation" do
23
+ let(:base_klass) do
24
+ Class.new do
25
+ include SimpleFormObject
26
+
27
+ def initialize(target_object, attributes = {})
28
+ @target_object = target_object
29
+ super(attributes)
30
+ end
31
+
32
+ attr_reader :target_object
33
+
34
+ delegate_all to: :target_object
35
+ end
36
+ end
37
+
38
+ let(:target) { double }
39
+ let(:instance) { klass.new(target) }
40
+
41
+ it "should delegate foo to the target" do
42
+ expect(target).to receive(:foo)
43
+ instance.foo
44
+
45
+ expect(target).to receive(:foo).with([1, 2, 3, 4])
46
+ instance.foo([1, 2, 3, 4])
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,90 @@
1
+ describe "SimpleFormObject" do
2
+ let(:base_klass) { Class.new.tap { |k| k.include SimpleFormObject } }
3
+ let(:klass) { base_klass }
4
+ let(:instance) { klass.new }
5
+
6
+ context "when included" do
7
+ it "should have ActiveModel::Model" do
8
+ expect(instance).to respond_to :valid?
9
+ end
10
+ end
11
+
12
+ describe ".attribute" do
13
+ let(:attribute) { :foo }
14
+
15
+ before do
16
+ klass.attribute :foo
17
+ end
18
+
19
+ it 'should respond to "attribute"' do
20
+ expect(instance).to respond_to(attribute)
21
+ end
22
+
23
+ it 'should respond to "attribute="' do
24
+ expect(instance).to respond_to("#{attribute}=")
25
+ end
26
+
27
+ describe "type" do
28
+ # rubocop:disable Metrics/LineLength
29
+ let(:types) { %i(boolean string email url tel password search text file hidden integer float decimal range datetime date time select radio_buttons check_boxes country time_zone) }
30
+ # rubocop:enable Metrics/LineLength
31
+
32
+ let(:type) { :boolean }
33
+ let(:attr) { :la }
34
+
35
+ before do
36
+ klass.attribute attr, type
37
+ end
38
+
39
+ it "should return a fake column with the correct type" do
40
+ expect(instance.column_for_attribute(attr).type).to eq type
41
+ end
42
+
43
+ it "should say that the attribute exists" do
44
+ expect(instance.attribute?(attr)).to eq true
45
+ end
46
+ end
47
+
48
+ describe "options" do
49
+ let(:type) { :boolean }
50
+ let(:attr) { :doh }
51
+
52
+ before do
53
+ klass.attribute attr, type, default: true
54
+ end
55
+
56
+ describe "default" do
57
+ it "should set the attribute to the default" do
58
+ expect(instance.doh).to eq true
59
+ end
60
+
61
+ context "when a value is supplied in the initialization hash" do
62
+ let(:instance) { klass.new(doh: false) }
63
+
64
+ it "should use the value in the hash" do
65
+ expect(instance.doh).to eq false
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+
73
+ describe ".model_name" do
74
+ let(:klass) do
75
+ class KlassStep
76
+ include SimpleFormObject
77
+ end
78
+
79
+ KlassStep
80
+ end
81
+
82
+ it "should return an ActiveModel::Name" do
83
+ expect(klass.model_name).to be_a_kind_of ActiveModel::Name
84
+ end
85
+
86
+ it "should remove Form from the name of the class" do
87
+ expect(klass.model_name.name).to eq "Klass"
88
+ end
89
+ end
90
+ end