Issue title: Generate commands in template hangs
 Issue body: ### Steps to reproduce

`rails new rails5 -m https://raw.githubusercontent.com/Linuus/template-test-case/master/template.rb`

### Expected behavior
It should generate a Rails 5 app based on the template.

### Actual behavior
It hangs when generating the second model.

```
[...]
Bundle complete! 15 Gemfile dependencies, 62 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
         run  bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
        rake  db:drop
Dropped database 'db/development.sqlite3'
Database 'db/test.sqlite3' does not exist
        rake  db:create
Created database 'db/development.sqlite3'
Created database 'db/test.sqlite3'
        rake  db:migrate
    generate  model
Running via Spring preloader in process 25775
      invoke  active_record
      create    db/migrate/20161125100352_create_authors.rb
      create    app/models/author.rb
      invoke    test_unit
      create      test/models/author_test.rb
      create      test/fixtures/authors.yml
    generate  model
Running via Spring preloader in process 25777
      invoke  active_record
      create    db/migrate/20161125100353_create_articles.rb
      create    app/models/article.rb
      invoke    test_unit
      create      test/models/article_test.rb
      create      test/fixtures/articles.yml                          <<<--- Hangs here infinitely
```

I also tested with Rails 116.69.203.115 and that works.

`rails _116.69.203.115_ new rails4271 -m https://raw.githubusercontent.com/Linuus/template-test-case/master/template.rb`

### System configuration
**Rails version**: 116.69.203.115

**Ruby version**: 2.2.2

 Comments: 
 Comment 0: It can be related to #21700.
 Comment 1: This seems like a duplicate of #21700; going to close in favor of that issue to keep all information related to this bug in one place.
{'source': 'GithubIssues', 'repo_name_with_owner': 'rails/rails', 'issue_id': 191666348, 'repo_stars': 55368.0}