Class: ReactOnRails::Generators::DevTestsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ReactOnRails::Generators::DevTestsGenerator
show all
- Includes:
- GeneratorHelper
- Defined in:
- lib/generators/react_on_rails/dev_tests_generator.rb
Instance Method Summary
collapse
#add_documentation_reference, #copy_file_and_missing_parent_directories, #dest_dir_exists?, #dest_file_exists?, #empty_directory_with_keep_file, #keep_file, #setup_file_error, #symlink_dest_file_to_dest_file
Instance Method Details
31
32
33
34
35
|
# File 'lib/generators/react_on_rails/dev_tests_generator.rb', line 31
def add_test_related_gems_to_gemfile
gem("rspec-rails", group: :test)
gem("chromedriver-helper", group: :test)
gem("coveralls", require: false)
end
|
#add_yarn_relative_install_script_in_package_json ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
|
# 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 = File.read(package_json)
replacement_value = " \"scripts\": {\n \"postinstall\": \"yalc link react-on-rails\",\n STRING\n new_client_package_json_contents = contents.gsub(/ {2}\"scripts\": {/,\n replacement_value)\n File.open(package_json, \"w+\") { |f| f.puts new_client_package_json_contents }\nend\n"
|
#copy_rspec_files ⇒ Object
19
20
21
22
23
24
25
|
# 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
|
#copy_tests ⇒ Object
27
28
29
|
# 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
|
#replace_prerender_if_server_rendering ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# 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
|