arbre 1.0.0.rc4 → 1.2.1
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 +7 -0
 - data/.gitignore +6 -3
 - data/.rubocop.yml +15 -0
 - data/.travis.yml +16 -0
 - data/CHANGELOG.md +86 -3
 - data/Gemfile +17 -5
 - data/Gemfile.lock +224 -0
 - data/LICENSE +20 -0
 - data/README.md +43 -0
 - data/Rakefile +19 -0
 - data/arbre.gemspec +3 -0
 - data/docs/Gemfile +2 -0
 - data/docs/_config.yml +7 -0
 - data/docs/_includes/footer.html +8 -0
 - data/docs/_includes/google-analytics.html +16 -0
 - data/docs/_includes/head.html +7 -0
 - data/docs/_includes/toc.html +12 -0
 - data/docs/_includes/top-menu.html +8 -0
 - data/docs/_layouts/default.html +21 -0
 - data/docs/index.md +106 -0
 - data/docs/stylesheets/main.css +1152 -0
 - data/lib/arbre/context.rb +34 -3
 - data/lib/arbre/element/builder_methods.rb +4 -5
 - data/lib/arbre/element/proxy.rb +28 -0
 - data/lib/arbre/element.rb +12 -6
 - data/lib/arbre/element_collection.rb +1 -1
 - data/lib/arbre/html/attributes.rb +11 -2
 - data/lib/arbre/html/class_list.rb +4 -0
 - data/lib/arbre/html/document.rb +1 -1
 - data/lib/arbre/html/html5_elements.rb +4 -4
 - data/lib/arbre/html/tag.rb +24 -9
 - data/lib/arbre/html/text_node.rb +4 -0
 - data/lib/arbre/rails/forms.rb +70 -67
 - data/lib/arbre/rails/template_handler.rb +7 -5
 - data/lib/arbre/version.rb +1 -1
 - data/spec/arbre/integration/html_spec.rb +118 -110
 - data/spec/arbre/unit/component_spec.rb +9 -9
 - data/spec/arbre/unit/context_spec.rb +8 -8
 - data/spec/arbre/unit/element_finder_methods_spec.rb +44 -29
 - data/spec/arbre/unit/element_spec.rb +64 -45
 - data/spec/arbre/unit/html/class_list_spec.rb +16 -0
 - data/spec/arbre/unit/html/tag_attributes_spec.rb +20 -18
 - data/spec/arbre/unit/html/tag_spec.rb +51 -15
 - data/spec/changelog_spec.rb +27 -0
 - data/spec/rails/integration/forms_spec.rb +14 -30
 - data/spec/rails/integration/rendering_spec.rb +46 -20
 - data/spec/rails/rails_spec_helper.rb +8 -11
 - data/spec/rails/stub_app/log/.gitignore +1 -1
 - data/spec/rails/support/mock_person.rb +15 -0
 - data/spec/rails/templates/arbre/_partial_with_assignment.arb +1 -0
 - data/spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb +3 -0
 - data/tasks/lint.rake +69 -0
 - data/tasks/release.rake +6 -0
 - metadata +43 -47
 - data/.DS_Store +0 -0
 - data/README.rdoc +0 -69
 - data/lib/.DS_Store +0 -0
 
| 
         @@ -7,25 +7,25 @@ describe Arbre::Element do 
     | 
|
| 
       7 
7 
     | 
    
         
             
              context "when initialized" do
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                it "should have no children" do
         
     | 
| 
       10 
     | 
    
         
            -
                  element.children. 
     | 
| 
      
 10 
     | 
    
         
            +
                  expect(element.children).to be_empty
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                it "should have no parent" do
         
     | 
| 
       14 
     | 
    
         
            -
                  element.parent. 
     | 
| 
      
 14 
     | 
    
         
            +
                  expect(element.parent).to be_nil
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                it "should respond to the HTML builder methods" do
         
     | 
| 
       18 
     | 
    
         
            -
                  element. 
     | 
| 
      
 18 
     | 
    
         
            +
                  expect(element).to respond_to(:span)
         
     | 
| 
       19 
19 
     | 
    
         
             
                end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                it "should have a set of local assigns" do
         
     | 
| 
       22 
     | 
    
         
            -
                  context = Arbre::Context.new : 
     | 
| 
      
 22 
     | 
    
         
            +
                  context = Arbre::Context.new hello: "World"
         
     | 
| 
       23 
23 
     | 
    
         
             
                  element = Arbre::Element.new(context)
         
     | 
| 
       24 
     | 
    
         
            -
                  element.assigns[:hello]. 
     | 
| 
      
 24 
     | 
    
         
            +
                  expect(element.assigns[:hello]).to eq("World")
         
     | 
| 
       25 
25 
     | 
    
         
             
                end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
                it "should have an empty hash with no local assigns" do
         
     | 
| 
       28 
     | 
    
         
            -
                  element.assigns. 
     | 
| 
      
 28 
     | 
    
         
            +
                  expect(element.assigns).to eq({})
         
     | 
| 
       29 
29 
     | 
    
         
             
                end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
              end
         
     | 
| 
         @@ -43,28 +43,34 @@ describe Arbre::Element do 
     | 
|
| 
       43 
43 
     | 
    
         
             
                let(:element){ Arbre::Element.new(Arbre::Context.new(nil, helper.new)) }
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                it "should call methods on the helper object and return TextNode objects" do
         
     | 
| 
       46 
     | 
    
         
            -
                  element.helper_method. 
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(element.helper_method).to eq("helper method")
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                it "should raise a NoMethodError if not found" do
         
     | 
| 
       50 
     | 
    
         
            -
                   
     | 
| 
      
 50 
     | 
    
         
            +
                  expect {
         
     | 
| 
       51 
51 
     | 
    
         
             
                    element.a_method_that_doesnt_exist
         
     | 
| 
       52 
     | 
    
         
            -
                  }. 
     | 
| 
      
 52 
     | 
    
         
            +
                  }.to raise_error(NoMethodError)
         
     | 
| 
       53 
53 
     | 
    
         
             
                end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
              end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
              describe "passing in assigns" do
         
     | 
| 
       58 
     | 
    
         
            -
                let(:post){  
     | 
| 
       59 
     | 
    
         
            -
                let(:assigns){ {: 
     | 
| 
      
 58 
     | 
    
         
            +
                let(:post){ double }
         
     | 
| 
      
 59 
     | 
    
         
            +
                let(:assigns){ {post: post} }
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
61 
     | 
    
         
             
                it "should be accessible via a method call" do
         
     | 
| 
       62 
62 
     | 
    
         
             
                  element = Arbre::Element.new(Arbre::Context.new(assigns))
         
     | 
| 
       63 
     | 
    
         
            -
                  element.post. 
     | 
| 
      
 63 
     | 
    
         
            +
                  expect(element.post).to eq(post)
         
     | 
| 
       64 
64 
     | 
    
         
             
                end
         
     | 
| 
       65 
65 
     | 
    
         | 
| 
       66 
66 
     | 
    
         
             
              end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
      
 68 
     | 
    
         
            +
              it "to_a.flatten should not infinitely recurse" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                Timeout.timeout(1) do
         
     | 
| 
      
 70 
     | 
    
         
            +
                  element.to_a.flatten
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
       68 
74 
     | 
    
         
             
              describe "adding a child" do
         
     | 
| 
       69 
75 
     | 
    
         | 
| 
       70 
76 
     | 
    
         
             
                let(:child){ Arbre::Element.new }
         
     | 
| 
         @@ -74,11 +80,11 @@ describe Arbre::Element do 
     | 
|
| 
       74 
80 
     | 
    
         
             
                end
         
     | 
| 
       75 
81 
     | 
    
         | 
| 
       76 
82 
     | 
    
         
             
                it "should add the child to the parent" do
         
     | 
| 
       77 
     | 
    
         
            -
                  element.children.first. 
     | 
| 
      
 83 
     | 
    
         
            +
                  expect(element.children.first).to eq(child)
         
     | 
| 
       78 
84 
     | 
    
         
             
                end
         
     | 
| 
       79 
85 
     | 
    
         | 
| 
       80 
86 
     | 
    
         
             
                it "should set the parent of the child" do
         
     | 
| 
       81 
     | 
    
         
            -
                  child.parent. 
     | 
| 
      
 87 
     | 
    
         
            +
                  expect(child.parent).to eq(element)
         
     | 
| 
       82 
88 
     | 
    
         
             
                end
         
     | 
| 
       83 
89 
     | 
    
         | 
| 
       84 
90 
     | 
    
         
             
                context "when the child is nil" do
         
     | 
| 
         @@ -86,7 +92,7 @@ describe Arbre::Element do 
     | 
|
| 
       86 
92 
     | 
    
         
             
                  let(:child){ nil }
         
     | 
| 
       87 
93 
     | 
    
         | 
| 
       88 
94 
     | 
    
         
             
                  it "should not add the child" do
         
     | 
| 
       89 
     | 
    
         
            -
                    element.children. 
     | 
| 
      
 95 
     | 
    
         
            +
                    expect(element.children).to be_empty
         
     | 
| 
       90 
96 
     | 
    
         
             
                  end
         
     | 
| 
       91 
97 
     | 
    
         | 
| 
       92 
98 
     | 
    
         
             
                end
         
     | 
| 
         @@ -96,8 +102,8 @@ describe Arbre::Element do 
     | 
|
| 
       96 
102 
     | 
    
         
             
                  let(:child){ "Hello World" }
         
     | 
| 
       97 
103 
     | 
    
         | 
| 
       98 
104 
     | 
    
         
             
                  it "should add as a TextNode" do
         
     | 
| 
       99 
     | 
    
         
            -
                    element.children.first. 
     | 
| 
       100 
     | 
    
         
            -
                    element.children.first.to_s. 
     | 
| 
      
 105 
     | 
    
         
            +
                    expect(element.children.first).to be_instance_of(Arbre::HTML::TextNode)
         
     | 
| 
      
 106 
     | 
    
         
            +
                    expect(element.children.first.to_s).to eq("Hello World")
         
     | 
| 
       101 
107 
     | 
    
         
             
                  end
         
     | 
| 
       102 
108 
     | 
    
         | 
| 
       103 
109 
     | 
    
         
             
                end
         
     | 
| 
         @@ -113,17 +119,17 @@ describe Arbre::Element do 
     | 
|
| 
       113 
119 
     | 
    
         
             
                  end
         
     | 
| 
       114 
120 
     | 
    
         | 
| 
       115 
121 
     | 
    
         
             
                  it "should clear the existing children" do
         
     | 
| 
       116 
     | 
    
         
            -
                    element.children.size. 
     | 
| 
      
 122 
     | 
    
         
            +
                    expect(element.children.size).to eq(1)
         
     | 
| 
       117 
123 
     | 
    
         
             
                  end
         
     | 
| 
       118 
124 
     | 
    
         | 
| 
       119 
125 
     | 
    
         
             
                  it "should add the string as a child" do
         
     | 
| 
       120 
     | 
    
         
            -
                    element.children.first.to_s. 
     | 
| 
      
 126 
     | 
    
         
            +
                    expect(element.children.first.to_s).to eq("Goodbye")
         
     | 
| 
       121 
127 
     | 
    
         
             
                  end
         
     | 
| 
       122 
128 
     | 
    
         | 
| 
       123 
129 
     | 
    
         
             
                  it "should html escape the string" do
         
     | 
| 
       124 
130 
     | 
    
         
             
                    string = "Goodbye <br />"
         
     | 
| 
       125 
131 
     | 
    
         
             
                    element.content = string
         
     | 
| 
       126 
     | 
    
         
            -
                    element.content.to_s. 
     | 
| 
      
 132 
     | 
    
         
            +
                    expect(element.content.to_s).to eq("Goodbye <br />")
         
     | 
| 
       127 
133 
     | 
    
         
             
                  end
         
     | 
| 
       128 
134 
     | 
    
         
             
                end
         
     | 
| 
       129 
135 
     | 
    
         | 
| 
         @@ -135,11 +141,11 @@ describe Arbre::Element do 
     | 
|
| 
       135 
141 
     | 
    
         
             
                  end
         
     | 
| 
       136 
142 
     | 
    
         | 
| 
       137 
143 
     | 
    
         
             
                  it "should set the content tag" do
         
     | 
| 
       138 
     | 
    
         
            -
                    element.children.first. 
     | 
| 
      
 144 
     | 
    
         
            +
                    expect(element.children.first).to eq(content_element)
         
     | 
| 
       139 
145 
     | 
    
         
             
                  end
         
     | 
| 
       140 
146 
     | 
    
         | 
| 
       141 
147 
     | 
    
         
             
                  it "should set the tags parent" do
         
     | 
| 
       142 
     | 
    
         
            -
                    content_element.parent. 
     | 
| 
      
 148 
     | 
    
         
            +
                    expect(content_element.parent).to eq(element)
         
     | 
| 
       143 
149 
     | 
    
         
             
                  end
         
     | 
| 
       144 
150 
     | 
    
         
             
                end
         
     | 
| 
       145 
151 
     | 
    
         | 
| 
         @@ -152,11 +158,11 @@ describe Arbre::Element do 
     | 
|
| 
       152 
158 
     | 
    
         
             
                  end
         
     | 
| 
       153 
159 
     | 
    
         | 
| 
       154 
160 
     | 
    
         
             
                  it "should set the content tag" do
         
     | 
| 
       155 
     | 
    
         
            -
                    element.children.first. 
     | 
| 
      
 161 
     | 
    
         
            +
                    expect(element.children.first).to eq(first)
         
     | 
| 
       156 
162 
     | 
    
         
             
                  end
         
     | 
| 
       157 
163 
     | 
    
         | 
| 
       158 
164 
     | 
    
         
             
                  it "should set the tags parent" do
         
     | 
| 
       159 
     | 
    
         
            -
                    element.children.first.parent. 
     | 
| 
      
 165 
     | 
    
         
            +
                    expect(element.children.first.parent).to eq(element)
         
     | 
| 
       160 
166 
     | 
    
         
             
                  end
         
     | 
| 
       161 
167 
     | 
    
         
             
                end
         
     | 
| 
       162 
168 
     | 
    
         | 
| 
         @@ -164,9 +170,22 @@ describe Arbre::Element do 
     | 
|
| 
       164 
170 
     | 
    
         | 
| 
       165 
171 
     | 
    
         
             
              describe "rendering to html" do
         
     | 
| 
       166 
172 
     | 
    
         | 
| 
      
 173 
     | 
    
         
            +
                before  { @separator = $, }
         
     | 
| 
      
 174 
     | 
    
         
            +
                after   { $, = @separator }
         
     | 
| 
      
 175 
     | 
    
         
            +
                let(:collection){ element + "hello world" }
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
       167 
177 
     | 
    
         
             
                it "should render the children collection" do
         
     | 
| 
       168 
     | 
    
         
            -
                  element.children. 
     | 
| 
       169 
     | 
    
         
            -
                  element.to_s. 
     | 
| 
      
 178 
     | 
    
         
            +
                  expect(element.children).to receive(:to_s).and_return("content")
         
     | 
| 
      
 179 
     | 
    
         
            +
                  expect(element.to_s).to eq("content")
         
     | 
| 
      
 180 
     | 
    
         
            +
                end
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                it "should render collection when is set the default separator" do
         
     | 
| 
      
 183 
     | 
    
         
            +
                  $, = "_"
         
     | 
| 
      
 184 
     | 
    
         
            +
                  expect(collection.to_s).to eq("hello world")
         
     | 
| 
      
 185 
     | 
    
         
            +
                end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                it "should render collection when is not set the default separator" do
         
     | 
| 
      
 188 
     | 
    
         
            +
                  expect(collection.to_s).to eq("hello world")
         
     | 
| 
       170 
189 
     | 
    
         
             
                end
         
     | 
| 
       171 
190 
     | 
    
         | 
| 
       172 
191 
     | 
    
         
             
              end
         
     | 
| 
         @@ -179,13 +198,13 @@ describe Arbre::Element do 
     | 
|
| 
       179 
198 
     | 
    
         
             
                  let(:collection){ first + second }
         
     | 
| 
       180 
199 
     | 
    
         | 
| 
       181 
200 
     | 
    
         
             
                  it "should return an instance of Collection" do
         
     | 
| 
       182 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 201 
     | 
    
         
            +
                    expect(collection).to be_an_instance_of(Arbre::ElementCollection)
         
     | 
| 
       183 
202 
     | 
    
         
             
                  end
         
     | 
| 
       184 
203 
     | 
    
         | 
| 
       185 
204 
     | 
    
         
             
                  it "should return the elements in the collection" do
         
     | 
| 
       186 
     | 
    
         
            -
                    collection.size. 
     | 
| 
       187 
     | 
    
         
            -
                    collection.first. 
     | 
| 
       188 
     | 
    
         
            -
                    collection[1]. 
     | 
| 
      
 205 
     | 
    
         
            +
                    expect(collection.size).to eq(2)
         
     | 
| 
      
 206 
     | 
    
         
            +
                    expect(collection.first).to eq(first)
         
     | 
| 
      
 207 
     | 
    
         
            +
                    expect(collection[1]).to eq(second)
         
     | 
| 
       189 
208 
     | 
    
         
             
                  end
         
     | 
| 
       190 
209 
     | 
    
         
             
                end
         
     | 
| 
       191 
210 
     | 
    
         | 
| 
         @@ -196,14 +215,14 @@ describe Arbre::Element do 
     | 
|
| 
       196 
215 
     | 
    
         
             
                  let(:collection){ Arbre::ElementCollection.new([first, second]) + third}
         
     | 
| 
       197 
216 
     | 
    
         | 
| 
       198 
217 
     | 
    
         
             
                  it "should return an instance of Collection" do
         
     | 
| 
       199 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 218 
     | 
    
         
            +
                    expect(collection).to be_an_instance_of(Arbre::ElementCollection)
         
     | 
| 
       200 
219 
     | 
    
         
             
                  end
         
     | 
| 
       201 
220 
     | 
    
         | 
| 
       202 
221 
     | 
    
         
             
                  it "should return the elements in the collection flattened" do
         
     | 
| 
       203 
     | 
    
         
            -
                    collection.size. 
     | 
| 
       204 
     | 
    
         
            -
                    collection[0]. 
     | 
| 
       205 
     | 
    
         
            -
                    collection[1]. 
     | 
| 
       206 
     | 
    
         
            -
                    collection[2]. 
     | 
| 
      
 222 
     | 
    
         
            +
                    expect(collection.size).to eq(3)
         
     | 
| 
      
 223 
     | 
    
         
            +
                    expect(collection[0]).to eq(first)
         
     | 
| 
      
 224 
     | 
    
         
            +
                    expect(collection[1]).to eq(second)
         
     | 
| 
      
 225 
     | 
    
         
            +
                    expect(collection[2]).to eq(third)
         
     | 
| 
       207 
226 
     | 
    
         
             
                  end
         
     | 
| 
       208 
227 
     | 
    
         
             
                end
         
     | 
| 
       209 
228 
     | 
    
         | 
| 
         @@ -214,14 +233,14 @@ describe Arbre::Element do 
     | 
|
| 
       214 
233 
     | 
    
         
             
                  let(:collection){ first + Arbre::ElementCollection.new([second,third]) }
         
     | 
| 
       215 
234 
     | 
    
         | 
| 
       216 
235 
     | 
    
         
             
                  it "should return an instance of Collection" do
         
     | 
| 
       217 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 236 
     | 
    
         
            +
                    expect(collection).to be_an_instance_of(Arbre::ElementCollection)
         
     | 
| 
       218 
237 
     | 
    
         
             
                  end
         
     | 
| 
       219 
238 
     | 
    
         | 
| 
       220 
239 
     | 
    
         
             
                  it "should return the elements in the collection flattened" do
         
     | 
| 
       221 
     | 
    
         
            -
                    collection.size. 
     | 
| 
       222 
     | 
    
         
            -
                    collection[0]. 
     | 
| 
       223 
     | 
    
         
            -
                    collection[1]. 
     | 
| 
       224 
     | 
    
         
            -
                    collection[2]. 
     | 
| 
      
 240 
     | 
    
         
            +
                    expect(collection.size).to eq(3)
         
     | 
| 
      
 241 
     | 
    
         
            +
                    expect(collection[0]).to eq(first)
         
     | 
| 
      
 242 
     | 
    
         
            +
                    expect(collection[1]).to eq(second)
         
     | 
| 
      
 243 
     | 
    
         
            +
                    expect(collection[2]).to eq(third)
         
     | 
| 
       225 
244 
     | 
    
         
             
                  end
         
     | 
| 
       226 
245 
     | 
    
         
             
                end
         
     | 
| 
       227 
246 
     | 
    
         | 
| 
         @@ -230,13 +249,13 @@ describe Arbre::Element do 
     | 
|
| 
       230 
249 
     | 
    
         
             
                  let(:collection){ element + "Hello World"}
         
     | 
| 
       231 
250 
     | 
    
         | 
| 
       232 
251 
     | 
    
         
             
                  it "should return an instance of Collection" do
         
     | 
| 
       233 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 252 
     | 
    
         
            +
                    expect(collection).to be_an_instance_of(Arbre::ElementCollection)
         
     | 
| 
       234 
253 
     | 
    
         
             
                  end
         
     | 
| 
       235 
254 
     | 
    
         | 
| 
       236 
255 
     | 
    
         
             
                  it "should return the elements in the collection" do
         
     | 
| 
       237 
     | 
    
         
            -
                    collection.size. 
     | 
| 
       238 
     | 
    
         
            -
                    collection[0]. 
     | 
| 
       239 
     | 
    
         
            -
                    collection[1]. 
     | 
| 
      
 256 
     | 
    
         
            +
                    expect(collection.size).to eq(2)
         
     | 
| 
      
 257 
     | 
    
         
            +
                    expect(collection[0]).to eq(element)
         
     | 
| 
      
 258 
     | 
    
         
            +
                    expect(collection[1]).to be_an_instance_of(Arbre::HTML::TextNode)
         
     | 
| 
       240 
259 
     | 
    
         
             
                  end
         
     | 
| 
       241 
260 
     | 
    
         
             
                end
         
     | 
| 
       242 
261 
     | 
    
         | 
| 
         @@ -244,7 +263,7 @@ describe Arbre::Element do 
     | 
|
| 
       244 
263 
     | 
    
         
             
                  let(:collection){ "hello World" + Arbre::Element.new}
         
     | 
| 
       245 
264 
     | 
    
         | 
| 
       246 
265 
     | 
    
         
             
                  it "should return a string" do
         
     | 
| 
       247 
     | 
    
         
            -
                    collection.strip.chomp. 
     | 
| 
      
 266 
     | 
    
         
            +
                    expect(collection.strip.chomp).to eq("hello World")
         
     | 
| 
       248 
267 
     | 
    
         
             
                  end
         
     | 
| 
       249 
268 
     | 
    
         
             
                end
         
     | 
| 
       250 
269 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Arbre::HTML::ClassList do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              describe ".build_from_string" do
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                it "should build a new list from a string of classes" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  list = Arbre::HTML::ClassList.build_from_string("first second")
         
     | 
| 
      
 9 
     | 
    
         
            +
                  expect(list.size).to eq(2)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  expect(list).to match_array(%w{first second})
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -6,55 +6,57 @@ describe Arbre::HTML::Tag, "Attributes" do 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              describe "attributes" do
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                before { tag.build : 
     | 
| 
      
 9 
     | 
    
         
            +
                before { tag.build id: "my_id" }
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                it "should have an attributes hash" do
         
     | 
| 
       12 
     | 
    
         
            -
                  tag.attributes. 
     | 
| 
      
 12 
     | 
    
         
            +
                  expect(tag.attributes).to eq({id: "my_id"})
         
     | 
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                it "should render the attributes to html" do
         
     | 
| 
       16 
     | 
    
         
            -
                  tag.to_s. 
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(tag.to_s).to eq "<tag id=\"my_id\"></tag>\n"
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                it "shouldn't render attributes that are empty" do
         
     | 
| 
      
 20 
     | 
    
         
            +
                  tag.class_list # initializes an empty ClassList
         
     | 
| 
      
 21 
     | 
    
         
            +
                  tag.set_attribute :foo, ''
         
     | 
| 
      
 22 
     | 
    
         
            +
                  tag.set_attribute :bar, nil
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  expect(tag.to_s).to eq "<tag id=\"my_id\"></tag>\n"
         
     | 
| 
       19 
25 
     | 
    
         
             
                end
         
     | 
| 
       20 
26 
     | 
    
         | 
| 
       21 
27 
     | 
    
         
             
                it "should get an attribute value" do
         
     | 
| 
       22 
     | 
    
         
            -
                  tag.attr(:id). 
     | 
| 
      
 28 
     | 
    
         
            +
                  expect(tag.attr(:id)).to eq("my_id")
         
     | 
| 
       23 
29 
     | 
    
         
             
                end
         
     | 
| 
       24 
30 
     | 
    
         | 
| 
       25 
31 
     | 
    
         
             
                describe "#has_attribute?" do
         
     | 
| 
       26 
32 
     | 
    
         
             
                  context "when the attribute exists" do
         
     | 
| 
       27 
33 
     | 
    
         
             
                    it "should return true" do
         
     | 
| 
       28 
     | 
    
         
            -
                      tag.has_attribute?(:id). 
     | 
| 
      
 34 
     | 
    
         
            +
                      expect(tag.has_attribute?(:id)).to eq(true)
         
     | 
| 
       29 
35 
     | 
    
         
             
                    end
         
     | 
| 
       30 
36 
     | 
    
         
             
                  end
         
     | 
| 
       31 
37 
     | 
    
         | 
| 
       32 
38 
     | 
    
         
             
                  context "when the attribute does not exist" do
         
     | 
| 
       33 
39 
     | 
    
         
             
                    it "should return false" do
         
     | 
| 
       34 
     | 
    
         
            -
                      tag.has_attribute?(:class). 
     | 
| 
      
 40 
     | 
    
         
            +
                      expect(tag.has_attribute?(:class)).to eq(false)
         
     | 
| 
       35 
41 
     | 
    
         
             
                    end
         
     | 
| 
       36 
42 
     | 
    
         
             
                  end
         
     | 
| 
       37 
43 
     | 
    
         
             
                end
         
     | 
| 
       38 
44 
     | 
    
         | 
| 
       39 
45 
     | 
    
         
             
                it "should remove an attribute" do
         
     | 
| 
       40 
     | 
    
         
            -
                  tag.attributes. 
     | 
| 
       41 
     | 
    
         
            -
                  tag.remove_attribute(:id). 
     | 
| 
       42 
     | 
    
         
            -
                  tag.attributes. 
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(tag.attributes).to eq({id: "my_id"})
         
     | 
| 
      
 47 
     | 
    
         
            +
                  expect(tag.remove_attribute(:id)).to eq("my_id")
         
     | 
| 
      
 48 
     | 
    
         
            +
                  expect(tag.attributes).to eq({})
         
     | 
| 
       43 
49 
     | 
    
         
             
                end
         
     | 
| 
       44 
50 
     | 
    
         
             
              end
         
     | 
| 
       45 
51 
     | 
    
         | 
| 
       46 
52 
     | 
    
         
             
              describe "rendering attributes" do
         
     | 
| 
       47 
53 
     | 
    
         
             
                it "should html safe the attribute values" do
         
     | 
| 
       48 
     | 
    
         
            -
                  tag.set_attribute(:class, " 
     | 
| 
       49 
     | 
    
         
            -
                  tag.to_s. 
     | 
| 
       50 
     | 
    
         
            -
            <tag class="">bad things!"></tag>
         
     | 
| 
       51 
     | 
    
         
            -
            HTML
         
     | 
| 
      
 54 
     | 
    
         
            +
                  tag.set_attribute(:class, '">bad things!')
         
     | 
| 
      
 55 
     | 
    
         
            +
                  expect(tag.to_s).to eq "<tag class=\"">bad things!\"></tag>\n"
         
     | 
| 
       52 
56 
     | 
    
         
             
                end
         
     | 
| 
       53 
57 
     | 
    
         
             
                it "should should escape the attribute names" do
         
     | 
| 
       54 
58 
     | 
    
         
             
                  tag.set_attribute(">bad", "things")
         
     | 
| 
       55 
     | 
    
         
            -
                  tag.to_s. 
     | 
| 
       56 
     | 
    
         
            -
            <tag >bad="things"></tag>
         
     | 
| 
       57 
     | 
    
         
            -
            HTML
         
     | 
| 
      
 59 
     | 
    
         
            +
                  expect(tag.to_s).to eq "<tag >bad=\"things\"></tag>\n"
         
     | 
| 
       58 
60 
     | 
    
         
             
                end
         
     | 
| 
       59 
61 
     | 
    
         
             
              end
         
     | 
| 
       60 
62 
     | 
    
         
             
            end
         
     | 
| 
         @@ -5,31 +5,48 @@ describe Arbre::HTML::Tag do 
     | 
|
| 
       5 
5 
     | 
    
         
             
              let(:tag){ Arbre::HTML::Tag.new }
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              describe "building a new tag" do
         
     | 
| 
       8 
     | 
    
         
            -
                before { tag.build "Hello World", : 
     | 
| 
      
 8 
     | 
    
         
            +
                before { tag.build "Hello World", id: "my_id" }
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                it "should set the contents to a string" do
         
     | 
| 
       11 
     | 
    
         
            -
                  tag.content. 
     | 
| 
      
 11 
     | 
    
         
            +
                  expect(tag.content).to eq("Hello World")
         
     | 
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                it "should set the hash of options to the attributes" do
         
     | 
| 
       15 
     | 
    
         
            -
                  tag.attributes. 
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(tag.attributes).to eq({ id: "my_id" })
         
     | 
| 
       16 
16 
     | 
    
         
             
                end
         
     | 
| 
       17 
17 
     | 
    
         
             
              end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              describe "creating a tag 'for' an object" do
         
     | 
| 
       20 
     | 
    
         
            -
                let(:model_name){  
     | 
| 
       21 
     | 
    
         
            -
                let(:resource_class){  
     | 
| 
       22 
     | 
    
         
            -
                let(:resource){  
     | 
| 
      
 20 
     | 
    
         
            +
                let(:model_name){ double(singular: "resource_class")}
         
     | 
| 
      
 21 
     | 
    
         
            +
                let(:resource_class){ double(model_name: model_name) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                let(:resource){ double(class: resource_class, to_key: ['5'])}
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                before do
         
     | 
| 
       25 
     | 
    
         
            -
                  tag.build : 
     | 
| 
      
 25 
     | 
    
         
            +
                  tag.build for: resource
         
     | 
| 
       26 
26 
     | 
    
         
             
                end
         
     | 
| 
       27 
27 
     | 
    
         
             
                it "should set the id to the type and id" do
         
     | 
| 
       28 
     | 
    
         
            -
                  tag.id. 
     | 
| 
      
 28 
     | 
    
         
            +
                  expect(tag.id).to eq("resource_class_5")
         
     | 
| 
       29 
29 
     | 
    
         
             
                end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                it "should add a class name" do
         
     | 
| 
       32 
     | 
    
         
            -
                  tag.class_list. 
     | 
| 
      
 32 
     | 
    
         
            +
                  expect(tag.class_list).to include("resource_class")
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                describe "for an object that doesn't have a model_name" do
         
     | 
| 
      
 37 
     | 
    
         
            +
                  let(:resource_class){ double(name: 'ResourceClass') }
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 40 
     | 
    
         
            +
                    tag.build for: resource
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  it "should set the id to the type and id" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                    expect(tag.id).to eq("resource_class_5")
         
     | 
| 
      
 45 
     | 
    
         
            +
                  end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                  it "should add a class name" do
         
     | 
| 
      
 48 
     | 
    
         
            +
                    expect(tag.class_list).to include("resource_class")
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
       33 
50 
     | 
    
         
             
                end
         
     | 
| 
       34 
51 
     | 
    
         | 
| 
       35 
52 
     | 
    
         
             
                describe "with a default_id_for_prefix" do
         
     | 
| 
         @@ -43,35 +60,54 @@ describe Arbre::HTML::Tag do 
     | 
|
| 
       43 
60 
     | 
    
         
             
                  end
         
     | 
| 
       44 
61 
     | 
    
         | 
| 
       45 
62 
     | 
    
         
             
                  it "should set the id to the type and id" do
         
     | 
| 
       46 
     | 
    
         
            -
                    tag.id. 
     | 
| 
      
 63 
     | 
    
         
            +
                    expect(tag.id).to eq("a_prefix_resource_class_5")
         
     | 
| 
       47 
64 
     | 
    
         
             
                  end
         
     | 
| 
       48 
65 
     | 
    
         | 
| 
       49 
66 
     | 
    
         
             
                end
         
     | 
| 
       50 
67 
     | 
    
         
             
              end
         
     | 
| 
       51 
68 
     | 
    
         | 
| 
      
 69 
     | 
    
         
            +
              describe "creating a tag with a for attribute" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                it "sets the `for` attribute when a string is given" do
         
     | 
| 
      
 71 
     | 
    
         
            +
                  tag.build for: "email"
         
     | 
| 
      
 72 
     | 
    
         
            +
                  expect(tag.attributes[:for]).to eq "email"
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                it "sets the `for` attribute when a symbol is given" do
         
     | 
| 
      
 76 
     | 
    
         
            +
                  tag.build for: :email
         
     | 
| 
      
 77 
     | 
    
         
            +
                  expect(tag.attributes[:for]).to eq :email
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
       52 
81 
     | 
    
         
             
              describe "css class names" do
         
     | 
| 
       53 
82 
     | 
    
         | 
| 
       54 
83 
     | 
    
         
             
                it "should add a class" do
         
     | 
| 
       55 
84 
     | 
    
         
             
                  tag.add_class "hello_world"
         
     | 
| 
       56 
     | 
    
         
            -
                  tag.class_names. 
     | 
| 
      
 85 
     | 
    
         
            +
                  expect(tag.class_names).to eq("hello_world")
         
     | 
| 
       57 
86 
     | 
    
         
             
                end
         
     | 
| 
       58 
87 
     | 
    
         | 
| 
       59 
88 
     | 
    
         
             
                it "should remove_class" do
         
     | 
| 
       60 
89 
     | 
    
         
             
                  tag.add_class "hello_world"
         
     | 
| 
       61 
     | 
    
         
            -
                  tag.class_names. 
     | 
| 
      
 90 
     | 
    
         
            +
                  expect(tag.class_names).to eq("hello_world")
         
     | 
| 
       62 
91 
     | 
    
         
             
                  tag.remove_class "hello_world"
         
     | 
| 
       63 
     | 
    
         
            -
                  tag.class_names. 
     | 
| 
      
 92 
     | 
    
         
            +
                  expect(tag.class_names).to eq("")
         
     | 
| 
       64 
93 
     | 
    
         
             
                end
         
     | 
| 
       65 
94 
     | 
    
         | 
| 
       66 
95 
     | 
    
         
             
                it "should not add a class if it already exists" do
         
     | 
| 
       67 
96 
     | 
    
         
             
                  tag.add_class "hello_world"
         
     | 
| 
       68 
97 
     | 
    
         
             
                  tag.add_class "hello_world"
         
     | 
| 
       69 
     | 
    
         
            -
                  tag.class_names. 
     | 
| 
      
 98 
     | 
    
         
            +
                  expect(tag.class_names).to eq("hello_world")
         
     | 
| 
       70 
99 
     | 
    
         
             
                end
         
     | 
| 
       71 
100 
     | 
    
         | 
| 
       72 
101 
     | 
    
         
             
                it "should seperate classes with space" do
         
     | 
| 
       73 
102 
     | 
    
         
             
                  tag.add_class "hello world"
         
     | 
| 
       74 
     | 
    
         
            -
                  tag.class_list.size. 
     | 
| 
      
 103 
     | 
    
         
            +
                  expect(tag.class_list.size).to eq(2)
         
     | 
| 
      
 104 
     | 
    
         
            +
                end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                it "should create a class list from a string" do
         
     | 
| 
      
 107 
     | 
    
         
            +
                  tag = Arbre::HTML::Tag.new
         
     | 
| 
      
 108 
     | 
    
         
            +
                  tag.build(class: "first-class")
         
     | 
| 
      
 109 
     | 
    
         
            +
                  tag.add_class "second-class"
         
     | 
| 
      
 110 
     | 
    
         
            +
                  expect(tag.class_list.size).to eq(2)
         
     | 
| 
       75 
111 
     | 
    
         
             
                end
         
     | 
| 
       76 
112 
     | 
    
         | 
| 
       77 
113 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Changelog" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:changelog) do
         
     | 
| 
      
 5 
     | 
    
         
            +
                path = File.join(File.dirname(__dir__), "CHANGELOG.md")
         
     | 
| 
      
 6 
     | 
    
         
            +
                File.read(path)
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              it 'has definitions for all implicit links' do
         
     | 
| 
      
 10 
     | 
    
         
            +
                implicit_link_names = changelog.scan(/\[([^\]]+)\]\[\]/).flatten.uniq
         
     | 
| 
      
 11 
     | 
    
         
            +
                implicit_link_names.each do |name|
         
     | 
| 
      
 12 
     | 
    
         
            +
                  expect(changelog).to include("[#{name}]: https")
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              describe 'entry' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                let(:lines) { changelog.each_line }
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                subject(:entries) { lines.grep(/^\*/) }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                it 'does not end with a punctuation' do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  entries.each do |entry|
         
     | 
| 
      
 23 
     | 
    
         
            +
                    expect(entry).not_to match(/\.$/)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,20 +1,4 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'rails/rails_spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'active_model'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            class MockPerson
         
     | 
| 
       6 
     | 
    
         
            -
              extend ActiveModel::Naming
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              attr_accessor :name
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              def persisted?
         
     | 
| 
       11 
     | 
    
         
            -
                false
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              def to_key
         
     | 
| 
       15 
     | 
    
         
            -
                []
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
| 
       18 
2 
     | 
    
         | 
| 
       19 
3 
     | 
    
         
             
            describe "Building forms" do
         
     | 
| 
       20 
4 
     | 
    
         | 
| 
         @@ -26,7 +10,7 @@ describe "Building forms" do 
     | 
|
| 
       26 
10 
     | 
    
         | 
| 
       27 
11 
     | 
    
         
             
                let(:form) do
         
     | 
| 
       28 
12 
     | 
    
         
             
                  arbre do
         
     | 
| 
       29 
     | 
    
         
            -
                    form_for MockPerson.new, : 
     | 
| 
      
 13 
     | 
    
         
            +
                    form_for MockPerson.new, url: "/" do |f|
         
     | 
| 
       30 
14 
     | 
    
         
             
                      f.label :name
         
     | 
| 
       31 
15 
     | 
    
         
             
                      f.text_field :name
         
     | 
| 
       32 
16 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -34,19 +18,19 @@ describe "Building forms" do 
     | 
|
| 
       34 
18 
     | 
    
         
             
                end
         
     | 
| 
       35 
19 
     | 
    
         | 
| 
       36 
20 
     | 
    
         
             
                it "should build a form" do
         
     | 
| 
       37 
     | 
    
         
            -
                  html. 
     | 
| 
      
 21 
     | 
    
         
            +
                  expect(html).to have_selector("form")
         
     | 
| 
       38 
22 
     | 
    
         
             
                end
         
     | 
| 
       39 
23 
     | 
    
         | 
| 
       40 
24 
     | 
    
         
             
                it "should include the hidden authenticity token" do
         
     | 
| 
       41 
     | 
    
         
            -
                  html. 
     | 
| 
      
 25 
     | 
    
         
            +
                  expect(html).to include '<input type="hidden" name="authenticity_token" value="AUTH_TOKEN" />'
         
     | 
| 
       42 
26 
     | 
    
         
             
                end
         
     | 
| 
       43 
27 
     | 
    
         | 
| 
       44 
28 
     | 
    
         
             
                it "should create a label" do
         
     | 
| 
       45 
     | 
    
         
            -
                  html. 
     | 
| 
      
 29 
     | 
    
         
            +
                  expect(html).to have_selector("form label[for=mock_person_name]")
         
     | 
| 
       46 
30 
     | 
    
         
             
                end
         
     | 
| 
       47 
31 
     | 
    
         | 
| 
       48 
32 
     | 
    
         
             
                it "should create a text field" do
         
     | 
| 
       49 
     | 
    
         
            -
                  html. 
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(html).to have_selector("form input[type=text]")
         
     | 
| 
       50 
34 
     | 
    
         
             
                end
         
     | 
| 
       51 
35 
     | 
    
         | 
| 
       52 
36 
     | 
    
         
             
              end
         
     | 
| 
         @@ -55,7 +39,7 @@ describe "Building forms" do 
     | 
|
| 
       55 
39 
     | 
    
         | 
| 
       56 
40 
     | 
    
         
             
                let(:form) do
         
     | 
| 
       57 
41 
     | 
    
         
             
                  arbre do
         
     | 
| 
       58 
     | 
    
         
            -
                    form_for MockPerson.new, : 
     | 
| 
      
 42 
     | 
    
         
            +
                    form_for MockPerson.new, url: "/" do |f|
         
     | 
| 
       59 
43 
     | 
    
         
             
                      f.label :name
         
     | 
| 
       60 
44 
     | 
    
         
             
                      f.text_field :name
         
     | 
| 
       61 
45 
     | 
    
         
             
                      f.fields_for :permission do |pf|
         
     | 
| 
         @@ -67,15 +51,15 @@ describe "Building forms" do 
     | 
|
| 
       67 
51 
     | 
    
         
             
                end
         
     | 
| 
       68 
52 
     | 
    
         | 
| 
       69 
53 
     | 
    
         
             
                it "should render nested label" do
         
     | 
| 
       70 
     | 
    
         
            -
                  html. 
     | 
| 
      
 54 
     | 
    
         
            +
                  expect(html).to have_selector("form label[for=mock_person_permission_admin]", text: "Admin")
         
     | 
| 
       71 
55 
     | 
    
         
             
                end
         
     | 
| 
       72 
56 
     | 
    
         | 
| 
       73 
57 
     | 
    
         
             
                it "should render nested label" do
         
     | 
| 
       74 
     | 
    
         
            -
                  html. 
     | 
| 
      
 58 
     | 
    
         
            +
                  expect(html).to have_selector("form input[type=checkbox][name='mock_person[permission][admin]']")
         
     | 
| 
       75 
59 
     | 
    
         
             
                end
         
     | 
| 
       76 
60 
     | 
    
         | 
| 
       77 
61 
     | 
    
         
             
                it "should not render a div for the proxy" do
         
     | 
| 
       78 
     | 
    
         
            -
                  html. 
     | 
| 
      
 62 
     | 
    
         
            +
                  expect(html).not_to have_selector("form div.fields_for_proxy")
         
     | 
| 
       79 
63 
     | 
    
         
             
                end
         
     | 
| 
       80 
64 
     | 
    
         | 
| 
       81 
65 
     | 
    
         
             
              end
         
     | 
| 
         @@ -83,7 +67,7 @@ describe "Building forms" do 
     | 
|
| 
       83 
67 
     | 
    
         
             
              describe "forms with other elements" do
         
     | 
| 
       84 
68 
     | 
    
         
             
                let(:form) do
         
     | 
| 
       85 
69 
     | 
    
         
             
                  arbre do
         
     | 
| 
       86 
     | 
    
         
            -
                    form_for MockPerson.new, : 
     | 
| 
      
 70 
     | 
    
         
            +
                    form_for MockPerson.new, url: "/" do |f|
         
     | 
| 
       87 
71 
     | 
    
         | 
| 
       88 
72 
     | 
    
         
             
                      div do
         
     | 
| 
       89 
73 
     | 
    
         
             
                        f.label :name
         
     | 
| 
         @@ -95,9 +79,9 @@ describe "Building forms" do 
     | 
|
| 
       95 
79 
     | 
    
         
             
                        f.text_field :name
         
     | 
| 
       96 
80 
     | 
    
         
             
                      end
         
     | 
| 
       97 
81 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
                      div : 
     | 
| 
      
 82 
     | 
    
         
            +
                      div class: "permissions" do
         
     | 
| 
       99 
83 
     | 
    
         
             
                        f.fields_for :permission do |pf|
         
     | 
| 
       100 
     | 
    
         
            -
                          div : 
     | 
| 
      
 84 
     | 
    
         
            +
                          div class: "permissions_label" do
         
     | 
| 
       101 
85 
     | 
    
         
             
                            pf.label :admin
         
     | 
| 
       102 
86 
     | 
    
         
             
                          end
         
     | 
| 
       103 
87 
     | 
    
         
             
                          pf.check_box :admin
         
     | 
| 
         @@ -109,11 +93,11 @@ describe "Building forms" do 
     | 
|
| 
       109 
93 
     | 
    
         
             
                end
         
     | 
| 
       110 
94 
     | 
    
         | 
| 
       111 
95 
     | 
    
         
             
                it "should correctly nest elements" do
         
     | 
| 
       112 
     | 
    
         
            -
                  html. 
     | 
| 
      
 96 
     | 
    
         
            +
                  expect(html).to have_selector("form > p > label")
         
     | 
| 
       113 
97 
     | 
    
         
             
                end
         
     | 
| 
       114 
98 
     | 
    
         | 
| 
       115 
99 
     | 
    
         
             
                it "should correnctly nest elements within fields for" do
         
     | 
| 
       116 
     | 
    
         
            -
                  html. 
     | 
| 
      
 100 
     | 
    
         
            +
                  expect(html).to have_selector("form > div.permissions > div.permissions_label label")
         
     | 
| 
       117 
101 
     | 
    
         
             
                end
         
     | 
| 
       118 
102 
     | 
    
         
             
              end
         
     | 
| 
       119 
103 
     | 
    
         |