From 855b5289d9438f22658feba5533d7e2ff56383a8 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 30 Jan 2019 17:55:22 +0800 Subject: [PATCH] Fix assert_react_component test helper for multiple components page --- lib/react/rails/test_helper.rb | 4 +--- test/react/rails/test_helper_test.rb | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/react/rails/test_helper.rb b/lib/react/rails/test_helper.rb index 4d06512f0..b54f6e78b 100644 --- a/lib/react/rails/test_helper.rb +++ b/lib/react/rails/test_helper.rb @@ -9,9 +9,7 @@ module TestHelper # assert_equal "Hello world", props[:message] # end def assert_react_component(name) - assert_select "div[data-react-class]" do |dom| - assert_select "[data-react-class=?]", name - + assert_select "div[data-react-class=?]", name do |dom| if block_given? props = JSON.parse(dom.attr("data-react-props")) props.deep_transform_keys! { |key| key.to_s.underscore } diff --git a/test/react/rails/test_helper_test.rb b/test/react/rails/test_helper_test.rb index fb3efe82f..c0d41f823 100644 --- a/test/react/rails/test_helper_test.rb +++ b/test/react/rails/test_helper_test.rb @@ -13,5 +13,8 @@ class TestHelperTest < ActionDispatch::IntegrationTest assert_select "[id=?]", "component" assert_select "[class=?]", "greeting-message" end + assert_react_component "Todo" do |props| + assert_equal "Another Component", props[:todo] + end end end