Skip to content

Commit 02bce87

Browse files
committed
Try to fix the generator tests
1 parent b6711ed commit 02bce87

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ yalc add react-on-rails
216216
### Testing the Generator
217217
The generators are covered by generator tests using Rails's generator testing helpers, but it never hurts to do a sanity check and explore the API. See [generator_testing_script.md](generator_testing_script.md) for a script on how to run the generator on a fresh project.
218218

219-
`rake run_rspec:example_basic` is a great way to run tests on one generator. Once that works, you should run `rake run_rspec:examples`. Be aware that this will create a hug number of files under a `/gen-examples` directory. You should be sure to exclude this directory from your IDE and delete it once your testing is done.
219+
`rake run_rspec:shakapacker_examples_basic` is a great way to run tests on one generator. Once that works, you should run `rake run_rspec:shakapacker_examples`. Be aware that this will create a huge number of files under a `/gen-examples` directory. You should be sure to exclude this directory from your IDE and delete it once your testing is done.
220220

221221
### Linting
222222
All linting is performed from the docker container for CI. You will need docker and docker-compose installed locally to lint code changes via the lint container. You can lint locally by running `npm run lint && npm run flow`

lib/generators/react_on_rails/base_generator.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ def add_base_gems_to_gemfile
7676
run "bundle"
7777
end
7878

79+
def use_local_react_on_rails
80+
false
81+
end
82+
7983
def add_js_dependencies
8084
major_minor_patch_only = /\A\d+\.\d+\.\d+\z/
81-
if ReactOnRails::VERSION.match?(major_minor_patch_only)
85+
if use_local_react_on_rails
86+
package_json.manager.add(["react-on-rails@link:.yalc/react-on-rails"])
87+
elsif ReactOnRails::VERSION.match?(major_minor_patch_only)
8288
package_json.manager.add(["react-on-rails@#{ReactOnRails::VERSION}"])
8389
else
8490
# otherwise add latest

lib/generators/react_on_rails/dev_tests_generator.rb

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class DevTestsGenerator < Rails::Generators::Base
1616
default: false,
1717
desc: "Setup prerender true for server rendered examples"
1818

19+
def use_local_react_on_rails
20+
true
21+
end
22+
1923
def copy_rspec_files
2024
%w[.eslintrc
2125
spec/spec_helper.rb

lib/generators/react_on_rails/templates/base/base/app/javascript/packs/registration.js.tt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ReactOnRails from 'react-on-rails';
1+
import ReactOnRails from 'react-on-rails/client';
22

33
import <%= config[:component_name] %> from '<%= config[:app_relative_path] %>';
44

0 commit comments

Comments
 (0)