validation_sync 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +29 -0
  4. data/app/assets/javascripts/validation_sync.js +14 -0
  5. data/app/assets/javascripts/validations.js.coffee.erb +51 -0
  6. data/app/assets/stylesheets/validation_sync/application.css +13 -0
  7. data/app/helpers/validation_sync_form_helper.rb +87 -0
  8. data/config/routes.rb +0 -0
  9. data/lib/tasks/validation_sync_tasks.rake +4 -0
  10. data/lib/validation_sync.rb +4 -0
  11. data/lib/validation_sync/engine.rb +16 -0
  12. data/lib/validation_sync/version.rb +3 -0
  13. data/spec/dummy/README.rdoc +28 -0
  14. data/spec/dummy/Rakefile +6 -0
  15. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  16. data/spec/dummy/app/assets/javascripts/posts.js +2 -0
  17. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  18. data/spec/dummy/app/assets/stylesheets/posts.css +4 -0
  19. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  21. data/spec/dummy/app/controllers/posts_controller.rb +58 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/helpers/posts_helper.rb +2 -0
  24. data/spec/dummy/app/models/post.rb +10 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/spec/dummy/app/views/posts/_form.html.erb +33 -0
  27. data/spec/dummy/app/views/posts/edit.html.erb +6 -0
  28. data/spec/dummy/app/views/posts/index.html.erb +33 -0
  29. data/spec/dummy/app/views/posts/new.html.erb +5 -0
  30. data/spec/dummy/app/views/posts/show.html.erb +24 -0
  31. data/spec/dummy/bin/bundle +3 -0
  32. data/spec/dummy/bin/rails +4 -0
  33. data/spec/dummy/bin/rake +4 -0
  34. data/spec/dummy/config.ru +4 -0
  35. data/spec/dummy/config/application.rb +30 -0
  36. data/spec/dummy/config/boot.rb +5 -0
  37. data/spec/dummy/config/database.yml +25 -0
  38. data/spec/dummy/config/environment.rb +5 -0
  39. data/spec/dummy/config/environments/development.rb +29 -0
  40. data/spec/dummy/config/environments/production.rb +80 -0
  41. data/spec/dummy/config/environments/test.rb +36 -0
  42. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  43. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  44. data/spec/dummy/config/initializers/inflections.rb +16 -0
  45. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  46. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  47. data/spec/dummy/config/initializers/session_store.rb +3 -0
  48. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  49. data/spec/dummy/config/locales/en.yml +23 -0
  50. data/spec/dummy/config/routes.rb +3 -0
  51. data/spec/dummy/db/development.sqlite3 +0 -0
  52. data/spec/dummy/db/migrate/20140210065920_create_posts.rb +12 -0
  53. data/spec/dummy/db/schema.rb +25 -0
  54. data/spec/dummy/db/test.sqlite3 +0 -0
  55. data/spec/dummy/log/development.log +6345 -0
  56. data/spec/dummy/log/test.log +89 -0
  57. data/spec/dummy/public/404.html +58 -0
  58. data/spec/dummy/public/422.html +58 -0
  59. data/spec/dummy/public/500.html +57 -0
  60. data/spec/dummy/public/favicon.ico +0 -0
  61. data/spec/dummy/tmp/cache/assets/development/sprockets/04f730b2979d2f24cffafefd80e430f0 +0 -0
  62. data/spec/dummy/tmp/cache/assets/development/sprockets/0f11e0b3e0ece93d6c047318f2e5497d +0 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/0f53e3491015320ad54b7352dd6e9245 +0 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/10c6f05e183df4466be1e0171868fbd3 +0 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/122e92d06837af295d6c941999a8d48f +0 -0
  66. data/spec/dummy/tmp/cache/assets/development/sprockets/134039afc96b5a8d33c96d5da3816c1a +0 -0
  67. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  68. data/spec/dummy/tmp/cache/assets/development/sprockets/1e8f75a6b5b33970fb8e397347caa0a1 +0 -0
  69. data/spec/dummy/tmp/cache/assets/development/sprockets/24204f742af588c8166d3160b500d20f +0 -0
  70. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  71. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  72. data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  73. data/spec/dummy/tmp/cache/assets/development/sprockets/416150dc3ac35079c94273cc46e90aa6 +0 -0
  74. data/spec/dummy/tmp/cache/assets/development/sprockets/43b02dba04222f7470018fdda830925e +0 -0
  75. data/spec/dummy/tmp/cache/assets/development/sprockets/467cb2a85cb807b3c28bacd8f6147dfc +0 -0
  76. data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  77. data/spec/dummy/tmp/cache/assets/development/sprockets/5384ad85f52d3272dbc64d46ef3876a4 +0 -0
  78. data/spec/dummy/tmp/cache/assets/development/sprockets/56146675dbad13c72d3eb9ebd823dc11 +0 -0
  79. data/spec/dummy/tmp/cache/assets/development/sprockets/5957a00e12da95bda275e8c3565a0316 +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/62d3fdf824fa141115db660a17ab94bc +0 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/76cec3171960b0a527249d215835fade +0 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/87283d82c809770d9da81fe4e72a2abe +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/97892dcc76bfd97e09ab26d3f7a6d522 +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sprockets/c71eea08c37d8da406449ab45486b070 +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/c85016e7bbd4f3adbb7635d01f85d39b +0 -0
  87. data/spec/dummy/tmp/cache/assets/development/sprockets/cbc66bd36b3aa4411f9ce20da0fd37a0 +0 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/cc1ff523f6e3d417ee0a9bbbfe23a69b +0 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/d066c004d1fd26ae76a61303a7a18145 +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/d5a2d5bfe451248efe5aa31d1c94575c +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  94. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  95. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  96. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  97. data/spec/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  98. data/spec/dummy/tmp/cache/assets/test/sprockets/416150dc3ac35079c94273cc46e90aa6 +0 -0
  99. data/spec/dummy/tmp/cache/assets/test/sprockets/5384ad85f52d3272dbc64d46ef3876a4 +0 -0
  100. data/spec/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  101. data/spec/dummy/tmp/cache/assets/test/sprockets/c85016e7bbd4f3adbb7635d01f85d39b +0 -0
  102. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  103. data/spec/dummy/tmp/cache/assets/test/sprockets/d066c004d1fd26ae76a61303a7a18145 +0 -0
  104. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  105. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  106. data/spec/dummy/tmp/pids/server.pid +1 -0
  107. data/spec/features/form_validation_spec.rb +53 -0
  108. data/spec/helpers/form_helper_spec.rb +4 -0
  109. data/spec/spec_helper.rb +26 -0
  110. metadata +388 -0
@@ -0,0 +1,89 @@
1
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
+  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
+ Migrating to CreatePosts (20140210065920)
5
+  (0.0ms) begin transaction
6
+  (0.2ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "content" text, "view_count" integer, "author_email" varchar(255), "created_at" datetime, "updated_at" datetime) 
7
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140210065920"]]
8
+  (2.5ms) commit transaction
9
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
10
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:44:14 -0500
11
+ Processing by PostsController#new as HTML
12
+ Rendered posts/_form.html.erb (68.3ms)
13
+ Rendered posts/new.html.erb within layouts/application (73.6ms)
14
+ Completed 200 OK in 141ms (Views: 139.0ms | ActiveRecord: 0.9ms)
15
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:44:15 -0500
16
+ Processing by PostsController#new as HTML
17
+ Rendered posts/_form.html.erb (2.0ms)
18
+ Rendered posts/new.html.erb within layouts/application (2.2ms)
19
+ Completed 200 OK in 3ms (Views: 2.8ms | ActiveRecord: 0.0ms)
20
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:44:15 -0500
21
+ Processing by PostsController#new as HTML
22
+ Rendered posts/_form.html.erb (2.1ms)
23
+ Rendered posts/new.html.erb within layouts/application (2.4ms)
24
+ Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms)
25
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:44:15 -0500
26
+ Processing by PostsController#new as HTML
27
+ Rendered posts/_form.html.erb (1.9ms)
28
+ Rendered posts/new.html.erb within layouts/application (2.1ms)
29
+ Completed 200 OK in 3ms (Views: 2.7ms | ActiveRecord: 0.0ms)
30
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:45:03 -0500
31
+ Processing by PostsController#new as HTML
32
+ Rendered posts/_form.html.erb (13.3ms)
33
+ Rendered posts/new.html.erb within layouts/application (15.9ms)
34
+ Completed 200 OK in 51ms (Views: 48.6ms | ActiveRecord: 0.8ms)
35
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:45:03 -0500
36
+ Processing by PostsController#new as HTML
37
+ Rendered posts/_form.html.erb (2.0ms)
38
+ Rendered posts/new.html.erb within layouts/application (2.2ms)
39
+ Completed 200 OK in 3ms (Views: 2.9ms | ActiveRecord: 0.0ms)
40
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:45:03 -0500
41
+ Processing by PostsController#new as HTML
42
+ Rendered posts/_form.html.erb (1.9ms)
43
+ Rendered posts/new.html.erb within layouts/application (2.2ms)
44
+ Completed 200 OK in 3ms (Views: 2.8ms | ActiveRecord: 0.0ms)
45
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:45:03 -0500
46
+ Processing by PostsController#new as HTML
47
+ Rendered posts/_form.html.erb (2.2ms)
48
+ Rendered posts/new.html.erb within layouts/application (2.5ms)
49
+ Completed 200 OK in 3ms (Views: 3.2ms | ActiveRecord: 0.0ms)
50
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:46:50 -0500
51
+ Processing by PostsController#new as HTML
52
+ Rendered posts/_form.html.erb (13.7ms)
53
+ Rendered posts/new.html.erb within layouts/application (16.2ms)
54
+ Completed 200 OK in 51ms (Views: 48.8ms | ActiveRecord: 0.9ms)
55
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:46:50 -0500
56
+ Processing by PostsController#new as HTML
57
+ Rendered posts/_form.html.erb (2.1ms)
58
+ Rendered posts/new.html.erb within layouts/application (2.3ms)
59
+ Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms)
60
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:46:50 -0500
61
+ Processing by PostsController#new as HTML
62
+ Rendered posts/_form.html.erb (1.9ms)
63
+ Rendered posts/new.html.erb within layouts/application (2.1ms)
64
+ Completed 200 OK in 3ms (Views: 2.8ms | ActiveRecord: 0.0ms)
65
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:46:50 -0500
66
+ Processing by PostsController#new as HTML
67
+ Rendered posts/_form.html.erb (2.1ms)
68
+ Rendered posts/new.html.erb within layouts/application (2.4ms)
69
+ Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms)
70
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:54:35 -0500
71
+ Processing by PostsController#new as HTML
72
+ Rendered posts/_form.html.erb (14.1ms)
73
+ Rendered posts/new.html.erb within layouts/application (16.7ms)
74
+ Completed 200 OK in 53ms (Views: 50.9ms | ActiveRecord: 1.0ms)
75
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:54:35 -0500
76
+ Processing by PostsController#new as HTML
77
+ Rendered posts/_form.html.erb (2.0ms)
78
+ Rendered posts/new.html.erb within layouts/application (2.2ms)
79
+ Completed 200 OK in 3ms (Views: 2.9ms | ActiveRecord: 0.0ms)
80
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:54:35 -0500
81
+ Processing by PostsController#new as HTML
82
+ Rendered posts/_form.html.erb (1.9ms)
83
+ Rendered posts/new.html.erb within layouts/application (2.1ms)
84
+ Completed 200 OK in 3ms (Views: 2.7ms | ActiveRecord: 0.0ms)
85
+ Started GET "/posts/new" for 127.0.0.1 at 2014-02-10 10:54:35 -0500
86
+ Processing by PostsController#new as HTML
87
+ Rendered posts/_form.html.erb (1.9ms)
88
+ Rendered posts/new.html.erb within layouts/application (2.2ms)
89
+ Completed 200 OK in 3ms (Views: 2.8ms | ActiveRecord: 0.0ms)
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ 58956
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Adding validation classes to form inputs" do
4
+
5
+ # Required
6
+
7
+ it "adds the 'required' class when an attribute is required" do
8
+ # are we validating the model correctly?
9
+ expect(Post.validators_on(:title).map(&:class)).to include ActiveRecord::Validations::PresenceValidator
10
+
11
+ # are we adding the 'required' class?
12
+ visit new_post_path
13
+ within("#new_post") do
14
+ expect(page).to have_css('input#post_title.required')
15
+ end
16
+ end
17
+
18
+ it "doesn't add the 'required' class when an attribute is not required" do
19
+ expect(Post.validators_on(:author_email).map(&:class)).not_to include ActiveRecord::Validations::PresenceValidator
20
+
21
+ # are we adding the 'required' class?
22
+ visit new_post_path
23
+ within("#new_post") do
24
+ expect(page).not_to have_css('input#post_author_email.required')
25
+ end
26
+ end
27
+
28
+
29
+ # Numericality
30
+
31
+ it "adds the 'number' class when a number is required" do
32
+ # are we validating the model correctly?
33
+ expect(Post.validators_on(:view_count).map(&:class)).to include ActiveModel::Validations::NumericalityValidator
34
+
35
+ # are we adding the 'number' class?
36
+ visit new_post_path
37
+ within("#new_post") do
38
+ expect(page).to have_css('input#post_view_count.number')
39
+ end
40
+ end
41
+
42
+ it "doesn't add the 'number' class when a number is not required" do
43
+ # are we validating the model correctly?
44
+ expect(Post.validators_on(:author_email).map(&:class)).not_to include ActiveModel::Validations::NumericalityValidator
45
+
46
+ # are we adding the 'number' class?
47
+ visit new_post_path
48
+ within("#new_post") do
49
+ expect(page).not_to have_css('input#post_author_email.number')
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe FormHelper do
4
+ end
@@ -0,0 +1,26 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'factory_girl_rails'
7
+
8
+ Rails.backtrace_cleaner.remove_silencers!
9
+
10
+ # Load support files
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
+
13
+ # Use webkit as the Capybara JS driver
14
+ Capybara.javascript_driver = :webkit
15
+
16
+ RSpec.configure do |config|
17
+ config.mock_with :rspec
18
+ config.infer_base_class_for_anonymous_controllers = false
19
+ config.order = "random"
20
+
21
+ # Make the standard Capybara driver play nice with the Webkit (JS) driver
22
+ config.use_transactional_fixtures = false
23
+
24
+ # Allow for short-hand Factory Girl syntax
25
+ config.include FactoryGirl::Syntax::Methods
26
+ end