arbre 1.2.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/README.md +4 -4
  4. data/docs/Gemfile +1 -0
  5. data/lib/arbre/component.rb +1 -0
  6. data/lib/arbre/context.rb +3 -1
  7. data/lib/arbre/element/builder_methods.rb +1 -0
  8. data/lib/arbre/element/proxy.rb +1 -0
  9. data/lib/arbre/element.rb +4 -11
  10. data/lib/arbre/element_collection.rb +1 -0
  11. data/lib/arbre/html/attributes.rb +1 -0
  12. data/lib/arbre/html/class_list.rb +1 -0
  13. data/lib/arbre/html/document.rb +1 -0
  14. data/lib/arbre/html/html5_elements.rb +1 -0
  15. data/lib/arbre/html/tag.rb +7 -6
  16. data/lib/arbre/html/text_node.rb +1 -0
  17. data/lib/arbre/rails/forms.rb +2 -1
  18. data/lib/arbre/rails/rendering.rb +1 -0
  19. data/lib/arbre/rails/template_handler.rb +0 -17
  20. data/lib/arbre/rails.rb +1 -0
  21. data/lib/arbre/version.rb +2 -1
  22. data/lib/arbre.rb +1 -0
  23. metadata +38 -50
  24. data/.gitignore +0 -10
  25. data/.rubocop.yml +0 -15
  26. data/.travis.yml +0 -16
  27. data/Gemfile +0 -25
  28. data/Gemfile.lock +0 -224
  29. data/Rakefile +0 -21
  30. data/arbre.gemspec +0 -24
  31. data/spec/arbre/integration/html_spec.rb +0 -249
  32. data/spec/arbre/unit/component_spec.rb +0 -44
  33. data/spec/arbre/unit/context_spec.rb +0 -35
  34. data/spec/arbre/unit/element_finder_methods_spec.rb +0 -116
  35. data/spec/arbre/unit/element_spec.rb +0 -271
  36. data/spec/arbre/unit/html/class_list_spec.rb +0 -16
  37. data/spec/arbre/unit/html/tag_attributes_spec.rb +0 -62
  38. data/spec/arbre/unit/html/tag_spec.rb +0 -115
  39. data/spec/arbre/unit/html/text_node_spec.rb +0 -5
  40. data/spec/changelog_spec.rb +0 -27
  41. data/spec/rails/integration/forms_spec.rb +0 -105
  42. data/spec/rails/integration/rendering_spec.rb +0 -114
  43. data/spec/rails/rails_spec_helper.rb +0 -42
  44. data/spec/rails/stub_app/config/database.yml +0 -3
  45. data/spec/rails/stub_app/config/routes.rb +0 -3
  46. data/spec/rails/stub_app/db/schema.rb +0 -3
  47. data/spec/rails/stub_app/log/.gitignore +0 -1
  48. data/spec/rails/stub_app/public/favicon.ico +0 -0
  49. data/spec/rails/support/mock_person.rb +0 -15
  50. data/spec/rails/templates/arbre/_partial.arb +0 -1
  51. data/spec/rails/templates/arbre/_partial_with_assignment.arb +0 -1
  52. data/spec/rails/templates/arbre/empty.arb +0 -0
  53. data/spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb +0 -3
  54. data/spec/rails/templates/arbre/page_with_assignment.arb +0 -1
  55. data/spec/rails/templates/arbre/page_with_erb_partial.arb +0 -3
  56. data/spec/rails/templates/arbre/page_with_helpers.arb +0 -7
  57. data/spec/rails/templates/arbre/page_with_partial.arb +0 -3
  58. data/spec/rails/templates/arbre/simple_page.arb +0 -8
  59. data/spec/rails/templates/erb/_partial.erb +0 -1
  60. data/spec/spec_helper.rb +0 -7
  61. data/spec/support/bundle.rb +0 -4
  62. data/tasks/lint.rake +0 -69
  63. data/tasks/release.rake +0 -6
data/Gemfile.lock DELETED
@@ -1,224 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- arbre (1.2.0)
5
- activesupport (>= 3.0.0)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- actioncable (5.2.3)
11
- actionpack (= 5.2.3)
12
- nio4r (~> 2.0)
13
- websocket-driver (>= 0.6.1)
14
- actionmailer (5.2.3)
15
- actionpack (= 5.2.3)
16
- actionview (= 5.2.3)
17
- activejob (= 5.2.3)
18
- mail (~> 2.5, >= 2.5.4)
19
- rails-dom-testing (~> 2.0)
20
- actionpack (5.2.3)
21
- actionview (= 5.2.3)
22
- activesupport (= 5.2.3)
23
- rack (~> 2.0)
24
- rack-test (>= 0.6.3)
25
- rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.3)
28
- activesupport (= 5.2.3)
29
- builder (~> 3.1)
30
- erubi (~> 1.4)
31
- rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.3)
34
- activesupport (= 5.2.3)
35
- globalid (>= 0.3.6)
36
- activemodel (5.2.3)
37
- activesupport (= 5.2.3)
38
- activerecord (5.2.3)
39
- activemodel (= 5.2.3)
40
- activesupport (= 5.2.3)
41
- arel (>= 9.0)
42
- activestorage (5.2.3)
43
- actionpack (= 5.2.3)
44
- activerecord (= 5.2.3)
45
- marcel (~> 0.3.1)
46
- activesupport (5.2.3)
47
- concurrent-ruby (~> 1.0, >= 1.0.2)
48
- i18n (>= 0.7, < 2)
49
- minitest (~> 5.1)
50
- tzinfo (~> 1.1)
51
- addressable (2.5.2)
52
- public_suffix (>= 2.0.2, < 4.0)
53
- arel (9.0.0)
54
- ast (2.4.0)
55
- builder (3.2.3)
56
- capybara (3.15.0)
57
- addressable
58
- mini_mime (>= 0.1.3)
59
- nokogiri (~> 1.8)
60
- rack (>= 1.6.0)
61
- rack-test (>= 0.6.3)
62
- regexp_parser (~> 1.2)
63
- xpath (~> 3.2)
64
- chandler (0.9.0)
65
- netrc
66
- octokit (>= 2.2.0)
67
- coderay (1.1.2)
68
- combustion (1.1.0)
69
- activesupport (>= 3.0.0)
70
- railties (>= 3.0.0)
71
- thor (>= 0.14.6)
72
- concurrent-ruby (1.1.5)
73
- crass (1.0.4)
74
- diff-lcs (1.3)
75
- erubi (1.8.0)
76
- faraday (0.15.4)
77
- multipart-post (>= 1.2, < 3)
78
- ffi (1.9.25-java)
79
- globalid (0.4.2)
80
- activesupport (>= 4.2.0)
81
- i18n (1.6.0)
82
- concurrent-ruby (~> 1.0)
83
- jar-dependencies (0.4.0)
84
- jaro_winkler (1.5.2)
85
- jaro_winkler (1.5.2-java)
86
- loofah (2.2.3)
87
- crass (~> 1.0.2)
88
- nokogiri (>= 1.5.9)
89
- mail (2.7.1)
90
- mini_mime (>= 0.1.1)
91
- marcel (0.3.3)
92
- mimemagic (~> 0.3.2)
93
- method_source (0.9.2)
94
- mimemagic (0.3.3)
95
- mini_mime (1.0.1)
96
- mini_portile2 (2.4.0)
97
- minitest (5.11.3)
98
- multipart-post (2.0.0)
99
- netrc (0.11.0)
100
- nio4r (2.3.1)
101
- nio4r (2.3.1-java)
102
- nokogiri (1.10.2)
103
- mini_portile2 (~> 2.4.0)
104
- nokogiri (1.10.2-java)
105
- octokit (4.13.0)
106
- sawyer (~> 0.8.0, >= 0.5.3)
107
- parallel (1.14.0)
108
- parser (2.6.0.0)
109
- ast (~> 2.4.0)
110
- pry (0.12.2)
111
- coderay (~> 1.1.0)
112
- method_source (~> 0.9.0)
113
- pry (0.12.2-java)
114
- coderay (~> 1.1.0)
115
- method_source (~> 0.9.0)
116
- spoon (~> 0.0)
117
- psych (3.1.0)
118
- psych (3.1.0-java)
119
- jar-dependencies (>= 0.1.7)
120
- public_suffix (3.0.3)
121
- rack (2.0.6)
122
- rack-test (1.1.0)
123
- rack (>= 1.0, < 3)
124
- rails (5.2.3)
125
- actioncable (= 5.2.3)
126
- actionmailer (= 5.2.3)
127
- actionpack (= 5.2.3)
128
- actionview (= 5.2.3)
129
- activejob (= 5.2.3)
130
- activemodel (= 5.2.3)
131
- activerecord (= 5.2.3)
132
- activestorage (= 5.2.3)
133
- activesupport (= 5.2.3)
134
- bundler (>= 1.3.0)
135
- railties (= 5.2.3)
136
- sprockets-rails (>= 2.0.0)
137
- rails-dom-testing (2.0.3)
138
- activesupport (>= 4.2.0)
139
- nokogiri (>= 1.6)
140
- rails-html-sanitizer (1.0.4)
141
- loofah (~> 2.2, >= 2.2.2)
142
- railties (5.2.3)
143
- actionpack (= 5.2.3)
144
- activesupport (= 5.2.3)
145
- method_source
146
- rake (>= 0.8.7)
147
- thor (>= 0.19.0, < 2.0)
148
- rainbow (3.0.0)
149
- rake (12.3.2)
150
- regexp_parser (1.3.0)
151
- rspec (3.8.0)
152
- rspec-core (~> 3.8.0)
153
- rspec-expectations (~> 3.8.0)
154
- rspec-mocks (~> 3.8.0)
155
- rspec-core (3.8.0)
156
- rspec-support (~> 3.8.0)
157
- rspec-expectations (3.8.2)
158
- diff-lcs (>= 1.2.0, < 2.0)
159
- rspec-support (~> 3.8.0)
160
- rspec-mocks (3.8.0)
161
- diff-lcs (>= 1.2.0, < 2.0)
162
- rspec-support (~> 3.8.0)
163
- rspec-rails (3.8.2)
164
- actionpack (>= 3.0)
165
- activesupport (>= 3.0)
166
- railties (>= 3.0)
167
- rspec-core (~> 3.8.0)
168
- rspec-expectations (~> 3.8.0)
169
- rspec-mocks (~> 3.8.0)
170
- rspec-support (~> 3.8.0)
171
- rspec-support (3.8.0)
172
- rubocop (0.66.0)
173
- jaro_winkler (~> 1.5.1)
174
- parallel (~> 1.10)
175
- parser (>= 2.5, != 2.5.1.1)
176
- psych (>= 3.1.0)
177
- rainbow (>= 2.2.2, < 4.0)
178
- ruby-progressbar (~> 1.7)
179
- unicode-display_width (>= 1.4.0, < 1.6)
180
- ruby-progressbar (1.10.0)
181
- sawyer (0.8.1)
182
- addressable (>= 2.3.5, < 2.6)
183
- faraday (~> 0.8, < 1.0)
184
- spoon (0.0.6)
185
- ffi
186
- sprockets (3.7.2)
187
- concurrent-ruby (~> 1.0)
188
- rack (> 1, < 3)
189
- sprockets-rails (3.2.1)
190
- actionpack (>= 4.0)
191
- activesupport (>= 4.0)
192
- sprockets (>= 3.0.0)
193
- thor (0.20.3)
194
- thread_safe (0.3.6)
195
- thread_safe (0.3.6-java)
196
- tzinfo (1.2.5)
197
- thread_safe (~> 0.1)
198
- unicode-display_width (1.5.0)
199
- websocket-driver (0.7.0)
200
- websocket-extensions (>= 0.1.0)
201
- websocket-driver (0.7.0-java)
202
- websocket-extensions (>= 0.1.0)
203
- websocket-extensions (0.1.3)
204
- xpath (3.2.0)
205
- nokogiri (~> 1.8)
206
-
207
- PLATFORMS
208
- java
209
- ruby
210
-
211
- DEPENDENCIES
212
- arbre!
213
- capybara
214
- chandler
215
- combustion
216
- pry
217
- rails (>= 5.0.0.1)
218
- rake
219
- rspec
220
- rspec-rails
221
- rubocop
222
-
223
- BUNDLED WITH
224
- 2.0.1
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>&lt;br /&gt;</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>&lt;br /&gt;</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>&lt;br /&gt;</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="&lt;br /&gt;"></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