class ReactOnRails::Generators::DevTestsGenerator
Public Instance Methods
Source
# File lib/generators/react_on_rails/dev_tests_generator.rb, line 48 def add_yarn_relative_install_script_in_package_json package_json = File.join(destination_root, "package.json") contents = JSON.parse(File.read(package_json)) contents["scripts"] ||= {} contents["scripts"]["postinstall"] = "yalc link react-on-rails" File.open(package_json, "w+") { |f| f.puts JSON.pretty_generate(contents) } end
Source
# File lib/generators/react_on_rails/dev_tests_generator.rb, line 19 def copy_rspec_files %w[.eslintrc spec/spec_helper.rb spec/rails_helper.rb spec/simplecov_helper.rb .rspec].each { |file| copy_file(file) } end
Source
# File lib/generators/react_on_rails/dev_tests_generator.rb, line 27 def copy_tests %w[spec/system/hello_world_spec.rb].each { |file| copy_file(file) } end
Source
# File lib/generators/react_on_rails/dev_tests_generator.rb, line 37 def replace_prerender_if_server_rendering return unless options.example_server_rendering hello_world_index = File.join(destination_root, "app", "views", "hello_world", "index.html.erb") hello_world_contents = File.read(hello_world_index) new_hello_world_contents = hello_world_contents.gsub("prerender: false", "prerender: true") File.open(hello_world_index, "w+") { |f| f.puts new_hello_world_contents } end