Skip to content

Commit 1660c1c

Browse files
justin808claude
andcommitted
Fix Redux generator tests and include missing GeneratorHelper
- Add missing GeneratorHelper include to ReactWithReduxGenerator to fix NoMethodError - Update test expectations for TypeScript Redux files (expect .ts/.tsx extensions) - Fix test regex to match type alias instead of interface declaration - All generator tests now pass (35/35 examples) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 14c7e20 commit 1660c1c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/generators/react_on_rails/react_with_redux_generator.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# frozen_string_literal: true
22

33
require "rails/generators"
4+
require_relative "generator_helper"
45

56
module ReactOnRails
67
module Generators
78
class ReactWithReduxGenerator < Rails::Generators::Base
9+
include GeneratorHelper
10+
811
Rails::Generators.hide_namespace(namespace)
912
source_root(File.expand_path("templates", __dir__))
1013

spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,29 @@
7373
before(:all) { run_generator_test_with_args(%w[--redux --typescript], package_json: true) }
7474

7575
include_examples "base_generator_common", application_js: true
76-
include_examples "react_with_redux_generator"
76+
77+
it "creates redux directories" do
78+
assert_directory "app/javascript/src/HelloWorldApp/ror_components"
79+
%w[actions constants containers reducers store].each do |dir|
80+
assert_directory("app/javascript/src/HelloWorldApp/#{dir}")
81+
end
82+
end
83+
84+
it "creates appropriate templates" do
85+
assert_file("app/views/hello_world/index.html.erb") do |contents|
86+
expect(contents).to match(/"HelloWorldApp"/)
87+
end
88+
end
89+
90+
it "copies base redux TypeScript files" do
91+
%w[app/javascript/src/HelloWorldApp/actions/helloWorldActionCreators.ts
92+
app/javascript/src/HelloWorldApp/containers/HelloWorldContainer.ts
93+
app/javascript/src/HelloWorldApp/constants/helloWorldConstants.ts
94+
app/javascript/src/HelloWorldApp/reducers/helloWorldReducer.ts
95+
app/javascript/src/HelloWorldApp/store/helloWorldStore.ts
96+
app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.client.tsx
97+
app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.server.tsx].each { |file| assert_file(file) }
98+
end
7799

78100
it "creates TypeScript Redux component files" do
79101
assert_file "app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.client.tsx"
@@ -83,7 +105,7 @@
83105

84106
it "TypeScript Redux component includes proper typing" do
85107
assert_file "app/javascript/src/HelloWorldApp/components/HelloWorld.tsx" do |content|
86-
expect(content).to match(/interface HelloWorldProps/)
108+
expect(content).to match(/type HelloWorldProps = PropsFromRedux/)
87109
expect(content).to match(/React\.FC<HelloWorldProps>/)
88110
end
89111
end

0 commit comments

Comments
 (0)