arbre 1.2.1 → 1.3.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/CHANGELOG.md +10 -0
 - data/README.md +1 -1
 - data/lib/arbre/context.rb +2 -1
 - data/lib/arbre/element.rb +2 -1
 - data/lib/arbre/version.rb +1 -1
 - metadata +35 -46
 - data/.gitignore +0 -10
 - data/.rubocop.yml +0 -15
 - data/.travis.yml +0 -16
 - data/Gemfile +0 -25
 - data/Gemfile.lock +0 -224
 - data/Rakefile +0 -21
 - data/arbre.gemspec +0 -24
 - data/spec/arbre/integration/html_spec.rb +0 -249
 - data/spec/arbre/unit/component_spec.rb +0 -44
 - data/spec/arbre/unit/context_spec.rb +0 -35
 - data/spec/arbre/unit/element_finder_methods_spec.rb +0 -116
 - data/spec/arbre/unit/element_spec.rb +0 -271
 - data/spec/arbre/unit/html/class_list_spec.rb +0 -16
 - data/spec/arbre/unit/html/tag_attributes_spec.rb +0 -62
 - data/spec/arbre/unit/html/tag_spec.rb +0 -115
 - data/spec/arbre/unit/html/text_node_spec.rb +0 -5
 - data/spec/changelog_spec.rb +0 -27
 - data/spec/rails/integration/forms_spec.rb +0 -105
 - data/spec/rails/integration/rendering_spec.rb +0 -99
 - data/spec/rails/rails_spec_helper.rb +0 -42
 - data/spec/rails/stub_app/config/database.yml +0 -3
 - data/spec/rails/stub_app/config/routes.rb +0 -3
 - data/spec/rails/stub_app/db/schema.rb +0 -3
 - data/spec/rails/stub_app/log/.gitignore +0 -1
 - data/spec/rails/stub_app/public/favicon.ico +0 -0
 - data/spec/rails/support/mock_person.rb +0 -15
 - data/spec/rails/templates/arbre/_partial.arb +0 -1
 - data/spec/rails/templates/arbre/_partial_with_assignment.arb +0 -1
 - data/spec/rails/templates/arbre/empty.arb +0 -0
 - data/spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb +0 -3
 - data/spec/rails/templates/arbre/page_with_assignment.arb +0 -1
 - data/spec/rails/templates/arbre/page_with_erb_partial.arb +0 -3
 - data/spec/rails/templates/arbre/page_with_partial.arb +0 -3
 - data/spec/rails/templates/arbre/simple_page.arb +0 -8
 - data/spec/rails/templates/erb/_partial.erb +0 -1
 - data/spec/spec_helper.rb +0 -7
 - data/spec/support/bundle.rb +0 -4
 - data/tasks/lint.rake +0 -69
 - data/tasks/release.rake +0 -6
 
    
        data/Rakefile
    DELETED
    
    | 
         @@ -1,21 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'bundler'
         
     | 
| 
       2 
     | 
    
         
            -
            Bundler::GemHelper.install_tasks
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            require 'rspec/core/rake_task'
         
     | 
| 
       5 
     | 
    
         
            -
            RSpec::Core::RakeTask.new(:spec)
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            import 'tasks/lint.rake'
         
     | 
| 
       8 
     | 
    
         
            -
            import 'tasks/release.rake'
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            task default: [:spec, :lint]
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            task :console do
         
     | 
| 
       13 
     | 
    
         
            -
              require 'irb'
         
     | 
| 
       14 
     | 
    
         
            -
              require 'irb/completion'
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              require 'pry'
         
     | 
| 
       17 
     | 
    
         
            -
              require 'arbre'
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              ARGV.clear
         
     | 
| 
       20 
     | 
    
         
            -
              IRB.start
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     | 
    
        data/arbre.gemspec
    DELETED
    
    | 
         @@ -1,24 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- encoding: utf-8 -*-
         
     | 
| 
       2 
     | 
    
         
            -
            $:.push File.expand_path("../lib", __FILE__)
         
     | 
| 
       3 
     | 
    
         
            -
            require "arbre/version"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            Gem::Specification.new do |s|
         
     | 
| 
       6 
     | 
    
         
            -
              s.name        = "arbre"
         
     | 
| 
       7 
     | 
    
         
            -
              s.version     = Arbre::VERSION
         
     | 
| 
       8 
     | 
    
         
            -
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
       9 
     | 
    
         
            -
              s.authors     = ["Greg Bell"]
         
     | 
| 
       10 
     | 
    
         
            -
              s.email       = ["gregdbell@gmail.com"]
         
     | 
| 
       11 
     | 
    
         
            -
              s.homepage    = ""
         
     | 
| 
       12 
     | 
    
         
            -
              s.summary     = %q{An Object Oriented DOM Tree in Ruby}
         
     | 
| 
       13 
     | 
    
         
            -
              s.description = %q{An Object Oriented DOM Tree in Ruby}
         
     | 
| 
       14 
     | 
    
         
            -
              s.license     = "MIT"
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
       17 
     | 
    
         
            -
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
       18 
     | 
    
         
            -
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
       19 
     | 
    
         
            -
              s.require_paths = ["lib"]
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              s.required_ruby_version = '>= 2.3'
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
              s.add_dependency("activesupport", ">= 3.0.0")
         
     | 
| 
       24 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,249 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Arbre do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              let(:helpers){ nil }
         
     | 
| 
       6 
     | 
    
         
            -
              let(:assigns){ {} }
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it "should render a single element" do
         
     | 
| 
       9 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       10 
     | 
    
         
            -
                  span "Hello World"
         
     | 
| 
       11 
     | 
    
         
            -
                }.to_s).to eq("<span>Hello World</span>\n")
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              it "should render a child element" do
         
     | 
| 
       15 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       16 
     | 
    
         
            -
                  span do
         
     | 
| 
       17 
     | 
    
         
            -
                    span "Hello World"
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       20 
     | 
    
         
            -
                  <span>
         
     | 
| 
       21 
     | 
    
         
            -
                    <span>Hello World</span>
         
     | 
| 
       22 
     | 
    
         
            -
                  </span>
         
     | 
| 
       23 
     | 
    
         
            -
                HTML
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              it "should render an unordered list" do
         
     | 
| 
       27 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       28 
     | 
    
         
            -
                  ul do
         
     | 
| 
       29 
     | 
    
         
            -
                    li "First"
         
     | 
| 
       30 
     | 
    
         
            -
                    li "Second"
         
     | 
| 
       31 
     | 
    
         
            -
                    li "Third"
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       33 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       34 
     | 
    
         
            -
                  <ul>
         
     | 
| 
       35 
     | 
    
         
            -
                    <li>First</li>
         
     | 
| 
       36 
     | 
    
         
            -
                    <li>Second</li>
         
     | 
| 
       37 
     | 
    
         
            -
                    <li>Third</li>
         
     | 
| 
       38 
     | 
    
         
            -
                  </ul>
         
     | 
| 
       39 
     | 
    
         
            -
                HTML
         
     | 
| 
       40 
     | 
    
         
            -
              end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
              it "should allow local variables inside the tags" do
         
     | 
| 
       43 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       44 
     | 
    
         
            -
                  first = "First"
         
     | 
| 
       45 
     | 
    
         
            -
                  second = "Second"
         
     | 
| 
       46 
     | 
    
         
            -
                  ul do
         
     | 
| 
       47 
     | 
    
         
            -
                    li first
         
     | 
| 
       48 
     | 
    
         
            -
                    li second
         
     | 
| 
       49 
     | 
    
         
            -
                  end
         
     | 
| 
       50 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       51 
     | 
    
         
            -
                  <ul>
         
     | 
| 
       52 
     | 
    
         
            -
                    <li>First</li>
         
     | 
| 
       53 
     | 
    
         
            -
                    <li>Second</li>
         
     | 
| 
       54 
     | 
    
         
            -
                  </ul>
         
     | 
| 
       55 
     | 
    
         
            -
                HTML
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
              it "should add children and nested" do
         
     | 
| 
       59 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       60 
     | 
    
         
            -
                  div do
         
     | 
| 
       61 
     | 
    
         
            -
                    ul
         
     | 
| 
       62 
     | 
    
         
            -
                    li do
         
     | 
| 
       63 
     | 
    
         
            -
                      li
         
     | 
| 
       64 
     | 
    
         
            -
                    end
         
     | 
| 
       65 
     | 
    
         
            -
                  end
         
     | 
| 
       66 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       67 
     | 
    
         
            -
                  <div>
         
     | 
| 
       68 
     | 
    
         
            -
                    <ul></ul>
         
     | 
| 
       69 
     | 
    
         
            -
                    <li>
         
     | 
| 
       70 
     | 
    
         
            -
                      <li></li>
         
     | 
| 
       71 
     | 
    
         
            -
                    </li>
         
     | 
| 
       72 
     | 
    
         
            -
                  </div>
         
     | 
| 
       73 
     | 
    
         
            -
                HTML
         
     | 
| 
       74 
     | 
    
         
            -
              end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
              it "should pass the element in to the block if asked for" do
         
     | 
| 
       78 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       79 
     | 
    
         
            -
                  div do |d|
         
     | 
| 
       80 
     | 
    
         
            -
                    d.ul do
         
     | 
| 
       81 
     | 
    
         
            -
                      li
         
     | 
| 
       82 
     | 
    
         
            -
                    end
         
     | 
| 
       83 
     | 
    
         
            -
                  end
         
     | 
| 
       84 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       85 
     | 
    
         
            -
                  <div>
         
     | 
| 
       86 
     | 
    
         
            -
                    <ul>
         
     | 
| 
       87 
     | 
    
         
            -
                      <li></li>
         
     | 
| 
       88 
     | 
    
         
            -
                    </ul>
         
     | 
| 
       89 
     | 
    
         
            -
                  </div>
         
     | 
| 
       90 
     | 
    
         
            -
                HTML
         
     | 
| 
       91 
     | 
    
         
            -
              end
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
              it "should move content tags between parents" do
         
     | 
| 
       95 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       96 
     | 
    
         
            -
                  div do
         
     | 
| 
       97 
     | 
    
         
            -
                    span(ul(li))
         
     | 
| 
       98 
     | 
    
         
            -
                  end
         
     | 
| 
       99 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       100 
     | 
    
         
            -
                  <div>
         
     | 
| 
       101 
     | 
    
         
            -
                    <span>
         
     | 
| 
       102 
     | 
    
         
            -
                      <ul>
         
     | 
| 
       103 
     | 
    
         
            -
                        <li></li>
         
     | 
| 
       104 
     | 
    
         
            -
                      </ul>
         
     | 
| 
       105 
     | 
    
         
            -
                    </span>
         
     | 
| 
       106 
     | 
    
         
            -
                  </div>
         
     | 
| 
       107 
     | 
    
         
            -
                HTML
         
     | 
| 
       108 
     | 
    
         
            -
              end
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
              it "should add content to the parent if the element is passed into block" do
         
     | 
| 
       111 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       112 
     | 
    
         
            -
                  div do |d|
         
     | 
| 
       113 
     | 
    
         
            -
                    d.id = "my-tag"
         
     | 
| 
       114 
     | 
    
         
            -
                    ul do
         
     | 
| 
       115 
     | 
    
         
            -
                      li
         
     | 
| 
       116 
     | 
    
         
            -
                    end
         
     | 
| 
       117 
     | 
    
         
            -
                  end
         
     | 
| 
       118 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       119 
     | 
    
         
            -
                  <div id="my-tag">
         
     | 
| 
       120 
     | 
    
         
            -
                    <ul>
         
     | 
| 
       121 
     | 
    
         
            -
                      <li></li>
         
     | 
| 
       122 
     | 
    
         
            -
                    </ul>
         
     | 
| 
       123 
     | 
    
         
            -
                  </div>
         
     | 
| 
       124 
     | 
    
         
            -
                HTML
         
     | 
| 
       125 
     | 
    
         
            -
              end
         
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
              it "should have the parent set on it" do
         
     | 
| 
       128 
     | 
    
         
            -
                list, item = nil
         
     | 
| 
       129 
     | 
    
         
            -
                arbre {
         
     | 
| 
       130 
     | 
    
         
            -
                  list = ul do
         
     | 
| 
       131 
     | 
    
         
            -
                    li "Hello"
         
     | 
| 
       132 
     | 
    
         
            -
                    item = li "World"
         
     | 
| 
       133 
     | 
    
         
            -
                  end
         
     | 
| 
       134 
     | 
    
         
            -
                }
         
     | 
| 
       135 
     | 
    
         
            -
                expect(item.parent).to eq list
         
     | 
| 
       136 
     | 
    
         
            -
              end
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
              it "should set a string content return value with no children" do
         
     | 
| 
       139 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       140 
     | 
    
         
            -
                  li do
         
     | 
| 
       141 
     | 
    
         
            -
                    "Hello World"
         
     | 
| 
       142 
     | 
    
         
            -
                  end
         
     | 
| 
       143 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       144 
     | 
    
         
            -
                  <li>Hello World</li>
         
     | 
| 
       145 
     | 
    
         
            -
                HTML
         
     | 
| 
       146 
     | 
    
         
            -
              end
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
              it "should turn string return values into text nodes" do
         
     | 
| 
       149 
     | 
    
         
            -
                node = nil
         
     | 
| 
       150 
     | 
    
         
            -
                arbre {
         
     | 
| 
       151 
     | 
    
         
            -
                  list = li do
         
     | 
| 
       152 
     | 
    
         
            -
                    "Hello World"
         
     | 
| 
       153 
     | 
    
         
            -
                  end
         
     | 
| 
       154 
     | 
    
         
            -
                  node = list.children.first
         
     | 
| 
       155 
     | 
    
         
            -
                }
         
     | 
| 
       156 
     | 
    
         
            -
                expect(node).to be_a Arbre::HTML::TextNode
         
     | 
| 
       157 
     | 
    
         
            -
              end
         
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
              it "should not render blank arrays" do
         
     | 
| 
       160 
     | 
    
         
            -
                expect(arbre {
         
     | 
| 
       161 
     | 
    
         
            -
                  tbody do
         
     | 
| 
       162 
     | 
    
         
            -
                    []
         
     | 
| 
       163 
     | 
    
         
            -
                  end
         
     | 
| 
       164 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       165 
     | 
    
         
            -
                  <tbody></tbody>
         
     | 
| 
       166 
     | 
    
         
            -
                HTML
         
     | 
| 
       167 
     | 
    
         
            -
              end
         
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
              describe "self-closing nodes" do
         
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
                it "should not self-close script tags" do
         
     | 
| 
       172 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       173 
     | 
    
         
            -
                    script type: 'text/javascript'
         
     | 
| 
       174 
     | 
    
         
            -
                  }.to_s).to eq("<script type=\"text/javascript\"></script>\n")
         
     | 
| 
       175 
     | 
    
         
            -
                end
         
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
                it "should self-close meta tags" do
         
     | 
| 
       178 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       179 
     | 
    
         
            -
                    meta content: "text/html; charset=utf-8"
         
     | 
| 
       180 
     | 
    
         
            -
                  }.to_s).to eq("<meta content=\"text/html; charset=utf-8\"/>\n")
         
     | 
| 
       181 
     | 
    
         
            -
                end
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
                it "should self-close link tags" do
         
     | 
| 
       184 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       185 
     | 
    
         
            -
                    link rel: "stylesheet"
         
     | 
| 
       186 
     | 
    
         
            -
                  }.to_s).to eq("<link rel=\"stylesheet\"/>\n")
         
     | 
| 
       187 
     | 
    
         
            -
                end
         
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
                Arbre::HTML::Tag::SELF_CLOSING_ELEMENTS.each do |tag|
         
     | 
| 
       190 
     | 
    
         
            -
                  it "should self-close #{tag} tags" do
         
     | 
| 
       191 
     | 
    
         
            -
                    expect(arbre {
         
     | 
| 
       192 
     | 
    
         
            -
                      send(tag)
         
     | 
| 
       193 
     | 
    
         
            -
                    }.to_s).to eq("<#{tag}/>\n")
         
     | 
| 
       194 
     | 
    
         
            -
                  end
         
     | 
| 
       195 
     | 
    
         
            -
                end
         
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
       197 
     | 
    
         
            -
              end
         
     | 
| 
       198 
     | 
    
         
            -
             
     | 
| 
       199 
     | 
    
         
            -
              describe "html safe" do
         
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
                it "should escape the contents" do
         
     | 
| 
       202 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       203 
     | 
    
         
            -
                    span("<br />")
         
     | 
| 
       204 
     | 
    
         
            -
                  }.to_s).to eq <<~HTML
         
     | 
| 
       205 
     | 
    
         
            -
                    <span><br /></span>
         
     | 
| 
       206 
     | 
    
         
            -
                  HTML
         
     | 
| 
       207 
     | 
    
         
            -
                end
         
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
                it "should return html safe strings" do
         
     | 
| 
       210 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       211 
     | 
    
         
            -
                    span("<br />")
         
     | 
| 
       212 
     | 
    
         
            -
                  }.to_s).to be_html_safe
         
     | 
| 
       213 
     | 
    
         
            -
                end
         
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
                it "should not escape html passed in" do
         
     | 
| 
       216 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       217 
     | 
    
         
            -
                    span(span("<br />"))
         
     | 
| 
       218 
     | 
    
         
            -
                  }.to_s).to eq <<~HTML
         
     | 
| 
       219 
     | 
    
         
            -
                    <span>
         
     | 
| 
       220 
     | 
    
         
            -
                      <span><br /></span>
         
     | 
| 
       221 
     | 
    
         
            -
                    </span>
         
     | 
| 
       222 
     | 
    
         
            -
                  HTML
         
     | 
| 
       223 
     | 
    
         
            -
                end
         
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
                it "should escape string contents when passed in block" do
         
     | 
| 
       226 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       227 
     | 
    
         
            -
                    span {
         
     | 
| 
       228 
     | 
    
         
            -
                      span {
         
     | 
| 
       229 
     | 
    
         
            -
                        "<br />"
         
     | 
| 
       230 
     | 
    
         
            -
                      }
         
     | 
| 
       231 
     | 
    
         
            -
                    }
         
     | 
| 
       232 
     | 
    
         
            -
                  }.to_s).to eq <<~HTML
         
     | 
| 
       233 
     | 
    
         
            -
                    <span>
         
     | 
| 
       234 
     | 
    
         
            -
                      <span><br /></span>
         
     | 
| 
       235 
     | 
    
         
            -
                    </span>
         
     | 
| 
       236 
     | 
    
         
            -
                  HTML
         
     | 
| 
       237 
     | 
    
         
            -
                end
         
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
       239 
     | 
    
         
            -
                it "should escape the contents of attributes" do
         
     | 
| 
       240 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       241 
     | 
    
         
            -
                    span(class: "<br />")
         
     | 
| 
       242 
     | 
    
         
            -
                  }.to_s).to eq <<~HTML
         
     | 
| 
       243 
     | 
    
         
            -
                    <span class="<br />"></span>
         
     | 
| 
       244 
     | 
    
         
            -
                  HTML
         
     | 
| 
       245 
     | 
    
         
            -
                end
         
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
       247 
     | 
    
         
            -
              end
         
     | 
| 
       248 
     | 
    
         
            -
             
     | 
| 
       249 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,44 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # A mock subclass to play with
         
     | 
| 
       4 
     | 
    
         
            -
            class MockComponent < Arbre::Component
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              builder_method :mock_component
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              def build
         
     | 
| 
       9 
     | 
    
         
            -
                h2 "Hello World"
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            describe Arbre::Component do
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              let(:assigns) { {} }
         
     | 
| 
       17 
     | 
    
         
            -
              let(:helpers) { nil }
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              let(:component_class){ MockComponent }
         
     | 
| 
       20 
     | 
    
         
            -
              let(:component){ component_class.new }
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
              it "should be a subclass of an html div" do
         
     | 
| 
       23 
     | 
    
         
            -
                expect(Arbre::Component.ancestors).to include(Arbre::HTML::Div)
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              it "should render to a div, even as a subclass" do
         
     | 
| 
       27 
     | 
    
         
            -
                expect(component.tag_name).to eq('div')
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              it "should add a class by default" do
         
     | 
| 
       31 
     | 
    
         
            -
                expect(component.class_list).to include("mock_component")
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              it "should render the object using the builder method name" do
         
     | 
| 
       35 
     | 
    
         
            -
                comp = expect(arbre {
         
     | 
| 
       36 
     | 
    
         
            -
                  mock_component
         
     | 
| 
       37 
     | 
    
         
            -
                }.to_s).to eq <<~HTML
         
     | 
| 
       38 
     | 
    
         
            -
                  <div class="mock_component">
         
     | 
| 
       39 
     | 
    
         
            -
                    <h2>Hello World</h2>
         
     | 
| 
       40 
     | 
    
         
            -
                  </div>
         
     | 
| 
       41 
     | 
    
         
            -
                  HTML
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,35 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # coding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            describe Arbre::Context do
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              let(:context) do
         
     | 
| 
       7 
     | 
    
         
            -
                Arbre::Context.new do
         
     | 
| 
       8 
     | 
    
         
            -
                  h1 "札幌市北区" # Add some HTML to the context
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              it "should not increment the indent_level" do
         
     | 
| 
       13 
     | 
    
         
            -
                expect(context.indent_level).to eq(-1)
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it "should return a bytesize" do
         
     | 
| 
       17 
     | 
    
         
            -
                expect(context.bytesize).to eq(25)
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              it "should return a length" do
         
     | 
| 
       21 
     | 
    
         
            -
                expect(context.length).to eq(25)
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              it "should delegate missing methods to the html string" do
         
     | 
| 
       25 
     | 
    
         
            -
                expect(context).to respond_to(:index)
         
     | 
| 
       26 
     | 
    
         
            -
                expect(context.index('<')).to eq(0)
         
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
              it "should use a cached version of the HTML for method delegation" do
         
     | 
| 
       30 
     | 
    
         
            -
                expect(context).to receive(:to_s).once.and_return("<h1>札幌市北区</h1>")
         
     | 
| 
       31 
     | 
    
         
            -
                expect(context.index('<')).to eq(0)
         
     | 
| 
       32 
     | 
    
         
            -
                expect(context.index('<')).to eq(0)
         
     | 
| 
       33 
     | 
    
         
            -
              end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,116 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Arbre::Element, "Finder Methods" do
         
     | 
| 
       4 
     | 
    
         
            -
              let(:assigns){ {} }
         
     | 
| 
       5 
     | 
    
         
            -
              let(:helpers){ {} }
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              describe "finding elements by tag name" do
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                it "should return 0 when no elements exist" do
         
     | 
| 
       10 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       11 
     | 
    
         
            -
                    div
         
     | 
| 
       12 
     | 
    
         
            -
                  }.get_elements_by_tag_name("li").size).to eq(0)
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                it "should return a child element" do
         
     | 
| 
       16 
     | 
    
         
            -
                  html = arbre do
         
     | 
| 
       17 
     | 
    
         
            -
                    ul
         
     | 
| 
       18 
     | 
    
         
            -
                    li
         
     | 
| 
       19 
     | 
    
         
            -
                    ul
         
     | 
| 
       20 
     | 
    
         
            -
                  end
         
     | 
| 
       21 
     | 
    
         
            -
                  elements = html.get_elements_by_tag_name("li")
         
     | 
| 
       22 
     | 
    
         
            -
                  expect(elements.size).to eq(1)
         
     | 
| 
       23 
     | 
    
         
            -
                  expect(elements[0]).to be_instance_of(Arbre::HTML::Li)
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                it "should return multple child elements" do
         
     | 
| 
       27 
     | 
    
         
            -
                  html = arbre do
         
     | 
| 
       28 
     | 
    
         
            -
                    ul
         
     | 
| 
       29 
     | 
    
         
            -
                    li
         
     | 
| 
       30 
     | 
    
         
            -
                    ul
         
     | 
| 
       31 
     | 
    
         
            -
                    li
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       33 
     | 
    
         
            -
                  elements = html.get_elements_by_tag_name("li")
         
     | 
| 
       34 
     | 
    
         
            -
                  expect(elements.size).to eq(2)
         
     | 
| 
       35 
     | 
    
         
            -
                  expect(elements[0]).to be_instance_of(Arbre::HTML::Li)
         
     | 
| 
       36 
     | 
    
         
            -
                  expect(elements[1]).to be_instance_of(Arbre::HTML::Li)
         
     | 
| 
       37 
     | 
    
         
            -
                end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                it "should return children's child elements" do
         
     | 
| 
       40 
     | 
    
         
            -
                  html = arbre do
         
     | 
| 
       41 
     | 
    
         
            -
                    ul
         
     | 
| 
       42 
     | 
    
         
            -
                    li do
         
     | 
| 
       43 
     | 
    
         
            -
                      li
         
     | 
| 
       44 
     | 
    
         
            -
                    end
         
     | 
| 
       45 
     | 
    
         
            -
                  end
         
     | 
| 
       46 
     | 
    
         
            -
                  elements = html.get_elements_by_tag_name("li")
         
     | 
| 
       47 
     | 
    
         
            -
                  expect(elements.size).to eq(2)
         
     | 
| 
       48 
     | 
    
         
            -
                  expect(elements[0]).to be_instance_of(Arbre::HTML::Li)
         
     | 
| 
       49 
     | 
    
         
            -
                  expect(elements[1]).to be_instance_of(Arbre::HTML::Li)
         
     | 
| 
       50 
     | 
    
         
            -
                  expect(elements[1].parent).to eq(elements[0])
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
              #TODO: describe "finding an element by id"
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
              describe "finding an element by a class name" do
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                it "should return 0 when no elements exist" do
         
     | 
| 
       59 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       60 
     | 
    
         
            -
                    div
         
     | 
| 
       61 
     | 
    
         
            -
                  }.get_elements_by_class_name("my_class").size).to eq(0)
         
     | 
| 
       62 
     | 
    
         
            -
                end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                it "should allow text nodes on tree" do
         
     | 
| 
       65 
     | 
    
         
            -
                  expect(arbre {
         
     | 
| 
       66 
     | 
    
         
            -
                    text_node "text"
         
     | 
| 
       67 
     | 
    
         
            -
                  }.get_elements_by_class_name("my_class").size).to eq(0)
         
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                it "should return a child element" do
         
     | 
| 
       71 
     | 
    
         
            -
                  html = arbre do
         
     | 
| 
       72 
     | 
    
         
            -
                    div class: "some_class"
         
     | 
| 
       73 
     | 
    
         
            -
                    div class: "my_class"
         
     | 
| 
       74 
     | 
    
         
            -
                  end
         
     | 
| 
       75 
     | 
    
         
            -
                  elements = html.get_elements_by_class_name("my_class")
         
     | 
| 
       76 
     | 
    
         
            -
                  expect(elements.size).to eq(1)
         
     | 
| 
       77 
     | 
    
         
            -
                  expect(elements[0]).to be_instance_of(Arbre::HTML::Div)
         
     | 
| 
       78 
     | 
    
         
            -
                end
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
                it "should return multple child elements" do
         
     | 
| 
       81 
     | 
    
         
            -
                  html = arbre do
         
     | 
| 
       82 
     | 
    
         
            -
                    div class: "some_class"
         
     | 
| 
       83 
     | 
    
         
            -
                    div class: "my_class"
         
     | 
| 
       84 
     | 
    
         
            -
                    div class: "my_class"
         
     | 
| 
       85 
     | 
    
         
            -
                  end
         
     | 
| 
       86 
     | 
    
         
            -
                  elements = html.get_elements_by_class_name("my_class")
         
     | 
| 
       87 
     | 
    
         
            -
                  expect(elements.size).to eq(2)
         
     | 
| 
       88 
     | 
    
         
            -
                  expect(elements[0]).to be_instance_of(Arbre::HTML::Div)
         
     | 
| 
       89 
     | 
    
         
            -
                  expect(elements[1]).to be_instance_of(Arbre::HTML::Div)
         
     | 
| 
       90 
     | 
    
         
            -
                end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                it "should return elements that match one of several classes" do
         
     | 
| 
       93 
     | 
    
         
            -
                  html = arbre do
         
     | 
| 
       94 
     | 
    
         
            -
                    div class: "some_class this_class"
         
     | 
| 
       95 
     | 
    
         
            -
                    div class: "some_class"
         
     | 
| 
       96 
     | 
    
         
            -
                    div class: "other_class"
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                  end
         
     | 
| 
       99 
     | 
    
         
            -
                  elements = html.get_elements_by_class_name("this_class")
         
     | 
| 
       100 
     | 
    
         
            -
                  expect(elements.size).to eq(1)
         
     | 
| 
       101 
     | 
    
         
            -
                  expect(elements[0]).to be_instance_of(Arbre::HTML::Div)
         
     | 
| 
       102 
     | 
    
         
            -
                end
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                it "should return a grandchild element" do
         
     | 
| 
       105 
     | 
    
         
            -
                  html = arbre do
         
     | 
| 
       106 
     | 
    
         
            -
                    div class: "some_class" do
         
     | 
| 
       107 
     | 
    
         
            -
                      div class: "my_class"
         
     | 
| 
       108 
     | 
    
         
            -
                    end
         
     | 
| 
       109 
     | 
    
         
            -
                  end
         
     | 
| 
       110 
     | 
    
         
            -
                  elements = html.get_elements_by_class_name("my_class")
         
     | 
| 
       111 
     | 
    
         
            -
                  expect(elements.size).to eq(1)
         
     | 
| 
       112 
     | 
    
         
            -
                  expect(elements[0]).to be_instance_of(Arbre::HTML::Div)
         
     | 
| 
       113 
     | 
    
         
            -
                end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
              end
         
     | 
| 
       116 
     | 
    
         
            -
            end
         
     |