diff --git a/CHANGELOG.md b/CHANGELOG.md index 24a2d2fca..24ee3961c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # master +* Fix bug where generator created invalid test code. + + *Joel Hawksley* + # v1.14.0 * Rename ActionView::Component::Base to ViewComponent::Base diff --git a/lib/rails/generators/rspec/templates/component_spec.rb.tt b/lib/rails/generators/rspec/templates/component_spec.rb.tt index 85fdfe08c..27779d0c1 100644 --- a/lib/rails/generators/rspec/templates/component_spec.rb.tt +++ b/lib/rails/generators/rspec/templates/component_spec.rb.tt @@ -5,7 +5,7 @@ RSpec.describe <%= class_name %>Component, type: :component do # it "renders something useful" do # expect( - # render_inline(described_class, attr: "value") { "Hello, components!" }.css("p").to_html + # render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html # ).to include( # "Hello, components!" # ) diff --git a/lib/rails/generators/test_unit/templates/component_test.rb.tt b/lib/rails/generators/test_unit/templates/component_test.rb.tt index e2e59e58a..7ecca7e1b 100644 --- a/lib/rails/generators/test_unit/templates/component_test.rb.tt +++ b/lib/rails/generators/test_unit/templates/component_test.rb.tt @@ -4,7 +4,7 @@ class <%= class_name %>ComponentTest < ViewComponent::TestCase test "component renders something useful" do # assert_equal( # %(Hello, components!), - # render_inline(<%= class_name %>Component, attr: "value") { "Hello, components!" }.css("span").to_html + # render_inline(<%= class_name %>Component.new(attr: "value")) { "Hello, components!" }.css("span").to_html # ) end end diff --git a/test/view_component/test_unit_generator_test.rb b/test/view_component/test_unit_generator_test.rb index 1bbc7a9cb..35b9178ea 100644 --- a/test/view_component/test_unit_generator_test.rb +++ b/test/view_component/test_unit_generator_test.rb @@ -17,7 +17,7 @@ class ViewComponent::TestUnitGeneratorTest < ::Rails::Generators::TestCase test "generates component" do assert_file "../tmp/test/components/dummy_component_test.rb" do |content| - assert_match(/render_inline\(DummyComponent, attr: "value"\) { "Hello, components!" }.css\("span"\).to_html/, content) + assert_match(/render_inline\(DummyComponent.new\(attr: "value"\)\) { "Hello, components!" }.css\("span"\).to_html/, content) end end end