Episodes
brandoncordell said 9 months ago on Testing View Components :
I'm running into an issue with view components. I generated a component called `LikeButtonComponent`. The default generated test won't run. Here's the test as it sits:

# frozen_string_literal: true

require 'test_helper'

class LikeButtonComponentTest < ViewComponent::TestCase
  def test_component_renders_something_useful
    assert_equal(
      %(<span>Hello, components!</span>),
      render_inline(LikeButtonComponent.new(message: "Hello, components!")).css("span").to_html
    )
  end
end

This gives a `NameError: uninitialized constant LikeButtonComponentTest::LikeButtonComponent`.

Any ideas? I'm on Rails 6.1.4, Ruby 3.0.1, and view_components 2.37.0.

Login to Comment