Skip to content

Commit 88e3390

Browse files
committed
Try to fix the generator tests
1 parent fcd2f1e commit 88e3390

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
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/dev_tests_generator.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,10 @@ def replace_prerender_if_server_rendering
4747

4848
def add_yarn_relative_install_script_in_package_json
4949
package_json = File.join(destination_root, "package.json")
50-
contents = File.read(package_json)
51-
replacement_value = <<-STRING
52-
"scripts": {
53-
"postinstall": "yalc link react-on-rails",
54-
STRING
55-
new_client_package_json_contents = contents.gsub(/ {2}"scripts": {/,
56-
replacement_value)
57-
File.open(package_json, "w+") { |f| f.puts new_client_package_json_contents }
50+
contents = JSON.parse(File.read(package_json))
51+
contents["scripts"] ||= {}
52+
contents["scripts"]["postinstall"] = "yalc link react-on-rails"
53+
File.open(package_json, "w+") { |f| f.puts JSON.pretty_generate(contents) }
5854
end
5955
end
6056
end

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

Lines changed: 1 addition & 1 deletion
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)