foundation_rails_helper 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.gitignore +1 -0
 - data/.travis.yml +2 -0
 - data/CHANGELOG.md +7 -0
 - data/CONTRIBUTING.md +40 -0
 - data/LICENSE +2 -2
 - data/README.md +44 -58
 - data/foundation_rails_helper.gemspec +1 -1
 - data/lib/foundation_rails_helper.rb +2 -1
 - data/lib/foundation_rails_helper/action_view_extension.rb +0 -2
 - data/lib/foundation_rails_helper/configuration.rb +25 -0
 - data/lib/foundation_rails_helper/flash_helper.rb +4 -3
 - data/lib/foundation_rails_helper/form_builder.rb +10 -8
 - data/lib/foundation_rails_helper/version.rb +1 -1
 - data/spec/foundation_rails_helper/configuration_spec.rb +37 -0
 - data/spec/foundation_rails_helper/flash_helper_spec.rb +10 -10
 - data/spec/foundation_rails_helper/form_builder_spec.rb +304 -147
 - data/spec/support/mock_rails.rb +44 -44
 - metadata +10 -6
 
| 
         @@ -9,28 +9,28 @@ describe "FoundationRailsHelper::FormHelper" do 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              it 'should have FoundationRailsHelper::FormHelper as default buidler' do
         
     | 
| 
       11 
11 
     | 
    
         
             
                form_for(@author) do |builder|
         
     | 
| 
       12 
     | 
    
         
            -
                  builder.class. 
     | 
| 
      
 12 
     | 
    
         
            +
                  expect(builder.class).to eq FoundationRailsHelper::FormBuilder
         
     | 
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
       14 
14 
     | 
    
         
             
              end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              it "should display labels by default" do
         
     | 
| 
       17 
17 
     | 
    
         
             
                form_for(@author) do |builder|
         
     | 
| 
       18 
18 
     | 
    
         
             
                  node = Capybara.string builder.text_field(:login)
         
     | 
| 
       19 
     | 
    
         
            -
                  node. 
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(node).to have_css('label[for="author_login"]', :text => "Login")
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
       21 
21 
     | 
    
         
             
              end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
              it "should not display labels by if there are options without auto_labels: false" do
         
     | 
| 
       24 
24 
     | 
    
         
             
                form_for(@author, {html: {class: 'myclass'}}) do |builder|
         
     | 
| 
       25 
25 
     | 
    
         
             
                  node = Capybara.string builder.text_field(:login)
         
     | 
| 
       26 
     | 
    
         
            -
                  node. 
     | 
| 
      
 26 
     | 
    
         
            +
                  expect(node).to have_css('label[for="author_login"]', :text => "Login")
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
              it "should not display labels by if there are options without auto_labels: false" do
         
     | 
| 
       31 
31 
     | 
    
         
             
                form_for(@author, {html: {class: 'myclass'}, auto_labels: false}) do |builder|
         
     | 
| 
       32 
32 
     | 
    
         
             
                  node = Capybara.string builder.text_field(:login)
         
     | 
| 
       33 
     | 
    
         
            -
                  node. 
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(node).to_not have_css('label[for="author_login"]', :text => "Login")
         
     | 
| 
       34 
34 
     | 
    
         
             
                end
         
     | 
| 
       35 
35 
     | 
    
         
             
              end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
         @@ -38,285 +38,306 @@ describe "FoundationRailsHelper::FormHelper" do 
     | 
|
| 
       38 
38 
     | 
    
         
             
                it "should generate text_field input" do
         
     | 
| 
       39 
39 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       40 
40 
     | 
    
         
             
                    node = Capybara.string builder.text_field(:login)
         
     | 
| 
       41 
     | 
    
         
            -
                    node. 
     | 
| 
       42 
     | 
    
         
            -
                    node. 
     | 
| 
       43 
     | 
    
         
            -
                    node.find_field('author_login').value. 
     | 
| 
      
 41 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_login"]', :text => "Login")
         
     | 
| 
      
 42 
     | 
    
         
            +
                    expect(node).to have_css('input[type="text"][name="author[login]"]')
         
     | 
| 
      
 43 
     | 
    
         
            +
                    expect(node.find_field('author_login').value).to eq @author.login
         
     | 
| 
       44 
44 
     | 
    
         
             
                  end
         
     | 
| 
       45 
45 
     | 
    
         
             
                end
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
                it "should generate text_field input without label" do
         
     | 
| 
       48 
48 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       49 
49 
     | 
    
         
             
                    node = Capybara.string builder.text_field(:login, :label => false)
         
     | 
| 
       50 
     | 
    
         
            -
                    node. 
     | 
| 
       51 
     | 
    
         
            -
                    node. 
     | 
| 
       52 
     | 
    
         
            -
                    node.find_field('author_login').value. 
     | 
| 
      
 50 
     | 
    
         
            +
                    expect(node).to_not have_css('label[for="author_login"]', :text => "Login")
         
     | 
| 
      
 51 
     | 
    
         
            +
                    expect(node).to have_css('input[type="text"][name="author[login]"]')
         
     | 
| 
      
 52 
     | 
    
         
            +
                    expect(node.find_field('author_login').value).to eq @author.login
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                it "should generate text_field with class from options" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                  form_for(@author) do |builder|
         
     | 
| 
      
 58 
     | 
    
         
            +
                    node = Capybara.string builder.text_field(:login, :class => 'righteous')
         
     | 
| 
      
 59 
     | 
    
         
            +
                    expect(node).to have_css('input.righteous[type="text"][name="author[login]"]')
         
     | 
| 
       53 
60 
     | 
    
         
             
                  end
         
     | 
| 
       54 
61 
     | 
    
         
             
                end
         
     | 
| 
       55 
62 
     | 
    
         | 
| 
       56 
63 
     | 
    
         
             
                it "should generate password_field input" do
         
     | 
| 
       57 
64 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       58 
65 
     | 
    
         
             
                    node = Capybara.string builder.password_field(:password)
         
     | 
| 
       59 
     | 
    
         
            -
                    node. 
     | 
| 
       60 
     | 
    
         
            -
                    node. 
     | 
| 
       61 
     | 
    
         
            -
                    node.find_field('author_password').value. 
     | 
| 
      
 66 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_password"]', :text => "Password")
         
     | 
| 
      
 67 
     | 
    
         
            +
                    expect(node).to have_css('input[type="password"][name="author[password]"]')
         
     | 
| 
      
 68 
     | 
    
         
            +
                    expect(node.find_field('author_password').value).to be_nil
         
     | 
| 
       62 
69 
     | 
    
         
             
                  end
         
     | 
| 
       63 
70 
     | 
    
         
             
                end
         
     | 
| 
       64 
71 
     | 
    
         | 
| 
       65 
72 
     | 
    
         
             
                it "should generate email_field input" do
         
     | 
| 
       66 
73 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       67 
74 
     | 
    
         
             
                    node = Capybara.string builder.email_field(:email)
         
     | 
| 
       68 
     | 
    
         
            -
                    node. 
     | 
| 
       69 
     | 
    
         
            -
                    node. 
     | 
| 
       70 
     | 
    
         
            -
                    node.find_field('author_email').value. 
     | 
| 
      
 75 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_email"]', :text => "Email")
         
     | 
| 
      
 76 
     | 
    
         
            +
                    expect(node).to have_css('input[type="email"][name="author[email]"]')
         
     | 
| 
      
 77 
     | 
    
         
            +
                    expect(node.find_field('author_email').value).to eq @author.email
         
     | 
| 
       71 
78 
     | 
    
         
             
                  end
         
     | 
| 
       72 
79 
     | 
    
         
             
                end
         
     | 
| 
       73 
80 
     | 
    
         | 
| 
       74 
81 
     | 
    
         
             
                it "should generate url_field input" do
         
     | 
| 
       75 
82 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       76 
83 
     | 
    
         
             
                    node = Capybara.string builder.url_field(:url)
         
     | 
| 
       77 
     | 
    
         
            -
                    node. 
     | 
| 
       78 
     | 
    
         
            -
                    node. 
     | 
| 
       79 
     | 
    
         
            -
                    node.find_field('author_url').value. 
     | 
| 
      
 84 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_url"]', :text => "Url")
         
     | 
| 
      
 85 
     | 
    
         
            +
                    expect(node).to have_css('input[type="url"][name="author[url]"]')
         
     | 
| 
      
 86 
     | 
    
         
            +
                    expect(node.find_field('author_url').value).to eq @author.url
         
     | 
| 
       80 
87 
     | 
    
         
             
                  end
         
     | 
| 
       81 
88 
     | 
    
         
             
                end
         
     | 
| 
       82 
89 
     | 
    
         | 
| 
       83 
90 
     | 
    
         
             
                it "should generate phone_field input" do
         
     | 
| 
       84 
91 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       85 
92 
     | 
    
         
             
                    node = Capybara.string builder.phone_field(:phone)
         
     | 
| 
       86 
     | 
    
         
            -
                    node. 
     | 
| 
       87 
     | 
    
         
            -
                    node. 
     | 
| 
       88 
     | 
    
         
            -
                    node.find_field('author_phone').value. 
     | 
| 
      
 93 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_phone"]', :text => "Phone")
         
     | 
| 
      
 94 
     | 
    
         
            +
                    expect(node).to have_css('input[type="tel"][name="author[phone]"]')
         
     | 
| 
      
 95 
     | 
    
         
            +
                    expect(node.find_field('author_phone').value).to eq @author.phone
         
     | 
| 
       89 
96 
     | 
    
         
             
                  end
         
     | 
| 
       90 
97 
     | 
    
         
             
                end
         
     | 
| 
       91 
98 
     | 
    
         | 
| 
       92 
99 
     | 
    
         
             
                it "should generate number_field input" do
         
     | 
| 
       93 
100 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       94 
101 
     | 
    
         
             
                    node = Capybara.string builder.number_field(:some_number)
         
     | 
| 
       95 
     | 
    
         
            -
                    node. 
     | 
| 
       96 
     | 
    
         
            -
                    node. 
     | 
| 
       97 
     | 
    
         
            -
                    node.find_field('author_some_number').value. 
     | 
| 
      
 102 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_some_number"]', :text => "Some number")
         
     | 
| 
      
 103 
     | 
    
         
            +
                    expect(node).to have_css('input[type="number"][name="author[some_number]"]')
         
     | 
| 
      
 104 
     | 
    
         
            +
                    expect(node.find_field('author_some_number').value).to eq @author.some_number
         
     | 
| 
       98 
105 
     | 
    
         
             
                  end
         
     | 
| 
       99 
106 
     | 
    
         
             
                end
         
     | 
| 
       100 
107 
     | 
    
         | 
| 
       101 
108 
     | 
    
         
             
                it "should generate text_area input" do
         
     | 
| 
       102 
109 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       103 
110 
     | 
    
         
             
                    node = Capybara.string builder.text_area(:description)
         
     | 
| 
       104 
     | 
    
         
            -
                    node. 
     | 
| 
       105 
     | 
    
         
            -
                    node. 
     | 
| 
       106 
     | 
    
         
            -
                    node.find_field('author_description').value.strip. 
     | 
| 
      
 111 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_description"]', :text => "Description")
         
     | 
| 
      
 112 
     | 
    
         
            +
                    expect(node).to have_css('textarea[name="author[description]"]')
         
     | 
| 
      
 113 
     | 
    
         
            +
                    expect(node.find_field('author_description').value.strip).to eq @author.description
         
     | 
| 
       107 
114 
     | 
    
         
             
                  end
         
     | 
| 
       108 
115 
     | 
    
         
             
                end
         
     | 
| 
       109 
116 
     | 
    
         | 
| 
       110 
117 
     | 
    
         
             
                it "should generate file_field input" do
         
     | 
| 
       111 
118 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       112 
119 
     | 
    
         
             
                    node = Capybara.string builder.file_field(:avatar)
         
     | 
| 
       113 
     | 
    
         
            -
                    node. 
     | 
| 
       114 
     | 
    
         
            -
                    node. 
     | 
| 
       115 
     | 
    
         
            -
                    node.find_field('author_avatar').value. 
     | 
| 
      
 120 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_avatar"]', :text => "Avatar")
         
     | 
| 
      
 121 
     | 
    
         
            +
                    expect(node).to have_css('input[type="file"][name="author[avatar]"]')
         
     | 
| 
      
 122 
     | 
    
         
            +
                    expect(node.find_field('author_avatar').value).to  be_nil
         
     | 
| 
       116 
123 
     | 
    
         
             
                  end
         
     | 
| 
       117 
124 
     | 
    
         
             
                end
         
     | 
| 
       118 
125 
     | 
    
         | 
| 
       119 
126 
     | 
    
         
             
                it "should generate select input" do
         
     | 
| 
       120 
127 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       121 
128 
     | 
    
         
             
                    node = Capybara.string builder.select(:description, [["Choice #1", :a], ["Choice #2", :b]])
         
     | 
| 
       122 
     | 
    
         
            -
                    node. 
     | 
| 
       123 
     | 
    
         
            -
                    node. 
     | 
| 
       124 
     | 
    
         
            -
                    node. 
     | 
| 
       125 
     | 
    
         
            -
                    node. 
     | 
| 
      
 129 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_description"]', :text => "Description")
         
     | 
| 
      
 130 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[description]"]')
         
     | 
| 
      
 131 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[description]"] option[value="a"]', :text => "Choice #1")
         
     | 
| 
      
 132 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[description]"] option[value="b"]', :text => "Choice #2")
         
     | 
| 
       126 
133 
     | 
    
         
             
                  end
         
     | 
| 
       127 
134 
     | 
    
         
             
                end
         
     | 
| 
       128 
135 
     | 
    
         | 
| 
       129 
136 
     | 
    
         
             
                it "should generate check_box input" do
         
     | 
| 
       130 
137 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       131 
138 
     | 
    
         
             
                    node = Capybara.string builder.check_box(:active)
         
     | 
| 
       132 
     | 
    
         
            -
                    node. 
     | 
| 
       133 
     | 
    
         
            -
                    node. 
     | 
| 
       134 
     | 
    
         
            -
                    node. 
     | 
| 
      
 139 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_active"] input[type="hidden"][name="author[active]"][value="0"]')
         
     | 
| 
      
 140 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_active"] input[type="checkbox"][name="author[active]"]')
         
     | 
| 
      
 141 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_active"]', :text => "Active")
         
     | 
| 
       135 
142 
     | 
    
         
             
                  end
         
     | 
| 
       136 
143 
     | 
    
         
             
                end
         
     | 
| 
       137 
144 
     | 
    
         
             
                it "should generate check_box input without a label" do
         
     | 
| 
       138 
145 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       139 
146 
     | 
    
         
             
                    node = Capybara.string builder.check_box(:active, :label => false)
         
     | 
| 
       140 
     | 
    
         
            -
                    node. 
     | 
| 
       141 
     | 
    
         
            -
                    node. 
     | 
| 
       142 
     | 
    
         
            -
                    node. 
     | 
| 
      
 147 
     | 
    
         
            +
                    expect(node).to have_css('input[type="hidden"][name="author[active]"][value="0"]')
         
     | 
| 
      
 148 
     | 
    
         
            +
                    expect(node).to have_css('input[type="checkbox"][name="author[active]"]')
         
     | 
| 
      
 149 
     | 
    
         
            +
                    expect(node).to_not have_css('label[for="author_active"]')
         
     | 
| 
       143 
150 
     | 
    
         
             
                  end
         
     | 
| 
       144 
151 
     | 
    
         
             
                end
         
     | 
| 
       145 
152 
     | 
    
         | 
| 
       146 
153 
     | 
    
         
             
                it "should generate radio_button input" do
         
     | 
| 
       147 
154 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       148 
     | 
    
         
            -
                    node = Capybara.string 
     | 
| 
       149 
     | 
    
         
            -
                    node. 
     | 
| 
      
 155 
     | 
    
         
            +
                    node = Capybara.string builder.radio_button(:active, "ok")
         
     | 
| 
      
 156 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_active_ok"]')
         
     | 
| 
      
 157 
     | 
    
         
            +
                    expect(node).to have_css('input[type="radio"][name="author[active]"]')
         
     | 
| 
       150 
158 
     | 
    
         
             
                  end
         
     | 
| 
       151 
159 
     | 
    
         
             
                end
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
                it "should generate radio_button input" do
         
     | 
| 
      
 160 
     | 
    
         
            +
                it "should generate radio_button input with a label" do
         
     | 
| 
       154 
161 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       155 
     | 
    
         
            -
                    node = Capybara.string builder.radio_button(:active, true,  
     | 
| 
       156 
     | 
    
         
            -
                    node. 
     | 
| 
       157 
     | 
    
         
            -
                    node. 
     | 
| 
      
 162 
     | 
    
         
            +
                    node = Capybara.string builder.radio_button(:active, true, label: "Functioning")
         
     | 
| 
      
 163 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_active_true"]', text: "Functioning")
         
     | 
| 
      
 164 
     | 
    
         
            +
                    expect(node).to have_css('input[type="radio"][name="author[active]"]')
         
     | 
| 
      
 165 
     | 
    
         
            +
                  end
         
     | 
| 
      
 166 
     | 
    
         
            +
                end
         
     | 
| 
      
 167 
     | 
    
         
            +
                it "should generate radio_button without a label" do
         
     | 
| 
      
 168 
     | 
    
         
            +
                  form_for(@author) do |builder|
         
     | 
| 
      
 169 
     | 
    
         
            +
                    node = Capybara.string builder.radio_button(:active, "ok", label: false)
         
     | 
| 
      
 170 
     | 
    
         
            +
                    expect(node).to_not have_css('label[for="author_active_ok"]')
         
     | 
| 
      
 171 
     | 
    
         
            +
                    expect(node).to have_css('input[type="radio"][name="author[active]"]')
         
     | 
| 
      
 172 
     | 
    
         
            +
                  end
         
     | 
| 
      
 173 
     | 
    
         
            +
                end
         
     | 
| 
      
 174 
     | 
    
         
            +
                it "should generate radio_button with label options" do
         
     | 
| 
      
 175 
     | 
    
         
            +
                  form_for(@author) do |builder|
         
     | 
| 
      
 176 
     | 
    
         
            +
                    node = Capybara.string builder.radio_button(:active, "ok", class: 'very', label_options: { class: 'special' })
         
     | 
| 
      
 177 
     | 
    
         
            +
                    expect(node).to have_css('label.special[for="author_active_ok"]')
         
     | 
| 
      
 178 
     | 
    
         
            +
                    expect(node).to have_css('input.very[type="radio"][name="author[active]"]')
         
     | 
| 
       158 
179 
     | 
    
         
             
                  end
         
     | 
| 
       159 
180 
     | 
    
         
             
                end
         
     | 
| 
       160 
181 
     | 
    
         | 
| 
       161 
182 
     | 
    
         
             
                it "should generate date_select input" do
         
     | 
| 
       162 
183 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       163 
184 
     | 
    
         
             
                    node = Capybara.string builder.label(:birthdate) + builder.date_select(:birthdate)
         
     | 
| 
       164 
     | 
    
         
            -
                    node. 
     | 
| 
       165 
     | 
    
         
            -
                    %w(1 2 3).each {|i| node. 
     | 
| 
       166 
     | 
    
         
            -
                    node. 
     | 
| 
       167 
     | 
    
         
            -
                    node. 
     | 
| 
       168 
     | 
    
         
            -
                    node. 
     | 
| 
       169 
     | 
    
         
            -
                    %w(4 5).each   {|i| node. 
     | 
| 
      
 185 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
         
     | 
| 
      
 186 
     | 
    
         
            +
                    %w(1 2 3).each {|i| expect(node).to     have_css("select[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
      
 187 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
         
     | 
| 
      
 188 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
         
     | 
| 
      
 189 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
         
     | 
| 
      
 190 
     | 
    
         
            +
                    %w(4 5).each   {|i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
       170 
191 
     | 
    
         
             
                  end
         
     | 
| 
       171 
192 
     | 
    
         
             
                end
         
     | 
| 
       172 
193 
     | 
    
         | 
| 
       173 
194 
     | 
    
         
             
                it "should generate date_select input with  :discard_year => true" do
         
     | 
| 
       174 
195 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       175 
196 
     | 
    
         
             
                    node = Capybara.string builder.label(:birthdate) + builder.date_select(:birthdate, :discard_year => true)
         
     | 
| 
       176 
     | 
    
         
            -
                    node. 
     | 
| 
       177 
     | 
    
         
            -
                    %w(2 3).each {|i| node. 
     | 
| 
       178 
     | 
    
         
            -
                    node. 
     | 
| 
       179 
     | 
    
         
            -
                    node. 
     | 
| 
       180 
     | 
    
         
            -
                    node. 
     | 
| 
       181 
     | 
    
         
            -
                    %w(1 4 5).each   {|i| node. 
     | 
| 
      
 197 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
         
     | 
| 
      
 198 
     | 
    
         
            +
                    %w(2 3).each {|i| expect(node).to     have_css("select[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
      
 199 
     | 
    
         
            +
                    expect(node).to_not have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
         
     | 
| 
      
 200 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
         
     | 
| 
      
 201 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
         
     | 
| 
      
 202 
     | 
    
         
            +
                    %w(1 4 5).each   {|i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
       182 
203 
     | 
    
         
             
                  end
         
     | 
| 
       183 
204 
     | 
    
         
             
                end
         
     | 
| 
       184 
205 
     | 
    
         | 
| 
       185 
206 
     | 
    
         
             
                it "should generate datetime_select input" do
         
     | 
| 
       186 
207 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       187 
208 
     | 
    
         
             
                    node = Capybara.string builder.label(:birthdate) + builder.datetime_select(:birthdate)
         
     | 
| 
       188 
     | 
    
         
            -
                    node. 
     | 
| 
       189 
     | 
    
         
            -
                    %w(1 2 3 4 5).each {|i| node. 
     | 
| 
       190 
     | 
    
         
            -
                    node. 
     | 
| 
       191 
     | 
    
         
            -
                    node. 
     | 
| 
       192 
     | 
    
         
            -
                    node. 
     | 
| 
       193 
     | 
    
         
            -
                    node. 
     | 
| 
       194 
     | 
    
         
            -
                    node. 
     | 
| 
      
 209 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
         
     | 
| 
      
 210 
     | 
    
         
            +
                    %w(1 2 3 4 5).each {|i| expect(node).to     have_css("select[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
      
 211 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
         
     | 
| 
      
 212 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
         
     | 
| 
      
 213 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
         
     | 
| 
      
 214 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_4i option[selected="selected"][value="20"]')
         
     | 
| 
      
 215 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_5i option[selected="selected"][value="30"]')
         
     | 
| 
       195 
216 
     | 
    
         
             
                  end
         
     | 
| 
       196 
217 
     | 
    
         
             
                end
         
     | 
| 
       197 
218 
     | 
    
         | 
| 
       198 
219 
     | 
    
         
             
                it "should generate datetime_select input with  :discard_year => true" do
         
     | 
| 
       199 
220 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       200 
221 
     | 
    
         
             
                    node = Capybara.string builder.label(:birthdate) + builder.datetime_select(:birthdate, :discard_year => true)
         
     | 
| 
       201 
     | 
    
         
            -
                    node. 
     | 
| 
       202 
     | 
    
         
            -
                    %w(2 3 4 5).each {|i| node. 
     | 
| 
       203 
     | 
    
         
            -
                    node. 
     | 
| 
       204 
     | 
    
         
            -
                    node. 
     | 
| 
       205 
     | 
    
         
            -
                    node. 
     | 
| 
       206 
     | 
    
         
            -
                    node. 
     | 
| 
       207 
     | 
    
         
            -
                    node. 
     | 
| 
       208 
     | 
    
         
            -
                    %w(1).each   {|i| node. 
     | 
| 
      
 222 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
         
     | 
| 
      
 223 
     | 
    
         
            +
                    %w(2 3 4 5).each {|i| expect(node).to     have_css("select[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
      
 224 
     | 
    
         
            +
                    expect(node).to_not have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
         
     | 
| 
      
 225 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
         
     | 
| 
      
 226 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
         
     | 
| 
      
 227 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_4i option[selected="selected"][value="20"]')
         
     | 
| 
      
 228 
     | 
    
         
            +
                    expect(node).to have_css('select#author_birthdate_5i option[selected="selected"][value="30"]')
         
     | 
| 
      
 229 
     | 
    
         
            +
                    %w(1).each   {|i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
       209 
230 
     | 
    
         
             
                  end
         
     | 
| 
       210 
231 
     | 
    
         
             
                end
         
     | 
| 
       211 
232 
     | 
    
         | 
| 
       212 
233 
     | 
    
         
             
                it "should generate time_zone_select input" do
         
     | 
| 
       213 
234 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       214 
235 
     | 
    
         
             
                    node = Capybara.string builder.label(:time_zone) + builder.time_zone_select(:time_zone)
         
     | 
| 
       215 
     | 
    
         
            -
                    node. 
     | 
| 
       216 
     | 
    
         
            -
                    node. 
     | 
| 
       217 
     | 
    
         
            -
                    node. 
     | 
| 
      
 236 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_time_zone"]', :text => "Time zone")
         
     | 
| 
      
 237 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[time_zone]"]')
         
     | 
| 
      
 238 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[time_zone]"] option[value="Perth"]', :text => "(GMT+08:00) Perth")
         
     | 
| 
       218 
239 
     | 
    
         
             
                  end
         
     | 
| 
       219 
240 
     | 
    
         
             
                end
         
     | 
| 
       220 
241 
     | 
    
         | 
| 
       221 
242 
     | 
    
         
             
                it "should generate date_field input" do
         
     | 
| 
       222 
243 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       223 
244 
     | 
    
         
             
                    node = Capybara.string builder.date_field(:publish_date)
         
     | 
| 
       224 
     | 
    
         
            -
                    node. 
     | 
| 
       225 
     | 
    
         
            -
                    node. 
     | 
| 
       226 
     | 
    
         
            -
                    node.find_field('author_publish_date').value. 
     | 
| 
      
 245 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_publish_date"]', :text => "date")
         
     | 
| 
      
 246 
     | 
    
         
            +
                    expect(node).to have_css('input[type="date"][name="author[publish_date]"]')
         
     | 
| 
      
 247 
     | 
    
         
            +
                    expect(node.find_field('author_publish_date').value).to eq @author.publish_date.to_s
         
     | 
| 
       227 
248 
     | 
    
         
             
                  end
         
     | 
| 
       228 
249 
     | 
    
         
             
                end
         
     | 
| 
       229 
250 
     | 
    
         | 
| 
       230 
251 
     | 
    
         
             
                it "should generate datetime_field input" do
         
     | 
| 
       231 
252 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       232 
253 
     | 
    
         
             
                    node = Capybara.string  builder.datetime_field(:forty_two)
         
     | 
| 
       233 
     | 
    
         
            -
                    node. 
     | 
| 
       234 
     | 
    
         
            -
                    node. 
     | 
| 
      
 254 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
         
     | 
| 
      
 255 
     | 
    
         
            +
                    expect(node).to have_css('input[type="datetime"][name="author[forty_two]"]')
         
     | 
| 
       235 
256 
     | 
    
         
             
                    value = DateTime.parse( node.find_field('author_forty_two').value)
         
     | 
| 
       236 
     | 
    
         
            -
                    value. 
     | 
| 
      
 257 
     | 
    
         
            +
                    expect(value).to eq @author.forty_two.to_s
         
     | 
| 
       237 
258 
     | 
    
         
             
                  end
         
     | 
| 
       238 
259 
     | 
    
         
             
                end
         
     | 
| 
       239 
260 
     | 
    
         | 
| 
       240 
261 
     | 
    
         
             
                it "should generate datetime_local_field" do
         
     | 
| 
       241 
262 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       242 
263 
     | 
    
         
             
                    node = Capybara.string builder.datetime_local_field(:forty_two)
         
     | 
| 
       243 
     | 
    
         
            -
                    node. 
     | 
| 
       244 
     | 
    
         
            -
                    node. 
     | 
| 
       245 
     | 
    
         
            -
                    node.find_field('author_forty_two').value. 
     | 
| 
      
 264 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
         
     | 
| 
      
 265 
     | 
    
         
            +
                    expect(node).to have_css('input[type="datetime-local"][name="author[forty_two]"]')
         
     | 
| 
      
 266 
     | 
    
         
            +
                    expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%Y-%m-%dT%H:%M:%S")
         
     | 
| 
       246 
267 
     | 
    
         
             
                  end
         
     | 
| 
       247 
268 
     | 
    
         
             
                end
         
     | 
| 
       248 
269 
     | 
    
         | 
| 
       249 
270 
     | 
    
         
             
                it "should generate month_field input" do
         
     | 
| 
       250 
271 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       251 
272 
     | 
    
         
             
                    node = Capybara.string  builder.month_field(:forty_two)
         
     | 
| 
       252 
     | 
    
         
            -
                    node. 
     | 
| 
       253 
     | 
    
         
            -
                    node. 
     | 
| 
       254 
     | 
    
         
            -
                    node.find_field('author_forty_two').value. 
     | 
| 
      
 273 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
         
     | 
| 
      
 274 
     | 
    
         
            +
                    expect(node).to have_css('input[type="month"][name="author[forty_two]"]')
         
     | 
| 
      
 275 
     | 
    
         
            +
                    expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%Y-%m")
         
     | 
| 
       255 
276 
     | 
    
         
             
                  end
         
     | 
| 
       256 
277 
     | 
    
         
             
                end
         
     | 
| 
       257 
278 
     | 
    
         | 
| 
       258 
279 
     | 
    
         
             
                it "should generate week_field" do
         
     | 
| 
       259 
280 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       260 
281 
     | 
    
         
             
                    node = Capybara.string  builder.week_field(:forty_two)
         
     | 
| 
       261 
     | 
    
         
            -
                    node. 
     | 
| 
       262 
     | 
    
         
            -
                    node. 
     | 
| 
       263 
     | 
    
         
            -
                    node.find_field('author_forty_two').value. 
     | 
| 
      
 282 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
         
     | 
| 
      
 283 
     | 
    
         
            +
                    expect(node).to have_css('input[type="week"][name="author[forty_two]"]')
         
     | 
| 
      
 284 
     | 
    
         
            +
                    expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%Y-W%V")
         
     | 
| 
       264 
285 
     | 
    
         
             
                  end
         
     | 
| 
       265 
286 
     | 
    
         
             
                end
         
     | 
| 
       266 
287 
     | 
    
         | 
| 
       267 
288 
     | 
    
         
             
                it "should generate time_field" do
         
     | 
| 
       268 
289 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       269 
290 
     | 
    
         
             
                    node = Capybara.string  builder.time_field(:forty_two)
         
     | 
| 
       270 
     | 
    
         
            -
                    node. 
     | 
| 
       271 
     | 
    
         
            -
                    node. 
     | 
| 
       272 
     | 
    
         
            -
                    node.find_field('author_forty_two').value. 
     | 
| 
      
 291 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
         
     | 
| 
      
 292 
     | 
    
         
            +
                    expect(node).to have_css('input[type="time"][name="author[forty_two]"]')
         
     | 
| 
      
 293 
     | 
    
         
            +
                    expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%H:%M:%S.%L")
         
     | 
| 
       273 
294 
     | 
    
         
             
                  end
         
     | 
| 
       274 
295 
     | 
    
         
             
                end
         
     | 
| 
       275 
296 
     | 
    
         | 
| 
       276 
297 
     | 
    
         
             
                it "should generate range_field" do
         
     | 
| 
       277 
298 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       278 
299 
     | 
    
         
             
                    node = Capybara.string builder.range_field(:some_number)
         
     | 
| 
       279 
     | 
    
         
            -
                    node. 
     | 
| 
       280 
     | 
    
         
            -
                    node. 
     | 
| 
       281 
     | 
    
         
            -
                    node.find_field('author_some_number').value. 
     | 
| 
      
 300 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_some_number"]', :text => "Some number")
         
     | 
| 
      
 301 
     | 
    
         
            +
                    expect(node).to have_css('input[type="range"][name="author[some_number]"]')
         
     | 
| 
      
 302 
     | 
    
         
            +
                    expect(node.find_field('author_some_number').value).to eq @author.some_number
         
     | 
| 
       282 
303 
     | 
    
         
             
                  end
         
     | 
| 
       283 
304 
     | 
    
         
             
                end
         
     | 
| 
       284 
305 
     | 
    
         | 
| 
       285 
306 
     | 
    
         
             
                it "should generate search_field" do
         
     | 
| 
       286 
307 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       287 
308 
     | 
    
         
             
                    node = Capybara.string builder.search_field(:description)
         
     | 
| 
       288 
     | 
    
         
            -
                    node. 
     | 
| 
       289 
     | 
    
         
            -
                    node. 
     | 
| 
       290 
     | 
    
         
            -
                    node.find_field('author_description').value. 
     | 
| 
      
 309 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_description"]', :text => "Description")
         
     | 
| 
      
 310 
     | 
    
         
            +
                    expect(node).to have_css('input[type="search"][name="author[description]"]')
         
     | 
| 
      
 311 
     | 
    
         
            +
                    expect(node.find_field('author_description').value).to eq @author.description
         
     | 
| 
       291 
312 
     | 
    
         
             
                  end
         
     | 
| 
       292 
313 
     | 
    
         
             
                end
         
     | 
| 
       293 
314 
     | 
    
         | 
| 
       294 
315 
     | 
    
         
             
                it "should generate color_field" do
         
     | 
| 
       295 
316 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       296 
317 
     | 
    
         
             
                    node = Capybara.string builder.color_field(:favorite_color)
         
     | 
| 
       297 
     | 
    
         
            -
                    node. 
     | 
| 
       298 
     | 
    
         
            -
                    node. 
     | 
| 
       299 
     | 
    
         
            -
                    node.find_field('author_favorite_color').value. 
     | 
| 
      
 318 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_favorite_color"]', :text => "Favorite color")
         
     | 
| 
      
 319 
     | 
    
         
            +
                    expect(node).to have_css('input[type="color"][name="author[favorite_color]"]')
         
     | 
| 
      
 320 
     | 
    
         
            +
                    expect(node.find_field('author_favorite_color').value).to eq @author.favorite_color
         
     | 
| 
       300 
321 
     | 
    
         
             
                  end
         
     | 
| 
       301 
322 
     | 
    
         
             
                end
         
     | 
| 
       302 
323 
     | 
    
         | 
| 
       303 
324 
     | 
    
         
             
                it "should generate collection_select input" do
         
     | 
| 
       304 
325 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       305 
326 
     | 
    
         
             
                    node = Capybara.string builder.collection_select(:favorite_book, Book.all, :id, :title)
         
     | 
| 
       306 
     | 
    
         
            -
                    node. 
     | 
| 
       307 
     | 
    
         
            -
                    node. 
     | 
| 
       308 
     | 
    
         
            -
                    node. 
     | 
| 
       309 
     | 
    
         
            -
                    node. 
     | 
| 
      
 327 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_favorite_book"]', :text => "Favorite book")
         
     | 
| 
      
 328 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[favorite_book]"]')
         
     | 
| 
      
 329 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[favorite_book]"] option[value="78"]', :text => "Gulliver's Travels")
         
     | 
| 
      
 330 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[favorite_book]"] option[value="133"]', :text => "Treasure Island")
         
     | 
| 
       310 
331 
     | 
    
         
             
                  end
         
     | 
| 
       311 
332 
     | 
    
         
             
                end
         
     | 
| 
       312 
333 
     | 
    
         | 
| 
       313 
334 
     | 
    
         
             
                it "should generate grouped_collection_select input" do
         
     | 
| 
       314 
335 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       315 
336 
     | 
    
         
             
                    node = Capybara.string builder.grouped_collection_select(:favorite_book, Genre.all, :books, :name, :id, :title)
         
     | 
| 
       316 
     | 
    
         
            -
                    node. 
     | 
| 
       317 
     | 
    
         
            -
                    node. 
     | 
| 
       318 
     | 
    
         
            -
                    node. 
     | 
| 
       319 
     | 
    
         
            -
                    node. 
     | 
| 
      
 337 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_favorite_book"]', :text => "Favorite book")
         
     | 
| 
      
 338 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[favorite_book]"]')
         
     | 
| 
      
 339 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[favorite_book]"] optgroup[label="Exploration"] option[value="78"]', :text => "Gulliver's Travels")
         
     | 
| 
      
 340 
     | 
    
         
            +
                    expect(node).to have_css('select[name="author[favorite_book]"] optgroup[label="Pirate Exploits"] option[value="133"]', :text => "Treasure Island")
         
     | 
| 
       320 
341 
     | 
    
         
             
                  end
         
     | 
| 
       321 
342 
     | 
    
         
             
                end
         
     | 
| 
       322 
343 
     | 
    
         
             
              end
         
     | 
| 
         @@ -325,14 +346,14 @@ describe "FoundationRailsHelper::FormHelper" do 
     | 
|
| 
       325 
346 
     | 
    
         
             
                it "should not display errors" do
         
     | 
| 
       326 
347 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       327 
348 
     | 
    
         
             
                    node = Capybara.string builder.text_field(:login)
         
     | 
| 
       328 
     | 
    
         
            -
                    node. 
     | 
| 
      
 349 
     | 
    
         
            +
                    expect(node).to_not have_css('small.error')
         
     | 
| 
       329 
350 
     | 
    
         
             
                  end
         
     | 
| 
       330 
351 
     | 
    
         
             
                end
         
     | 
| 
       331 
352 
     | 
    
         
             
                it "should display errors" do
         
     | 
| 
       332 
353 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       333 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 354 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:login => ['required']})
         
     | 
| 
       334 
355 
     | 
    
         
             
                    node = Capybara.string builder.text_field(:login)
         
     | 
| 
       335 
     | 
    
         
            -
                    node. 
     | 
| 
      
 356 
     | 
    
         
            +
                    expect(node).to have_css('small.error', :text => "required")
         
     | 
| 
       336 
357 
     | 
    
         
             
                  end
         
     | 
| 
       337 
358 
     | 
    
         
             
                end
         
     | 
| 
       338 
359 
     | 
    
         
             
                %w(file_field email_field text_field telephone_field phone_field
         
     | 
| 
         @@ -343,69 +364,69 @@ describe "FoundationRailsHelper::FormHelper" do 
     | 
|
| 
       343 
364 
     | 
    
         
             
                   ).each do |field|
         
     | 
| 
       344 
365 
     | 
    
         
             
                  it "should display errors on #{field} inputs" do
         
     | 
| 
       345 
366 
     | 
    
         
             
                    form_for(@author) do |builder|
         
     | 
| 
       346 
     | 
    
         
            -
                      @author. 
     | 
| 
      
 367 
     | 
    
         
            +
                      allow(@author).to receive(:errors).and_return({:description => ['required']})
         
     | 
| 
       347 
368 
     | 
    
         
             
                      node = Capybara.string builder.public_send(field, :description)
         
     | 
| 
       348 
     | 
    
         
            -
                      node. 
     | 
| 
       349 
     | 
    
         
            -
                      node. 
     | 
| 
      
 369 
     | 
    
         
            +
                      expect(node).to have_css('label.error[for="author_description"]')
         
     | 
| 
      
 370 
     | 
    
         
            +
                      expect(node).to have_css('input.error[name="author[description]"]')
         
     | 
| 
       350 
371 
     | 
    
         
             
                    end
         
     | 
| 
       351 
372 
     | 
    
         
             
                  end
         
     | 
| 
       352 
373 
     | 
    
         
             
                end
         
     | 
| 
       353 
374 
     | 
    
         
             
                it "should display errors on text_area inputs" do
         
     | 
| 
       354 
375 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       355 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 376 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:description => ['required']})
         
     | 
| 
       356 
377 
     | 
    
         
             
                    node = Capybara.string builder.text_area(:description)
         
     | 
| 
       357 
     | 
    
         
            -
                    node. 
     | 
| 
       358 
     | 
    
         
            -
                    node. 
     | 
| 
      
 378 
     | 
    
         
            +
                    expect(node).to have_css('label.error[for="author_description"]')
         
     | 
| 
      
 379 
     | 
    
         
            +
                    expect(node).to have_css('textarea.error[name="author[description]"]')
         
     | 
| 
       359 
380 
     | 
    
         
             
                  end
         
     | 
| 
       360 
381 
     | 
    
         
             
                end
         
     | 
| 
       361 
382 
     | 
    
         
             
                it "should display errors on select inputs" do
         
     | 
| 
       362 
383 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       363 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 384 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:favorite_book => ['required']})
         
     | 
| 
       364 
385 
     | 
    
         
             
                    node = Capybara.string builder.select(:favorite_book, [["Choice #1", :a], ["Choice #2", :b]])
         
     | 
| 
       365 
     | 
    
         
            -
                    node. 
     | 
| 
       366 
     | 
    
         
            -
                    node. 
     | 
| 
      
 386 
     | 
    
         
            +
                    expect(node).to have_css('label.error[for="author_favorite_book"]')
         
     | 
| 
      
 387 
     | 
    
         
            +
                    expect(node).to have_css('select.error[name="author[favorite_book]"]')
         
     | 
| 
       367 
388 
     | 
    
         
             
                  end
         
     | 
| 
       368 
389 
     | 
    
         
             
                end
         
     | 
| 
       369 
390 
     | 
    
         
             
                it "should display errors on date_select inputs" do
         
     | 
| 
       370 
391 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       371 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 392 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:birthdate => ['required']})
         
     | 
| 
       372 
393 
     | 
    
         
             
                    node = Capybara.string builder.date_select(:birthdate)
         
     | 
| 
       373 
     | 
    
         
            -
                    node. 
     | 
| 
       374 
     | 
    
         
            -
                    %w(1 2 3).each {|i| node. 
     | 
| 
      
 394 
     | 
    
         
            +
                    expect(node).to have_css('label.error[for="author_birthdate"]')
         
     | 
| 
      
 395 
     | 
    
         
            +
                    %w(1 2 3).each {|i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
       375 
396 
     | 
    
         
             
                  end
         
     | 
| 
       376 
397 
     | 
    
         
             
                end
         
     | 
| 
       377 
398 
     | 
    
         
             
                it "should display errors on datetime_select inputs" do
         
     | 
| 
       378 
399 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       379 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 400 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:birthdate => ['required']})
         
     | 
| 
       380 
401 
     | 
    
         
             
                    node = Capybara.string builder.datetime_select(:birthdate)
         
     | 
| 
       381 
     | 
    
         
            -
                    node. 
     | 
| 
       382 
     | 
    
         
            -
                    %w(1 2 3 4 5).each {|i| node. 
     | 
| 
      
 402 
     | 
    
         
            +
                    expect(node).to have_css('label.error[for="author_birthdate"]')
         
     | 
| 
      
 403 
     | 
    
         
            +
                    %w(1 2 3 4 5).each {|i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
         
     | 
| 
       383 
404 
     | 
    
         
             
                  end
         
     | 
| 
       384 
405 
     | 
    
         
             
                end
         
     | 
| 
       385 
406 
     | 
    
         
             
                it "should display errors on time_zone_select inputs"  do
         
     | 
| 
       386 
407 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       387 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 408 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:time_zone => ['required']})
         
     | 
| 
       388 
409 
     | 
    
         
             
                    node = Capybara.string builder.time_zone_select(:time_zone)
         
     | 
| 
       389 
     | 
    
         
            -
                    node. 
     | 
| 
       390 
     | 
    
         
            -
                    node. 
     | 
| 
      
 410 
     | 
    
         
            +
                    expect(node).to have_css('label.error[for="author_time_zone"]')
         
     | 
| 
      
 411 
     | 
    
         
            +
                    expect(node).to have_css('select.error[name="author[time_zone]"]')
         
     | 
| 
       391 
412 
     | 
    
         
             
                  end
         
     | 
| 
       392 
413 
     | 
    
         
             
                end
         
     | 
| 
       393 
414 
     | 
    
         | 
| 
       394 
415 
     | 
    
         
             
                it "should display errors on collection_select inputs" do
         
     | 
| 
       395 
416 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       396 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 417 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:favorite_book => ['required']})
         
     | 
| 
       397 
418 
     | 
    
         
             
                    node = Capybara.string builder.collection_select(:favorite_book, Book.all, :id, :title)
         
     | 
| 
       398 
     | 
    
         
            -
                    node. 
     | 
| 
       399 
     | 
    
         
            -
                    node. 
     | 
| 
      
 419 
     | 
    
         
            +
                    expect(node).to have_css('label.error[for="author_favorite_book"]')
         
     | 
| 
      
 420 
     | 
    
         
            +
                    expect(node).to have_css('select.error[name="author[favorite_book]"]')
         
     | 
| 
       400 
421 
     | 
    
         
             
                  end
         
     | 
| 
       401 
422 
     | 
    
         
             
                end
         
     | 
| 
       402 
423 
     | 
    
         | 
| 
       403 
424 
     | 
    
         
             
                it "should display errors on grouped_collection_select inputs" do
         
     | 
| 
       404 
425 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       405 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 426 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:favorite_book => ['required']})
         
     | 
| 
       406 
427 
     | 
    
         
             
                    node = Capybara.string builder.grouped_collection_select(:favorite_book, Genre.all, :books, :name, :id, :title)
         
     | 
| 
       407 
     | 
    
         
            -
                    node. 
     | 
| 
       408 
     | 
    
         
            -
                    node. 
     | 
| 
      
 428 
     | 
    
         
            +
                    expect(node).to have_css('label.error[for="author_favorite_book"]')
         
     | 
| 
      
 429 
     | 
    
         
            +
                    expect(node).to have_css('select.error[name="author[favorite_book]"]')
         
     | 
| 
       409 
430 
     | 
    
         
             
                  end
         
     | 
| 
       410 
431 
     | 
    
         
             
                end
         
     | 
| 
       411 
432 
     | 
    
         | 
| 
         @@ -413,16 +434,16 @@ describe "FoundationRailsHelper::FormHelper" do 
     | 
|
| 
       413 
434 
     | 
    
         | 
| 
       414 
435 
     | 
    
         
             
                it "should display HTML errors when the option is specified" do
         
     | 
| 
       415 
436 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       416 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 437 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:login => ['required <a href="link_target">link</a>']})
         
     | 
| 
       417 
438 
     | 
    
         
             
                    node = Capybara.string builder.text_field(:login, html_safe_errors: true)
         
     | 
| 
       418 
     | 
    
         
            -
                    node. 
     | 
| 
      
 439 
     | 
    
         
            +
                    expect(node).to have_link('link', href: 'link_target')
         
     | 
| 
       419 
440 
     | 
    
         
             
                  end
         
     | 
| 
       420 
441 
     | 
    
         
             
                end
         
     | 
| 
       421 
442 
     | 
    
         
             
                it "should not display HTML errors when the option is not specified" do
         
     | 
| 
       422 
443 
     | 
    
         
             
                  form_for(@author) do |builder|
         
     | 
| 
       423 
     | 
    
         
            -
                    @author. 
     | 
| 
      
 444 
     | 
    
         
            +
                    allow(@author).to receive(:errors).and_return({:login => ['required <a href="link_target">link</a>']})
         
     | 
| 
       424 
445 
     | 
    
         
             
                    node = Capybara.string builder.text_field(:login)
         
     | 
| 
       425 
     | 
    
         
            -
                    node. 
     | 
| 
      
 446 
     | 
    
         
            +
                    expect(node).to_not have_link('link', href: 'link')
         
     | 
| 
       426 
447 
     | 
    
         
             
                  end
         
     | 
| 
       427 
448 
     | 
    
         
             
                end
         
     | 
| 
       428 
449 
     | 
    
         | 
| 
         @@ -432,11 +453,147 @@ describe "FoundationRailsHelper::FormHelper" do 
     | 
|
| 
       432 
453 
     | 
    
         
             
                      builder.check_box(:active, label: true) +
         
     | 
| 
       433 
454 
     | 
    
         
             
                      builder.text_field(:description, label: 'Tell me about you')
         
     | 
| 
       434 
455 
     | 
    
         | 
| 
       435 
     | 
    
         
            -
                    node. 
     | 
| 
       436 
     | 
    
         
            -
                    node. 
     | 
| 
       437 
     | 
    
         
            -
                    node. 
     | 
| 
      
 456 
     | 
    
         
            +
                    expect(node).to_not have_css('label[for="author_login"]')
         
     | 
| 
      
 457 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_active"]', text: 'Active')
         
     | 
| 
      
 458 
     | 
    
         
            +
                    expect(node).to have_css('label[for="author_description"]', text: 'Tell me about you')
         
     | 
| 
      
 459 
     | 
    
         
            +
                  end
         
     | 
| 
      
 460 
     | 
    
         
            +
                end
         
     | 
| 
      
 461 
     | 
    
         
            +
             
     | 
| 
      
 462 
     | 
    
         
            +
                context 'when class option given' do
         
     | 
| 
      
 463 
     | 
    
         
            +
                  it "should add it to the error class" do
         
     | 
| 
      
 464 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 465 
     | 
    
         
            +
                      allow(@author).to receive(:errors).and_return({:email => ['required']})
         
     | 
| 
      
 466 
     | 
    
         
            +
                      node = Capybara.string builder.text_field(:email, class: 'righteous')
         
     | 
| 
      
 467 
     | 
    
         
            +
                      expect(node).to have_css('input.righteous.error[name="author[email]"]')
         
     | 
| 
      
 468 
     | 
    
         
            +
                    end
         
     | 
| 
      
 469 
     | 
    
         
            +
                  end
         
     | 
| 
      
 470 
     | 
    
         
            +
                end
         
     | 
| 
      
 471 
     | 
    
         
            +
             
     | 
| 
      
 472 
     | 
    
         
            +
                context 'when invalid class option given' do
         
     | 
| 
      
 473 
     | 
    
         
            +
                  it "should add it to the error class" do
         
     | 
| 
      
 474 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 475 
     | 
    
         
            +
                      allow(@author).to receive(:errors).and_return({:email => ['required']})
         
     | 
| 
      
 476 
     | 
    
         
            +
                      node = Capybara.string builder.text_field(:email, class: :illgotten)
         
     | 
| 
      
 477 
     | 
    
         
            +
                      expect(node).to have_css('input.illgotten.error[name="author[email]"]')
         
     | 
| 
      
 478 
     | 
    
         
            +
                    end
         
     | 
| 
      
 479 
     | 
    
         
            +
                  end
         
     | 
| 
      
 480 
     | 
    
         
            +
                end
         
     | 
| 
      
 481 
     | 
    
         
            +
              end
         
     | 
| 
      
 482 
     | 
    
         
            +
             
     | 
| 
      
 483 
     | 
    
         
            +
              describe 'submit button generator' do
         
     | 
| 
      
 484 
     | 
    
         
            +
                after :each do
         
     | 
| 
      
 485 
     | 
    
         
            +
                  FoundationRailsHelper.reset
         
     | 
| 
      
 486 
     | 
    
         
            +
                end
         
     | 
| 
      
 487 
     | 
    
         
            +
             
     | 
| 
      
 488 
     | 
    
         
            +
                context 'when button_class config is not set' do
         
     | 
| 
      
 489 
     | 
    
         
            +
                  it "should display form button with default class" do
         
     | 
| 
      
 490 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 491 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save')
         
     | 
| 
      
 492 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="small radius success button"]')
         
     | 
| 
      
 493 
     | 
    
         
            +
                    end
         
     | 
| 
      
 494 
     | 
    
         
            +
                  end
         
     | 
| 
      
 495 
     | 
    
         
            +
                end
         
     | 
| 
      
 496 
     | 
    
         
            +
             
     | 
| 
      
 497 
     | 
    
         
            +
                context 'when button_class config is "superduper"' do
         
     | 
| 
      
 498 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 499 
     | 
    
         
            +
                    FoundationRailsHelper.configure do |config|
         
     | 
| 
      
 500 
     | 
    
         
            +
                      config.button_class = 'superduper'
         
     | 
| 
      
 501 
     | 
    
         
            +
                    end
         
     | 
| 
      
 502 
     | 
    
         
            +
                  end
         
     | 
| 
      
 503 
     | 
    
         
            +
             
     | 
| 
      
 504 
     | 
    
         
            +
                  it "should display form button with 'superduper' class" do
         
     | 
| 
      
 505 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 506 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save')
         
     | 
| 
      
 507 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="superduper"]')
         
     | 
| 
      
 508 
     | 
    
         
            +
                    end
         
     | 
| 
      
 509 
     | 
    
         
            +
                  end
         
     | 
| 
      
 510 
     | 
    
         
            +
                end
         
     | 
| 
      
 511 
     | 
    
         
            +
             
     | 
| 
      
 512 
     | 
    
         
            +
                context 'when option value is "superduper"' do
         
     | 
| 
      
 513 
     | 
    
         
            +
                  it "should display form button with 'superduper' class" do
         
     | 
| 
      
 514 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 515 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save', class: 'superduper')
         
     | 
| 
      
 516 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="superduper"]')
         
     | 
| 
      
 517 
     | 
    
         
            +
                    end
         
     | 
| 
      
 518 
     | 
    
         
            +
                  end
         
     | 
| 
      
 519 
     | 
    
         
            +
                end
         
     | 
| 
      
 520 
     | 
    
         
            +
              end
         
     | 
| 
      
 521 
     | 
    
         
            +
             
     | 
| 
      
 522 
     | 
    
         
            +
              describe 'submit button generator' do
         
     | 
| 
      
 523 
     | 
    
         
            +
                after :each do
         
     | 
| 
      
 524 
     | 
    
         
            +
                  FoundationRailsHelper.reset
         
     | 
| 
      
 525 
     | 
    
         
            +
                end
         
     | 
| 
      
 526 
     | 
    
         
            +
             
     | 
| 
      
 527 
     | 
    
         
            +
                context 'when button_class config is not set' do
         
     | 
| 
      
 528 
     | 
    
         
            +
                  it "should display form button with default class" do
         
     | 
| 
      
 529 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 530 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save')
         
     | 
| 
      
 531 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="small radius success button"]')
         
     | 
| 
      
 532 
     | 
    
         
            +
                    end
         
     | 
| 
      
 533 
     | 
    
         
            +
                  end
         
     | 
| 
      
 534 
     | 
    
         
            +
                end
         
     | 
| 
      
 535 
     | 
    
         
            +
             
     | 
| 
      
 536 
     | 
    
         
            +
                context 'when button_class config is "superduper"' do
         
     | 
| 
      
 537 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 538 
     | 
    
         
            +
                    FoundationRailsHelper.configure do |config|
         
     | 
| 
      
 539 
     | 
    
         
            +
                      config.button_class = 'superduper'
         
     | 
| 
      
 540 
     | 
    
         
            +
                    end
         
     | 
| 
      
 541 
     | 
    
         
            +
                  end
         
     | 
| 
      
 542 
     | 
    
         
            +
             
     | 
| 
      
 543 
     | 
    
         
            +
                  it "should display form button with 'superduper' class" do
         
     | 
| 
      
 544 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 545 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save')
         
     | 
| 
      
 546 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="superduper"]')
         
     | 
| 
      
 547 
     | 
    
         
            +
                    end
         
     | 
| 
      
 548 
     | 
    
         
            +
                  end
         
     | 
| 
      
 549 
     | 
    
         
            +
                end
         
     | 
| 
      
 550 
     | 
    
         
            +
             
     | 
| 
      
 551 
     | 
    
         
            +
                context 'when option value is "superduper"' do
         
     | 
| 
      
 552 
     | 
    
         
            +
                  it "should display form button with 'superduper' class" do
         
     | 
| 
      
 553 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 554 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save', class: 'superduper')
         
     | 
| 
      
 555 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="superduper"]')
         
     | 
| 
      
 556 
     | 
    
         
            +
                    end
         
     | 
| 
      
 557 
     | 
    
         
            +
                  end
         
     | 
| 
      
 558 
     | 
    
         
            +
                end
         
     | 
| 
      
 559 
     | 
    
         
            +
              end
         
     | 
| 
      
 560 
     | 
    
         
            +
             
     | 
| 
      
 561 
     | 
    
         
            +
              describe 'submit button generator' do
         
     | 
| 
      
 562 
     | 
    
         
            +
                after :each do
         
     | 
| 
      
 563 
     | 
    
         
            +
                  FoundationRailsHelper.reset
         
     | 
| 
      
 564 
     | 
    
         
            +
                end
         
     | 
| 
      
 565 
     | 
    
         
            +
             
     | 
| 
      
 566 
     | 
    
         
            +
                context 'when button_class config is not set' do
         
     | 
| 
      
 567 
     | 
    
         
            +
                  it "should display form button with default class" do
         
     | 
| 
      
 568 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 569 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save')
         
     | 
| 
      
 570 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="small radius success button"]')
         
     | 
| 
      
 571 
     | 
    
         
            +
                    end
         
     | 
| 
       438 
572 
     | 
    
         
             
                  end
         
     | 
| 
       439 
573 
     | 
    
         
             
                end
         
     | 
| 
       440 
574 
     | 
    
         | 
| 
      
 575 
     | 
    
         
            +
                context 'when button_class config is "superduper"' do
         
     | 
| 
      
 576 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 577 
     | 
    
         
            +
                    FoundationRailsHelper.configure do |config|
         
     | 
| 
      
 578 
     | 
    
         
            +
                      config.button_class = 'superduper'
         
     | 
| 
      
 579 
     | 
    
         
            +
                    end
         
     | 
| 
      
 580 
     | 
    
         
            +
                  end
         
     | 
| 
      
 581 
     | 
    
         
            +
             
     | 
| 
      
 582 
     | 
    
         
            +
                  it "should display form button with 'superduper' class" do
         
     | 
| 
      
 583 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 584 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save')
         
     | 
| 
      
 585 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="superduper"]')
         
     | 
| 
      
 586 
     | 
    
         
            +
                    end
         
     | 
| 
      
 587 
     | 
    
         
            +
                  end
         
     | 
| 
      
 588 
     | 
    
         
            +
                end
         
     | 
| 
      
 589 
     | 
    
         
            +
             
     | 
| 
      
 590 
     | 
    
         
            +
                context 'when option value is "superduper"' do
         
     | 
| 
      
 591 
     | 
    
         
            +
                  it "should display form button with 'superduper' class" do
         
     | 
| 
      
 592 
     | 
    
         
            +
                    form_for(@author) do |builder|
         
     | 
| 
      
 593 
     | 
    
         
            +
                      node = Capybara.string builder.submit('Save', class: 'superduper')
         
     | 
| 
      
 594 
     | 
    
         
            +
                      expect(node).to have_css('input[type="submit"][class="superduper"]')
         
     | 
| 
      
 595 
     | 
    
         
            +
                    end
         
     | 
| 
      
 596 
     | 
    
         
            +
                  end
         
     | 
| 
      
 597 
     | 
    
         
            +
                end
         
     | 
| 
       441 
598 
     | 
    
         
             
              end
         
     | 
| 
       442 
599 
     | 
    
         
             
            end
         
     |