yorisoi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +8 -0
  4. data/.travis.yml +22 -0
  5. data/Gemfile +15 -0
  6. data/Gemfile.lock +173 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +5 -0
  9. data/Rakefile +4 -0
  10. data/lib/tasks/yorisoi_tasks.rake +4 -0
  11. data/lib/yorisoi/version.rb +3 -0
  12. data/lib/yorisoi.rb +221 -0
  13. data/spec/controllers/samples_controller_spec.rb +52 -0
  14. data/spec/dummy/README.rdoc +28 -0
  15. data/spec/dummy/Rakefile +6 -0
  16. data/spec/dummy/app/assets/images/.keep +0 -0
  17. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  18. data/spec/dummy/app/assets/javascripts/samples.js +2 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  20. data/spec/dummy/app/assets/stylesheets/samples.css +4 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  22. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  23. data/spec/dummy/app/controllers/samples_controller.rb +21 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/helpers/samples_helper.rb +2 -0
  26. data/spec/dummy/app/mailers/.keep +0 -0
  27. data/spec/dummy/app/models/.keep +0 -0
  28. data/spec/dummy/app/models/concerns/.keep +0 -0
  29. data/spec/dummy/app/models/sample.rb +12 -0
  30. data/spec/dummy/app/views/layouts/application.html.erb +13 -0
  31. data/spec/dummy/app/views/samples/new.html.erb +155 -0
  32. data/spec/dummy/bin/bundle +3 -0
  33. data/spec/dummy/bin/rails +4 -0
  34. data/spec/dummy/bin/rake +4 -0
  35. data/spec/dummy/bin/setup +29 -0
  36. data/spec/dummy/config/application.rb +32 -0
  37. data/spec/dummy/config/boot.rb +5 -0
  38. data/spec/dummy/config/database.def.yml +25 -0
  39. data/spec/dummy/config/database.travis.yml +3 -0
  40. data/spec/dummy/config/environment.rb +5 -0
  41. data/spec/dummy/config/environments/development.rb +41 -0
  42. data/spec/dummy/config/environments/production.rb +79 -0
  43. data/spec/dummy/config/environments/test.rb +42 -0
  44. data/spec/dummy/config/initializers/assets.rb +11 -0
  45. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  46. data/spec/dummy/config/initializers/constants.rb +5 -0
  47. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  48. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/spec/dummy/config/initializers/inflections.rb +16 -0
  50. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  51. data/spec/dummy/config/initializers/session_store.rb +3 -0
  52. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  53. data/spec/dummy/config/locales/en.yml +23 -0
  54. data/spec/dummy/config/routes.rb +6 -0
  55. data/spec/dummy/config/secrets.yml +22 -0
  56. data/spec/dummy/config.ru +4 -0
  57. data/spec/dummy/coverage/.last_run.json +5 -0
  58. data/spec/dummy/coverage/.resultset.json +1215 -0
  59. data/spec/dummy/coverage/.resultset.json.lock +0 -0
  60. data/spec/dummy/db/migrate/20150622110108_create_samples.rb +14 -0
  61. data/spec/dummy/db/schema.rb +27 -0
  62. data/spec/dummy/lib/assets/.keep +0 -0
  63. data/spec/dummy/log/.keep +0 -0
  64. data/spec/dummy/public/404.html +67 -0
  65. data/spec/dummy/public/422.html +67 -0
  66. data/spec/dummy/public/500.html +66 -0
  67. data/spec/dummy/public/css/def.css +1 -0
  68. data/spec/dummy/public/favicon.ico +0 -0
  69. data/spec/factories/sample.rb +14 -0
  70. data/spec/libs/conmare_with_normail_builder_spec.rb +244 -0
  71. data/spec/libs/yorisoi_spec.rb +237 -0
  72. data/spec/models/samples_spec.rb +38 -0
  73. data/spec/rails_helper.rb +64 -0
  74. data/spec/spec_helper.rb +95 -0
  75. data/spec/supports/active_model.rb +30 -0
  76. data/yorisoi.gemspec +32 -0
  77. metadata +245 -0
File without changes
@@ -0,0 +1,14 @@
1
+ class CreateSamples < ActiveRecord::Migration
2
+ def change
3
+ create_table :samples do |t|
4
+ t.string :text
5
+ t.string :password
6
+ t.string :textarea
7
+ t.string :select
8
+ t.string :radio
9
+ t.string :checkbox
10
+
11
+ t.timestamps null: false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20150622110108) do
15
+
16
+ create_table "samples", force: :cascade do |t|
17
+ t.string "text"
18
+ t.string "password"
19
+ t.string "textarea"
20
+ t.string "select"
21
+ t.string "radio"
22
+ t.string "checkbox"
23
+ t.datetime "created_at", null: false
24
+ t.datetime "updated_at", null: false
25
+ end
26
+
27
+ end
File without changes
File without changes
@@ -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>
@@ -0,0 +1 @@
1
+ a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}html{line-height:1}ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0}caption,td,th{text-align:left;font-weight:400;vertical-align:middle}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}a img{border:none}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}.biggest{font-size:42px;line-height:50.4px}input[type=checkbox].biggest,input[type=radio].biggest{width:42px;height:42px}.bigger{font-size:26px;line-height:31.2px}input[type=checkbox].bigger,input[type=radio].bigger{width:26px;height:26px}.big{font-size:18px;line-height:21.6px}input[type=checkbox].big,input[type=radio].big{width:18px;height:18px}.button,.normal,body,input,select,textarea{font-size:14px;line-height:16.8px}input[type=checkbox],input[type=checkbox].normal,input[type=radio],input[type=radio].normal{width:14px;height:14px}.small{font-size:12px;line-height:14.4px}input[type=checkbox].small,input[type=radio].small{width:12px;height:12px}.smaller{font-size:10px;line-height:12px}input[type=checkbox].smaller,input[type=radio].smaller{width:10px;height:10px}.smallest{font-size:8px;line-height:9.6px}input[type=checkbox].smallest,input[type=radio].smallest{width:8px;height:8px}.read{line-height:170%}.text-black{color:#000}.bg-black{color:#fff;background-color:#000}.label-black{background-color:#000;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.text-silver{color:#bdc3c7}.bg-silver{color:#fff;background-color:#bdc3c7}.label-silver{background-color:#bdc3c7;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.information-text,.text-gray{color:#7f8c8d}.bg-gray,.information-message{color:#fff;background-color:#7f8c8d}.label-gray{background-color:#7f8c8d;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.text-turquoise{color:#16a085}.bg-turquoise{color:#fff;background-color:#16a085}.label-turquoise{background-color:#16a085;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.text-green{color:#27ae60}.bg-green{color:#fff;background-color:#27ae60}.label-green{background-color:#27ae60;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.success-text,.text-blue{color:#2980b9}.bg-blue,.success-message{color:#fff;background-color:#2980b9}.label-blue{background-color:#2980b9;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.text-purple{color:#8e44ad}.bg-purple{color:#fff;background-color:#8e44ad}.label-purple{background-color:#8e44ad;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.text-navy{color:#2c3e50}.bg-navy{color:#fff;background-color:#2c3e50}.label-navy{background-color:#2c3e50;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.alert-text,.text-yellow{color:#f39c12}.alert-message,.bg-yellow{color:#fff;background-color:#f39c12}.label-yellow{background-color:#f39c12;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.text-orange{color:#d35400}.bg-orange{color:#fff;background-color:#d35400}.label-orange{background-color:#d35400;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.error-text,.text-red{color:#c0392b}.bg-red,.error-message{color:#fff;background-color:#c0392b}.label-red{background-color:#c0392b;border-radius:3px;color:#fff;display:inline-block;padding:3px 6px;vertical-align:middle}.button{border:1px solid transparent;border-radius:3px;box-sizing:border-box;color:#fff;display:inline-block;font-family:"Helvetica Neue",Helvetica,Arial,"Hiragino Kaku Gothic Pro",Meiryo,"MS PGothic",sans-serif;font-weight:400;margin:0;outline:0;padding:7px 15px 6px;position:relative;text-align:center;text-decoration:none;top:-2px}.button.thin{padding:2px 15px 1px}.button:focus,.button:hover{top:-6px}.button.black{text-shadow:0 -1px #000;background-color:#333;box-shadow:0 4px #000}.button.black:focus,.button.black:hover{box-shadow:0 8px #000}.button.black .active,.button.black:active{top:-2px;box-shadow:0 4px #000}.button.silver{text-shadow:0 -1px #bdc3c7;background-color:#ecf0f1;box-shadow:0 4px #bdc3c7}.button.silver:focus,.button.silver:hover{box-shadow:0 8px #bdc3c7}.button.silver .active,.button.silver:active{top:-2px;box-shadow:0 4px #bdc3c7}.button.gray{text-shadow:0 -1px #7f8c8d;background-color:#95a5a6;box-shadow:0 4px #7f8c8d}.button.gray:focus,.button.gray:hover{box-shadow:0 8px #7f8c8d}.button.gray .active,.button.gray:active{top:-2px;box-shadow:0 4px #7f8c8d}.button.turquoise{text-shadow:0 -1px #16a085;background-color:#1abc9c;box-shadow:0 4px #16a085}.button.turquoise:focus,.button.turquoise:hover{box-shadow:0 8px #16a085}.button.turquoise .active,.button.turquoise:active{top:-2px;box-shadow:0 4px #16a085}.button.green{text-shadow:0 -1px #27ae60;background-color:#2ecc71;box-shadow:0 4px #27ae60}.button.green:focus,.button.green:hover{box-shadow:0 8px #27ae60}.button.green .active,.button.green:active{top:-2px;box-shadow:0 4px #27ae60}.button.blue{text-shadow:0 -1px #2980b9;background-color:#3498db;box-shadow:0 4px #2980b9}.button.blue:focus,.button.blue:hover{box-shadow:0 8px #2980b9}.button.blue .active,.button.blue:active{top:-2px;box-shadow:0 4px #2980b9}.button.purple{text-shadow:0 -1px #8e44ad;background-color:#9b59b6;box-shadow:0 4px #8e44ad}.button.purple:focus,.button.purple:hover{box-shadow:0 8px #8e44ad}.button.purple .active,.button.purple:active{top:-2px;box-shadow:0 4px #8e44ad}.button.navy{text-shadow:0 -1px #2c3e50;background-color:#34495e;box-shadow:0 4px #2c3e50}.button.navy:focus,.button.navy:hover{box-shadow:0 8px #2c3e50}.button.navy .active,.button.navy:active{top:-2px;box-shadow:0 4px #2c3e50}.button.yellow{text-shadow:0 -1px #f39c12;background-color:#f1c40f;box-shadow:0 4px #f39c12}.button.yellow:focus,.button.yellow:hover{box-shadow:0 8px #f39c12}.button.yellow .active,.button.yellow:active{top:-2px;box-shadow:0 4px #f39c12}.button.orange{text-shadow:0 -1px #d35400;background-color:#e67e22;box-shadow:0 4px #d35400}.button.orange:focus,.button.orange:hover{box-shadow:0 8px #d35400}.button.orange .active,.button.orange:active{top:-2px;box-shadow:0 4px #d35400}.button.red{text-shadow:0 -1px #c0392b;background-color:#e74c3c;box-shadow:0 4px #c0392b}.button.red:focus,.button.red:hover{box-shadow:0 8px #c0392b}.button.red .active,.button.red:active{top:-2px;box-shadow:0 4px #c0392b}.line-layout>*{display:inline-block}.w300{width:300px}.w400{width:400px}.w500{width:500px}.w600{width:600px}.w700{width:700px}.w800{width:800px}.w900{width:900px}.p5{width:5%}.p10{width:10%}.p15{width:15%}.p20{width:20%}.p25{width:25%}.p30{width:30%}.p35{width:35%}.p40{width:40%}.p45{width:45%}.p50{width:50%}.p55{width:55%}.p60{width:60%}.p65{width:65%}.p70{width:70%}.p75{width:75%}.p80{width:80%}.p85{width:85%}.p90{width:90%}.p95{width:95%}.p100{width:100%}.block-centering{margin-left:auto;margin-right:auto}.block-lefting{margin-left:0;margin-right:auto}.block-righting{margin-left:auto;margin-right:0}.input-box{display:table}.input-set{display:table-row-group}.input-body,.input-head{box-sizing:border-box;vertical-align:middle;display:table-cell;padding-top:5px;padding-bottom:5px}.input-head{white-space:nowrap;font-weight:700;padding-right:10px}.form-button-area{width:100%;text-align:center;margin-top:5px;margin-bottom:5px}.form-button-area>*{display:inline-block;vertical-align:middle;margin:5px}.checkbox-label,.radio-label{display:inline-block;white-space:nowrap;vertical-align:middle;padding-right:5px}.checkbox-input,.checkbox-text,.radio-input,.radio-text{display:inline-block;white-space:nowrap}input[type=password],input[type=text],select,textarea{border-radius:3px;border:1px solid #95a5a6;outline:0;padding:5px 10px;position:relative}input[type=password]:focus,input[type=text]:focus,select:focus,textarea:focus{border-color:#2ecc71;box-shadow:0 0 4px #2ecc71}input[type=password].input-error,input[type=text].input-error,select.input-error,textarea.input-error{border-color:#c0392b}input[type=password].input-error:focus,input[type=text].input-error:focus,select.input-error:focus,textarea.input-error:focus{box-shadow:0 0 4px #c0392b}input[type=password].input-valid,input[type=text].input-valid,select.input-valid,textarea.input-valid{border-color:#2980b9}input[type=password].input-valid:focus,input[type=text].input-valid:focus,select.input-valid:focus,textarea.input-valid:focus{box-shadow:0 0 4px #2980b9}input[type=checkbox],input[type=radio]{width:16px;height:16px;vertical-align:middle}.alert-message,.error-message,.information-message,.success-message{padding:5px 10px}.alert-text,.error-text,.information-text,.success-text{margin:5px 0}.message-list{padding-left:25px}.message-list>li{list-style:square}body,input,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,"Hiragino Kaku Gothic Pro",Meiryo,"MS PGothic",sans-serif;color:#333;vertical-align:top}body{overflow-y:scroll}a{text-decoration:none;color:#3498db}*{box-sizing:border-box}section{margin:10px}
File without changes
@@ -0,0 +1,14 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :sample do
5
+ factory :valid_sample do
6
+ sequence(:text) { |n| "text#{n}" }
7
+ sequence(:password) { |n| "password#{n}" }
8
+ sequence(:textarea) { |n| "textarea#{n}" }
9
+ select {Const::SELECT.sample}
10
+ radio {Const::RADIO.sample}
11
+ checkbox {[Const::CHECKBOX.sample]}
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,244 @@
1
+ require 'rails_helper'
2
+
3
+ class TestHelper < ActionView::Base;
4
+ end
5
+
6
+ RSpec.describe Yorisoi::Builder do
7
+ before :each do
8
+ @sample = build(:sample)
9
+ @df = ActionView::Helpers::FormBuilder.new(:sample, @sample, TestHelper.new, {})
10
+ @f = Yorisoi::Builder.new(:sample, @sample, TestHelper.new, {})
11
+ end
12
+
13
+ let(:for_select) do
14
+ (1..4).to_a.zip(('a'..'d').to_a)
15
+ end
16
+
17
+ context 'wrapping' do
18
+ context 'wrapped' do
19
+ context 'yet valid or no error' do
20
+ # check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
21
+ it 'include normal check_box' do
22
+ args = [:text, {class: :test}, nil, nil]
23
+ expect(@f.check_box(*args)).to have_tag('div.normal-field', content: @df.check_box(*args))
24
+ end
25
+
26
+ # radio_button(method, tag_value, options = {})
27
+ it 'include normal radio button' do
28
+ args = [:text, nil, class: :test]
29
+ expect(@f.radio_button(*args)).to have_tag('div.normal-field', content: @df.radio_button(*args))
30
+ end
31
+
32
+ it 'include normal select' do
33
+ args = [:text, for_select, class: :test]
34
+ expect(@f.select(*args)).to have_tag('div.normal-field', content: @df.select(*args))
35
+ end
36
+ end
37
+
38
+ context 'when has error' do
39
+ context 'check_box' do
40
+ before :each do
41
+ @sample.valid?
42
+ @args = [:text, {class: :test}, nil, nil]
43
+ @html = @f.check_box(*@args)
44
+ end
45
+
46
+ it 'has error wrapper' do
47
+ expect(@html).to have_tag('div.field_with_errors', content: @df.check_box(*@args))
48
+ end
49
+
50
+ it 'has error message' do
51
+ expect(@html).to have_tag('ul.errors.text li.error.text')
52
+ end
53
+ end
54
+
55
+ context 'radio button' do
56
+ before :each do
57
+ @sample.valid?
58
+ @args = [:text, nil, class: :test]
59
+ @html = @f.radio_button(*@args)
60
+ end
61
+
62
+ it 'has error wrapper' do
63
+ expect(@html).to have_tag('div.field_with_errors', content: @df.radio_button(*@args))
64
+ end
65
+
66
+ it 'has error message' do
67
+ expect(@html).to have_tag('ul.errors.text li.error.text')
68
+ end
69
+ end
70
+
71
+ context 'select' do
72
+ before :each do
73
+ @sample.valid?
74
+ @args = [:text, for_select, class: :test]
75
+ @html = @f.select(*@args)
76
+ end
77
+
78
+ it 'has error wrapper' do
79
+ expect(@html).to have_tag('div.field_with_errors', content: @df.select(*@args))
80
+ end
81
+
82
+ it 'has error message' do
83
+ expect(@html).to have_tag('ul.errors.text li.error.text')
84
+ end
85
+ end
86
+ end
87
+
88
+ context 'when has error with no error option' do
89
+ context 'check_box' do
90
+ before :each do
91
+ @sample.valid?
92
+ @args = [:text, {class: :test, no_errors: true}, nil, nil]
93
+ @html = @f.check_box(*@args)
94
+ end
95
+
96
+ it 'has error wrapper' do
97
+ expect(@html).to have_tag('div.field_with_errors', content: @df.check_box(*@args))
98
+ end
99
+
100
+ it 'has no error message' do
101
+ expect(@html).not_to have_tag('ul.errors.text li.error.text')
102
+ end
103
+ end
104
+
105
+ # radio_button(method, tag_value, options = {})
106
+ context 'radio button' do
107
+ before :each do
108
+ @sample.valid?
109
+ @args = [:text, nil, class: :test, no_errors: true]
110
+ @html = @f.radio_button(*@args)
111
+ end
112
+
113
+ it 'has error wrapper' do
114
+ expect(@html).to have_tag('div.field_with_errors', content: @df.radio_button(*@args))
115
+ end
116
+
117
+ it 'has no error message' do
118
+ expect(@html).not_to have_tag('ul.errors.text li.error.text')
119
+ end
120
+ end
121
+
122
+ context 'select' do
123
+ before :each do
124
+ @sample.valid?
125
+ @args = [:text, for_select, class: :test, no_errors: true]
126
+ @html = @f.select(*@args)
127
+ end
128
+
129
+ it 'has error wrapper' do
130
+ expect(@html).to have_tag('div.field_with_errors', content: @df.select(*@args))
131
+ end
132
+
133
+ it 'has no error message' do
134
+ expect(@html).not_to have_tag('ul.errors.text li.error.text')
135
+ end
136
+ end
137
+ end
138
+
139
+ [:text_field, :password_field, :text_area,
140
+ :color_field, :search_field, :file_field,
141
+ :telephone_field, :phone_field, :url_field, :email_field,
142
+ :date_field, :time_field, :datetime_field, :datetime_local_field, :month_field, :week_field,
143
+ :number_field, :range_field].each do |selector|
144
+
145
+ context "raw #{selector}" do
146
+ before :each do
147
+ @args = [:text, class: :test]
148
+ @html = @f.send(selector, *@args)
149
+ end
150
+
151
+ it 'has wrapper' do
152
+ expect(@html).to have_tag('div.normal-field', content: @df.send(selector, *@args))
153
+ end
154
+
155
+ it 'has no error message' do
156
+ expect(@html).not_to have_tag('ul.errors.text li.error.text')
157
+ end
158
+ end
159
+
160
+ context "on error #{selector}" do
161
+ before :each do
162
+ @sample.valid?
163
+ @args = [:text, class: :test]
164
+ @html = @f.send(selector, *@args)
165
+ end
166
+
167
+ it 'has error wrapper' do
168
+ expect(@html).to have_tag('div.field_with_errors', content: @df.send(selector, *@args))
169
+ end
170
+
171
+ it 'has error message' do
172
+ expect(@html).to have_tag('ul.errors.text li.error.text')
173
+ end
174
+ end
175
+
176
+ context "with no error option, #{selector}" do
177
+ before :each do
178
+ @sample.valid?
179
+ @args = [:text, class: :test, no_errors: true]
180
+ @html = @f.send(selector, *@args)
181
+ end
182
+
183
+ it 'has error wrapper' do
184
+ expect(@html).to have_tag('div.field_with_errors', content: @df.send(selector, *@args))
185
+ end
186
+
187
+ it 'has no error message' do
188
+ expect(@html).not_to have_tag('ul.errors.text li.error.text')
189
+ end
190
+ end
191
+ end
192
+ end
193
+
194
+ context 'wrapping and no error' do
195
+ context "raw label" do
196
+ before :each do
197
+ @args = [:text, class: :test]
198
+ @html = @f.send(:label, *@args)
199
+ end
200
+
201
+ it 'has wrapper' do
202
+ expect(@html).to have_tag('div.normal-field', content: @df.send(:label, *@args))
203
+ end
204
+
205
+ it 'has no error message' do
206
+ expect(@html).not_to have_tag('ul.errors.text li.error.text')
207
+ end
208
+ end
209
+
210
+ context "on error label" do
211
+ before :each do
212
+ @sample.valid?
213
+ @args = [:text, class: :test]
214
+ @html = @f.send(:label, *@args)
215
+ end
216
+
217
+ it 'has error wrapper' do
218
+ expect(@html).to have_tag('div.field_with_errors', content: @df.send(:label, *@args))
219
+ end
220
+
221
+ it 'has no error message' do
222
+ expect(@html).not_to have_tag('ul.errors.text li.error.text')
223
+ end
224
+ end
225
+ end
226
+
227
+ context 'no wrapping no error' do
228
+ context 'raw hidden_field' do
229
+ it 'equal plane' do
230
+ @args = [:text, class: :test]
231
+ expect(@f.hidden_field *@args).to eq(@df.hidden_field *@args)
232
+ end
233
+ end
234
+
235
+ context 'on error hidden_field' do
236
+ it 'equal plane' do
237
+ @sample.valid?
238
+ @args = [:text, class: :test]
239
+ expect(@f.hidden_field *@args).to eq(@df.hidden_field *@args)
240
+ end
241
+ end
242
+ end
243
+ end
244
+ end