From 33a87390aa54fc473bf878c2138eaa1387a3cf0b Mon Sep 17 00:00:00 2001 From: Ryunosuke Sato Date: Sun, 29 Oct 2017 01:22:41 +0900 Subject: [PATCH] Always generate package.json for generator spec Without package.json in dummy app, yarn will search package.json in ancestral directories. And when running `yarn install `, the package.json will be destructively changed. --- .../generators/install_generator_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/react_on_rails/generators/install_generator_spec.rb b/spec/react_on_rails/generators/install_generator_spec.rb index ed649159e..fec6b661f 100644 --- a/spec/react_on_rails/generators/install_generator_spec.rb +++ b/spec/react_on_rails/generators/install_generator_spec.rb @@ -8,35 +8,35 @@ destination File.expand_path("../../dummy-for-generators/", __FILE__) context "no args" do - before(:all) { run_generator_test_with_args(%w[]) } + before(:all) { run_generator_test_with_args(%w[], package_json: true) } include_examples "base_generator", application_js: true include_examples "no_redux_generator" end context "--redux" do - before(:all) { run_generator_test_with_args(%w[--redux]) } + before(:all) { run_generator_test_with_args(%w[--redux], package_json: true) } include_examples "base_generator", application_js: true include_examples "react_with_redux_generator" end context "-R" do - before(:all) { run_generator_test_with_args(%w[-R]) } + before(:all) { run_generator_test_with_args(%w[-R], package_json: true) } include_examples "base_generator", application_js: true include_examples "react_with_redux_generator" end context "without existing application.js or application.js.coffee file" do - before(:all) { run_generator_test_with_args([], application_js: false) } + before(:all) { run_generator_test_with_args([], application_js: false, package_json: true) } include_examples "base_generator", application_js: false end context "with existing application.js or application.js.coffee file" do - before(:all) { run_generator_test_with_args([], application_js: true) } + before(:all) { run_generator_test_with_args([], application_js: true, package_json: true) } include_examples "base_generator", application_js: true end context "with rails_helper" do - before(:all) { run_generator_test_with_args([], spec: true) } + before(:all) { run_generator_test_with_args([], spec: true, package_json: true) } it "adds ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)" do expected = ReactOnRails::Generators::BaseGenerator::CONFIGURE_RSPEC_TO_COMPILE_ASSETS assert_file("spec/rails_helper.rb") { |contents| assert_match(expected, contents) } @@ -49,13 +49,13 @@ end specify "base generator contains a helpful message" do - run_generator_test_with_args(%w[]) + run_generator_test_with_args(%w[], package_json: true) # GeneratorMessages.output is an array with the git error being the first one expect(GeneratorMessages.output).to include(expected) end specify "react with redux generator contains a helpful message" do - run_generator_test_with_args(%w[--redux]) + run_generator_test_with_args(%w[--redux], package_json: true) # GeneratorMessages.output is an array with the git error being the first one expect(GeneratorMessages.output).to include(expected) end