Skip to content

Commit 2ceeb64

Browse files
committed
ci: fix old import paths and generator examples
1 parent 8d2fc83 commit 2ceeb64

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
context "with --redux" do
1818
before(:all) { run_generator_test_with_args(%w[--redux], package_json: true) }
1919

20-
include_examples "base_generator", application_js: true
20+
include_examples "base_generator_common", application_js: true
2121
include_examples "react_with_redux_generator"
2222
end
2323

2424
context "with -R" do
2525
before(:all) { run_generator_test_with_args(%w[-R], package_json: true) }
2626

27-
include_examples "base_generator", application_js: true
27+
include_examples "base_generator_common", application_js: true
2828
include_examples "react_with_redux_generator"
2929
end
3030

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
shared_examples "base_generator" do
3+
shared_examples "base_generator_common" do
44
it "adds a route for get 'hello_world' to 'hello_world#index'" do
55
match = <<-MATCH.strip_heredoc
66
Rails.application.routes.draw do
@@ -10,20 +10,29 @@
1010
assert_file "config/routes.rb", match
1111
end
1212

13-
it "creates react directories" do
14-
# Auto-registration structure is always created
15-
assert_directory "app/javascript/src/HelloWorld/ror_components"
16-
end
17-
18-
it "copies react files" do
13+
it "copies common files" do
1914
%w[app/controllers/hello_world_controller.rb
2015
config/initializers/react_on_rails.rb
2116
Procfile.dev
2217
Procfile.dev-static-assets
2318
Procfile.dev-prod-assets].each { |file| assert_file(file) }
19+
end
20+
end
2421

25-
# Auto-registration components are always created
22+
shared_examples "react_component_structure" do
23+
it "creates react directories" do
24+
# Auto-registration structure for non-Redux components
25+
assert_directory "app/javascript/src/HelloWorld/ror_components"
26+
end
27+
28+
it "copies react files" do
29+
# Auto-registration components for non-Redux
2630
assert_file "app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx"
2731
assert_file "app/javascript/src/HelloWorld/ror_components/HelloWorld.server.jsx"
2832
end
2933
end
34+
35+
shared_examples "base_generator" do
36+
include_examples "base_generator_common"
37+
include_examples "react_component_structure"
38+
end

spec/react_on_rails/support/shared_examples/react_with_redux_generator_examples.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
shared_examples "react_with_redux_generator" do
44
it "creates redux directories" do
5-
%w[actions constants reducers store].each { |dir| assert_directory("app/javascript/bundles/HelloWorld/#{dir}") }
5+
assert_directory "app/javascript/src/HelloWorldApp/ror_components"
6+
%w[actions constants containers reducers store].each do |dir|
7+
assert_directory("app/javascript/src/HelloWorldApp/#{dir}")
8+
end
69
end
710

811
it "creates appropriate templates" do
9-
assert_file("app/javascript/packs/hello-world-bundle.js") do |contents|
10-
expect(contents).to match("import HelloWorld from '../bundles/HelloWorld/startup/HelloWorldApp.client';")
11-
end
1212
assert_file("app/views/hello_world/index.html.erb") do |contents|
13-
expect(contents).to match(/"HelloWorld"/)
13+
expect(contents).to match(/"HelloWorldApp"/)
1414
end
1515
end
1616

1717
it "copies base redux files" do
18-
%w[app/javascript/bundles/HelloWorld/actions/helloWorldActionCreators.js
19-
app/javascript/bundles/HelloWorld/containers/HelloWorldContainer.js
20-
app/javascript/bundles/HelloWorld/constants/helloWorldConstants.js
21-
app/javascript/bundles/HelloWorld/reducers/helloWorldReducer.js
22-
app/javascript/bundles/HelloWorld/store/helloWorldStore.js
23-
app/javascript/bundles/HelloWorld/startup/HelloWorldApp.client.jsx
24-
app/javascript/bundles/HelloWorld/startup/HelloWorldApp.server.jsx].each { |file| assert_file(file) }
18+
%w[app/javascript/src/HelloWorldApp/actions/helloWorldActionCreators.js
19+
app/javascript/src/HelloWorldApp/containers/HelloWorldContainer.js
20+
app/javascript/src/HelloWorldApp/constants/helloWorldConstants.js
21+
app/javascript/src/HelloWorldApp/reducers/helloWorldReducer.js
22+
app/javascript/src/HelloWorldApp/store/helloWorldStore.js
23+
app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.client.jsx
24+
app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.server.jsx].each { |file| assert_file(file) }
2525
end
2626
end

0 commit comments

Comments
 (0)