Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit de5d685

Browse files
committed
closes #142 closes #143
1 parent 6e2fcce commit de5d685

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

lib/generators/reactive_ruby/test_app/test_app_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def generate_test_app
2525

2626
def configure_test_app
2727
template 'boot.rb.erb', "#{test_app_path}/config/boot.rb", force: true
28-
template 'application.rb.erb', "#{test_app_path}/config/application.rb", force: true
29-
template 'assets/javascripts/application.rb',
28+
template 'test_application.rb.erb', "#{test_app_path}/config/application.rb", force: true
29+
template 'assets/javascripts/test_application.rb',
3030
"#{test_app_path}/app/assets/javascripts/application.rb", force: true
3131
template 'assets/javascripts/components.rb',
3232
"#{test_app_path}/app/views/components.rb", force: true

lib/react/component.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ def deprecated_params_method(name, *args, &block)
6464
end
6565

6666
def children
67-
nodes = [`#{@native}.props.children`].flatten
67+
nodes = if `#{@native}.props.children==undefined`
68+
[]
69+
else
70+
[`#{@native}.props.children`].flatten
71+
end
6872
class << nodes
6973
include Enumerable
7074

spec/react/component_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,14 @@ def render
705705
expect(nodes).to be_a(Enumerator)
706706
expect(nodes.size).to eq(2)
707707
end
708+
709+
it 'returns an empty Enumerator if there are no children' do
710+
ele = React.create_element(Foo)
711+
renderElementToDocument(ele)
712+
nodes = Foo.the_children.each
713+
expect(nodes.size).to eq(nil)
714+
expect(nodes.count).to eq(0)
715+
end
708716
end
709717
end
710718
end

0 commit comments

Comments
 (0)