Skip to content

Commit

Permalink
Don't wrap with module namespace in tests and specs
Browse files Browse the repository at this point in the history
Instead of wraping test/spec with module namespacing
pass module namespace inline with described class
  • Loading branch information
tkowalewski committed Aug 15, 2024
1 parent 03c5750 commit 6663b3c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions lib/rails/generators/rspec/templates/component_spec.rb.tt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

require "rails_helper"

<% module_namespacing do -%>
RSpec.describe <%= class_name %>Component, type: :component do
RSpec.describe <%= namespaced? ? "#{namespace.name}::" : '' %><%= class_name %>Component, type: :component do
pending "add some examples to (or delete) #{__FILE__}"

# it "renders something useful" do
Expand All @@ -14,4 +13,3 @@ RSpec.describe <%= class_name %>Component, type: :component do
# )
# end
end
<% end -%>
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

require "test_helper"

<% module_namespacing do -%>
class <%= class_name %>ComponentTest < ViewComponent::TestCase
class <%= namespaced? ? "#{namespace.name}::" : '' %><%= class_name %>ComponentTest < ViewComponent::TestCase
def test_component_renders_something_useful
# assert_equal(
# %(<span>Hello, components!</span>),
# render_inline(<%= class_name %>Component.new(message: "Hello, components!")).css("span").to_html
# )
end
end
<% end -%>
4 changes: 2 additions & 2 deletions test/dummy/test/generators/test_unit_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def test_component_tests
run_generator %w[example --test-framework test_unit]

assert_file "test/components/dummy/example_component_test.rb" do |component|
assert_match(/module Dummy/, component)
assert_match(/class ExampleComponentTest < /, component)
assert_no_match(/module/, component)
assert_match(/class Dummy::ExampleComponentTest < /, component)
assert_match(/def test_component_renders_something_useful/, component)
end
end
Expand Down

0 comments on commit 6663b3c

Please sign in to comment.