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