Module: React::Rails::TestHelper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/react/rails/test_helper.rb
Instance Method Summary collapse
-
#assert_react_component(name) ⇒ Object
assert react_component render.
Instance Method Details
#assert_react_component(name) ⇒ Object
assert react_component render
assert_react_component(“HelloWorld”) do |props|
assert_equal "Hello world", props[:message]
end
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/react/rails/test_helper.rb', line 11 def assert_react_component(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 } props.deep_symbolize_keys! yield(props) end end end |