見出し画像

railsチュートリアル挑戦記 第3章 ほぼ静的なページの作成

railsチュートリアルをやりながらメモしたことをそのまま記述しています。

第3章ほぼ静的なページの作成
railsでは静的なページを作っておいて、あとから動的なページを作ることができる


・3 1 セットアップ

cloud9を時間を置いて開いたら以下の表示
EC2 instance is stopped. Attempting to start instance...
EC2インスタンスは停止しています。 インスタンスを開始しようとしています...
そんだけ


以下のコマンドでアプリケーションを作成する
cd ~/environment
rails _5.1.6_ new sample_app
cd ~/environment/sample_app

ログ
----------------------------
ec2-user:~/environment $ cd ~/environment
ec2-user:~/environment $ rails _5.1.6_ new sample_app
     create  
     create  README.md
     create  Rakefile
     create  config.ru
     create  .gitignore
     create  Gemfile
        run  git init from "."
Initialized empty Git repository in /home/ec2-user/environment/sample_app/.git/
     create  app
     create  app/assets/config/manifest.js
     create  app/assets/javascripts/application.js
     create  app/assets/javascripts/cable.js
     create  app/assets/stylesheets/application.css
     create  app/channels/application_cable/channel.rb
     create  app/channels/application_cable/connection.rb
     create  app/controllers/application_controller.rb
     create  app/helpers/application_helper.rb
     create  app/jobs/application_job.rb
     create  app/mailers/application_mailer.rb
     create  app/models/application_record.rb
     create  app/views/layouts/application.html.erb
     create  app/views/layouts/mailer.html.erb
     create  app/views/layouts/mailer.text.erb
     create  app/assets/images/.keep
     create  app/assets/javascripts/channels
     create  app/assets/javascripts/channels/.keep
     create  app/controllers/concerns/.keep
     create  app/models/concerns/.keep
     create  bin
     create  bin/bundle
     create  bin/rails
     create  bin/rake
     create  bin/setup
     create  bin/update
     create  bin/yarn
     create  config
     create  config/routes.rb
     create  config/application.rb
     create  config/environment.rb
     create  config/secrets.yml
     create  config/cable.yml
     create  config/puma.rb
     create  config/spring.rb
     create  config/environments
     create  config/environments/development.rb
     create  config/environments/production.rb
     create  config/environments/test.rb
     create  config/initializers
     create  config/initializers/application_controller_renderer.rb
     create  config/initializers/assets.rb
     create  config/initializers/backtrace_silencers.rb
     create  config/initializers/cookies_serializer.rb
     create  config/initializers/cors.rb
     create  config/initializers/filter_parameter_logging.rb
     create  config/initializers/inflections.rb
     create  config/initializers/mime_types.rb
     create  config/initializers/new_framework_defaults_5_1.rb
     create  config/initializers/wrap_parameters.rb
     create  config/locales
     create  config/locales/en.yml
     create  config/boot.rb
     create  config/database.yml
     create  db
     create  db/seeds.rb
     create  lib
     create  lib/tasks
     create  lib/tasks/.keep
     create  lib/assets
     create  lib/assets/.keep
     create  log
     create  log/.keep
     create  public
     create  public/404.html
     create  public/422.html
     create  public/500.html
     create  public/apple-touch-icon-precomposed.png
     create  public/apple-touch-icon.png
     create  public/favicon.ico
     create  public/robots.txt
     create  test/fixtures
     create  test/fixtures/.keep
     create  test/fixtures/files
     create  test/fixtures/files/.keep
     create  test/controllers
     create  test/controllers/.keep
     create  test/mailers
     create  test/mailers/.keep
     create  test/models
     create  test/models/.keep
     create  test/helpers
     create  test/helpers/.keep
     create  test/integration
     create  test/integration/.keep
     create  test/test_helper.rb
     create  test/system
     create  test/system/.keep
     create  test/application_system_test_case.rb
     create  tmp
     create  tmp/.keep
     create  tmp/cache
     create  tmp/cache/assets
     create  vendor
     create  vendor/.keep
     create  package.json
     remove  config/initializers/cors.rb
     remove  config/initializers/new_framework_defaults_5_1.rb
        run  bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
Using rake 13.0.1
Using concurrent-ruby 1.1.5
Using i18n 1.7.0
Using minitest 5.13.0
Using thread_safe 0.3.6
Using tzinfo 1.2.6
Using activesupport 5.1.7
Using builder 3.2.4
Using erubi 1.9.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.7
Using rails-dom-testing 2.0.3
Using crass 1.0.5
Using loofah 2.4.0
Using rails-html-sanitizer 1.3.0
Using actionview 5.1.7
Using rack 2.0.8
Using rack-test 1.1.0
Using actionpack 5.1.7
Using nio4r 2.5.2
Using websocket-extensions 0.1.4
Using websocket-driver 0.6.5
Using actioncable 5.1.7
Using globalid 0.4.2
Using activejob 5.1.7
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailer 5.1.7
Using activemodel 5.1.7
Using arel 8.0.0
Using activerecord 5.1.7
Using public_suffix 4.0.2
Using addressable 2.7.0
Using bindex 0.8.1
Using bundler 1.17.3
Using byebug 11.0.1
Using xpath 3.2.0
Using capybara 2.18.0
Using childprocess 3.0.0
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using coffee-script 2.4.1
Using method_source 0.9.2
Using thor 1.0.1
Using railties 5.1.7
Using coffee-rails 4.2.2
Using ffi 1.11.3
Using jbuilder 2.9.1
Using rb-fsevent 0.10.3
Using rb-inotify 0.10.1
Using ruby_dep 1.5.0
Using listen 3.1.5
Using puma 3.12.2
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using rails 5.1.7
Using rubyzip 2.0.0
Using sass-listen 4.0.0
Using sass 3.7.4
Using tilt 2.0.10
Using sass-rails 5.0.7
Using selenium-webdriver 3.142.7
Using spring 2.1.0
Using spring-watcher-listen 2.0.1
Using sqlite3 1.4.2
Using turbolinks-source 5.2.0
Using turbolinks 5.2.1
Using uglifier 4.2.0
Using web-console 3.7.0
Bundle complete! 16 Gemfile dependencies, 69 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
        run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted
ec2-user:~/environment $ cd ~/environment/sample_app
ec2-user:~/environment/sample_app (master) $ 
----------------------------

Gemfileを以下のようにする

Gemfile
----------------------------
source 'https://rubygems.org'
gem 'rails',        '5.1.6'
gem 'puma',         '3.9.1'
gem 'sass-rails',   '5.0.6'
gem 'uglifier',     '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks',   '5.0.1'
gem 'jbuilder',     '2.7.0'
group :development, :test do
 gem 'sqlite3', '1.3.13'
 gem 'byebug',  '9.0.6', platform: :mri
end
group :development do
 gem 'web-console',           '3.5.1'
 gem 'listen',                '3.1.5'
 gem 'spring',                '2.0.2'
 gem 'spring-watcher-listen', '2.0.1'
end
group :test do
 gem 'rails-controller-testing', '1.0.2'
 gem 'minitest',                 '5.10.3'
 gem 'minitest-reporters',       '1.1.14'
 gem 'guard',                    '2.13.0'
 gem 'guard-minitest',           '2.4.4'
end
group :production do
 gem 'pg', '0.20.0'
end
# Windows環境ではtzinfo-dataというgemを含める必要があります
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
----------------------------

修正したら必ずセーブする!


変更したら、以下のコマンドを実行
bundle install --without production

このオプションで、
PostgreSQL用のpg gemをdevelopment環境にインストールせず、代わりにSQLiteがdevelopment環境とtest環境で使われるようになる

そして、以下のコマンドを実行
bundle update

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ bundle install --without productionFetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
You have requested:
 spring = 2.0.2
The bundle currently has spring locked at 2.1.0.
Try running `bundle update spring`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
ec2-user:~/environment/sample_app (master) $ bundle update
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
Using rake 13.0.1
Using concurrent-ruby 1.1.5
Using i18n 1.7.0
Fetching minitest 5.10.3 (was 5.13.0)
Installing minitest 5.10.3 (was 5.13.0)
Using thread_safe 0.3.6
Using tzinfo 1.2.6
Using activesupport 5.1.6 (was 5.1.7)
Using builder 3.2.4
Using erubi 1.9.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.7
Using rails-dom-testing 2.0.3
Using crass 1.0.5
Using loofah 2.4.0
Using rails-html-sanitizer 1.3.0
Using actionview 5.1.6 (was 5.1.7)
Using rack 2.0.8
Using rack-test 1.1.0
Using actionpack 5.1.6 (was 5.1.7)
Using nio4r 2.5.2
Using websocket-extensions 0.1.4
Using websocket-driver 0.6.5
Using actioncable 5.1.6 (was 5.1.7)
Using globalid 0.4.2
Using activejob 5.1.6 (was 5.1.7)
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailer 5.1.6 (was 5.1.7)
Using activemodel 5.1.6 (was 5.1.7)
Using arel 8.0.0
Using activerecord 5.1.6 (was 5.1.7)
Fetching ansi 1.5.0
Installing ansi 1.5.0
Using bindex 0.8.1
Using bundler 1.17.3
Using byebug 9.0.6 (was 11.0.1)
Fetching coderay 1.1.2
Installing coderay 1.1.2
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using coffee-script 2.4.1
Using method_source 0.9.2
Using thor 1.0.1
Using railties 5.1.6 (was 5.1.7)
Using coffee-rails 4.2.2
Using ffi 1.11.3
Fetching formatador 0.2.5
Installing formatador 0.2.5
Using rb-fsevent 0.10.3
Using rb-inotify 0.10.1
Using ruby_dep 1.5.0
Using listen 3.1.5
Fetching lumberjack 1.0.13
Installing lumberjack 1.0.13
Fetching nenv 0.3.0
Installing nenv 0.3.0
Fetching shellany 0.0.1
Installing shellany 0.0.1
Fetching notiffany 0.1.3
Installing notiffany 0.1.3
Fetching pry 0.12.2
Installing pry 0.12.2
Fetching guard 2.13.0
Installing guard 2.13.0
Fetching guard-compat 1.2.1
Installing guard-compat 1.2.1
Fetching guard-minitest 2.4.4
Installing guard-minitest 2.4.4
Using multi_json 1.14.1
Using jbuilder 2.7.0 (was 2.9.1)
Using jquery-rails 4.3.1
Fetching ruby-progressbar 1.10.1
Installing ruby-progressbar 1.10.1
Fetching minitest-reporters 1.1.14
Installing minitest-reporters 1.1.14
Using puma 3.9.1 (was 3.12.2)
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using rails 5.1.6 (was 5.1.7)
Fetching rails-controller-testing 1.0.2
Installing rails-controller-testing 1.0.2
Using sass-listen 4.0.0
Using sass 3.7.4
Using tilt 2.0.10
Using sass-rails 5.0.6 (was 5.0.7)
Using spring 2.0.2 (was 2.1.0)
Using spring-watcher-listen 2.0.1
Using sqlite3 1.3.13 (was 1.4.2)
Using turbolinks-source 5.2.0
Using turbolinks 5.0.1 (was 5.2.1)
Using uglifier 3.2.0 (was 4.2.0)
Using web-console 3.5.1 (was 3.7.0)
Bundle updated!
Gems in the group production were not installed.
ec2-user:~/environment/sample_app (master) $ 
----------------------------

ここらへんからrailsチュートリアルの手順を完全に無視
絶対に上手く行く方法で進める
手順としては以下の通り
①ファイルを修正
②.gitを作成する
③Bitbucketにリポジトリを作成する
④Bitbucketにリモートする
⑤HerokuにWebページを作成する
⑥gitでadd,commitを行う
⑦Bitbucketにpushする
⑧Herokuにpushする

アプリケーションのreadmeを以下のように変更する

サンプルアプリケーション向けに書き換えたREADME
readme.md
----------------------------
# Ruby on Rails チュートリアルのサンプルアプリケーション
これは、次の教材で作られたサンプルアプリケーションです。   
[*Ruby on Rails チュートリアル*](https://railstutorial.jp/)
[Michael Hartl](http://www.michaelhartl.com/) 著
## ライセンス
[Ruby on Rails チュートリアル](https://railstutorial.jp/)内にある
ソースコードはMITライセンスとBeerwareライセンスのもとで公開されています。
詳細は [LICENSE.md](LICENSE.md) をご覧ください。
## 使い方
このアプリケーションを動かす場合は、まずはリポジトリを手元にクローンしてください。
その後、次のコマンドで必要になる RubyGems をインストールします。
```
$ bundle install --without production
```
その後、データベースへのマイグレーションを実行します。
```
$ rails db:migrate
```
最後に、テストを実行してうまく動いているかどうか確認してください。
```
$ rails test
```
テストが無事に通ったら、Railsサーバーを立ち上げる準備が整っているはずです。
```
$ rails server
```
詳しくは、[*Ruby on Rails チュートリアル*](https://railstutorial.jp/)
を参考にしてください。
----------------------------
helloアクションをApplicationコントローラーに追加する
app/controllers/application_controller.rb
----------------------------
class ApplicationController < ActionController::Base
 protect_from_forgery with: :exception
 def hello
   render html: "hello, world!"
 end
end
----------------------------
ルートルーティングを設定する
config/routes.rb
----------------------------
Rails.application.routes.draw do
 root 'application#hello'
end
----------------------------

ここまで終わったらファイルを全て保存して閉じておく

次はgitの設定
cd ~/environment/sample_app
git init

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ cd ~/environment/sample_app
ec2-user:~/environment/sample_app (master) $ git init
Reinitialized existing Git repository in /home/ec2-user/environment/sample_app/.git/
ec2-user:~/environment/sample_app (master) $ 
----------------------------

次に、あらかじめBitbucketにsample_appリポジトリを作成する
https://bitbucket.org/

終わったらcloud9に戻り、gitでBitbucketリモートする
git config --global user.name
git config --global user.email
git remote add origin git@bitbucket.org:**********/sample_app

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ git config --global user.name **********
ec2-user:~/environment/sample_app (master) $ git config --global user.email **********_2@yahoo.co.jp
ec2-user:~/environment/sample_app (master) $ git config --global user.name
**********
ec2-user:~/environment/sample_app (master) $ git config --global user.email
**********_2@yahoo.co.jp
ec2-user:~/environment/sample_app (master) $ git remote add origin git@bitbucket.org:**********/sample_app
ec2-user:~/environment/sample_app (master) $ git remote -v
origin  git@bitbucket.org:**********/sample_app (fetch)
origin  git@bitbucket.org:**********/sample_app (push)
ec2-user:~/environment/sample_app (master) $ 
----------------------------

そして、Herokuも設定を進める
source <(curl -sL https://cdn.learnenough.com/heroku_install)
heroku login --interactive
heroku create
heroku rename jun-killer-rails3

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ heroku -v
bash: heroku: command not found
ec2-user:~/environment/sample_app (master) $ source <(curl -sL https://cdn.learnenough.com/heroku_install)
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100 25.9M  100 25.9M    0     0  70.1M      0 --:--:-- --:--:-- --:--:-- 69.9M
mv: cannot move ‘heroku’ to ‘/usr/local/heroku’: Directory not empty
ec2-user:~/environment/sample_app (master) $ heroku login --interactive
heroku: Enter your login credentials
Email [**********_2@yahoo.co.jp]: **********_2@yahoo.co.jp
Password: ********
Logged in as **********_2@yahoo.co.jp
ec2-user:~/environment/sample_app (master) $ heroku create
Creating app... done,  young-castle-93324
https://young-castle-93324.herokuapp.com/ | https://git.heroku.com/young-castle-93324.git
ec2-user:~/environment/sample_app (master) $ heroku rename jun-killer-rails3
Renaming young-castle-93324 to jun-killer-rails3... done
https://jun-killer-rails3.herokuapp.com/ | https://git.heroku.com/jun-killer-rails3.git
Git remote heroku updated
    Don't forget to update git remotes for all other local checkouts of the
    app.
ec2-user:~/environment/sample_app (master) $ 
----------------------------

そして、ここでようやくgitでAddとCommitを行う
git add -A
※ここで僕のPCのネット接続がなぜか切れたのでホントにaddできたかどうかを確認するためにgit statusで実行
git commit -m "Initialize repository"

ログ
----------------------------
create mode 100644 heroku/node_modules/strftime/Changelog.md
create mode 100644 heroku/node_modules/strftime/Makefile
create mode 100644 heroku/node_modules/strftime/Readme.md
create mode 100644 heroku/node_modules/strftime/bower.json
create mode 100644 heroku/node_modules/strftime/component.json
create mode 100644 heroku/node_modules/strftime/millis.js
create mode 100644 heroku/node_modules/strftime/package.json
create mode 100644 heroku/node_modules/strftime/strftime-min.js
create mode 100644 heroku/node_modules/strftime/strftime.js
create mode 100755 heroku/node_modules/strftime/test-dst.js
create mode 100644 heroku/node_modules/strftime/test-week.js
create mode 100644 heroku/node_modules/strftime/test.c
create mode 100755 heroku/node_modules/strftime/test.js
create mode 100644 heroku/node_modules/strict-uri-encode/index.js
create mode 100644 heroku/node_modules/strict-uri-encode/license
create mode 100644 heroku/node_modules/strict-uri-encode/package.json
create mode 100644 heroku/node_modules/strict-uri-encode/readme.md
create mode 100644 heroku/node_modules/string-width/index.js
create mode 100644 heroku/node_modules/string-width/license
create mode 100644 heroku/node_modules/string-width/package.json
create mode 100644 heroku/node_modules/string-width/readme.md
create mode 100644 heroku/node_modules/string_decoder/.travis.yml
create mode 100644 heroku/node_modules/string_decoder/LICENSE
create mode 100644 heroku/node_modules/string_decoder/README.md
create mode 100644 heroku/node_modules/string_decoder/lib/string_decoder.js
create mode 100644 heroku/node_modules/string_decoder/node_modules/safe-buffer/LICENSE
create mode 100644 heroku/node_modules/string_decoder/node_modules/safe-buffer/README.md
create mode 100644 heroku/node_modules/string_decoder/node_modules/safe-buffer/index.d.ts
create mode 100644 heroku/node_modules/string_decoder/node_modules/safe-buffer/index.js
create mode 100644 heroku/node_modules/string_decoder/node_modules/safe-buffer/package.json
create mode 100644 heroku/node_modules/string_decoder/package.json
create mode 100644 heroku/node_modules/strip-ansi/index.d.ts
create mode 100644 heroku/node_modules/strip-ansi/index.js
create mode 100644 heroku/node_modules/strip-ansi/license
create mode 100644 heroku/node_modules/strip-ansi/node_modules/ansi-regex/index.js
create mode 100644 heroku/node_modules/strip-ansi/node_modules/ansi-regex/license
create mode 100644 heroku/node_modules/strip-ansi/node_modules/ansi-regex/package.json
create mode 100644 heroku/node_modules/strip-ansi/node_modules/ansi-regex/readme.md
create mode 100644 heroku/node_modules/strip-ansi/package.json
create mode 100644 heroku/node_modules/strip-ansi/readme.md
create mode 100644 heroku/node_modules/strip-bom/index.js
create mode 100644 heroku/node_modules/strip-bom/license
create mode 100644 heroku/node_modules/strip-bom/package.json
create mode 100644 heroku/node_modules/strip-bom/readme.md
create mode 100644 heroku/node_modules/strip-eof/index.js
create mode 100644 heroku/node_modules/strip-eof/license
create mode 100644 heroku/node_modules/strip-eof/package.json
create mode 100644 heroku/node_modules/strip-eof/readme.md
create mode 100644 heroku/node_modules/supports-color/browser.js
create mode 100644 heroku/node_modules/supports-color/index.js
create mode 100644 heroku/node_modules/supports-color/license
create mode 100644 heroku/node_modules/supports-color/package.json
create mode 100644 heroku/node_modules/supports-color/readme.md
create mode 100644 heroku/node_modules/supports-hyperlinks/browser.js
create mode 100644 heroku/node_modules/supports-hyperlinks/index.js
create mode 100644 heroku/node_modules/supports-hyperlinks/license
create mode 100644 heroku/node_modules/supports-hyperlinks/node_modules/has-flag/index.js
create mode 100644 heroku/node_modules/supports-hyperlinks/node_modules/has-flag/license
create mode 100644 heroku/node_modules/supports-hyperlinks/node_modules/has-flag/package.json
create mode 100644 heroku/node_modules/supports-hyperlinks/node_modules/has-flag/readme.md
create mode 100644 heroku/node_modules/supports-hyperlinks/package.json
create mode 100644 heroku/node_modules/supports-hyperlinks/readme.md
create mode 100644 heroku/node_modules/tar-fs/.travis.yml
create mode 100644 heroku/node_modules/tar-fs/LICENSE
create mode 100644 heroku/node_modules/tar-fs/README.md
create mode 100644 heroku/node_modules/tar-fs/index.js
create mode 120000 heroku/node_modules/tar-fs/node_modules/.bin/mkdirp
create mode 100644 heroku/node_modules/tar-fs/node_modules/pump/.travis.yml
create mode 100644 heroku/node_modules/tar-fs/node_modules/pump/LICENSE
create mode 100644 heroku/node_modules/tar-fs/node_modules/pump/README.md
create mode 100644 heroku/node_modules/tar-fs/node_modules/pump/index.js
create mode 100644 heroku/node_modules/tar-fs/node_modules/pump/package.json
create mode 100644 heroku/node_modules/tar-fs/node_modules/pump/test-browser.js
create mode 100644 heroku/node_modules/tar-fs/node_modules/pump/test.js
create mode 100644 heroku/node_modules/tar-fs/package.json
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/a/hello.txt
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/b/a/test.txt
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/d/file1
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/d/file2
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/d/sub-dir/file5
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/d/sub-files/file3
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/d/sub-files/file4
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/e/directory/.ignore
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/e/file
create mode 100644 heroku/node_modules/tar-fs/test/fixtures/invalid.tar
create mode 100644 heroku/node_modules/tar-fs/test/index.js
create mode 100644 heroku/node_modules/tar-stream/LICENSE
create mode 100644 heroku/node_modules/tar-stream/README.md
create mode 100644 heroku/node_modules/tar-stream/extract.js
create mode 100644 heroku/node_modules/tar-stream/headers.js
create mode 100644 heroku/node_modules/tar-stream/index.js
create mode 100644 heroku/node_modules/tar-stream/pack.js
create mode 100644 heroku/node_modules/tar-stream/package.json
create mode 100644 heroku/node_modules/temp/.npmignore
create mode 100644 heroku/node_modules/temp/.travis.yml
create mode 100644 heroku/node_modules/temp/LICENSE
create mode 100644 heroku/node_modules/temp/README.md
create mode 100644 heroku/node_modules/temp/examples/grepcount.js
create mode 100644 heroku/node_modules/temp/examples/pdfcreator.js
create mode 100644 heroku/node_modules/temp/lib/temp.js
create mode 100644 heroku/node_modules/temp/no_cleanup.js
create mode 100644 heroku/node_modules/temp/no_cleanup_on_exit.js
create mode 100644 heroku/node_modules/temp/no_cleanup_on_exit.spec.js
create mode 120000 heroku/node_modules/temp/node_modules/.bin/rimraf
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/AUTHORS
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/LICENSE
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/README.md
create mode 100755 heroku/node_modules/temp/node_modules/rimraf/bin.js
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/package.json
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/rimraf.js
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/test/run.sh
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/test/setup.sh
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/test/test-async.js
create mode 100644 heroku/node_modules/temp/node_modules/rimraf/test/test-sync.js
create mode 100644 heroku/node_modules/temp/package.json
create mode 100644 heroku/node_modules/temp/test/temp-test.js
create mode 100644 heroku/node_modules/term-img/index.js
create mode 100644 heroku/node_modules/term-img/license
create mode 100644 heroku/node_modules/term-img/node_modules/ansi-escapes/index.js
create mode 100644 heroku/node_modules/term-img/node_modules/ansi-escapes/license
create mode 100644 heroku/node_modules/term-img/node_modules/ansi-escapes/package.json
create mode 100644 heroku/node_modules/term-img/node_modules/ansi-escapes/readme.md
create mode 100644 heroku/node_modules/term-img/package.json
create mode 100644 heroku/node_modules/term-img/readme.md
create mode 100644 heroku/node_modules/through/.travis.yml
create mode 100644 heroku/node_modules/through/LICENSE.APACHE2
create mode 100644 heroku/node_modules/through/LICENSE.MIT
create mode 100644 heroku/node_modules/through/index.js
create mode 100644 heroku/node_modules/through/package.json
create mode 100644 heroku/node_modules/through/readme.markdown
create mode 100644 heroku/node_modules/through/test/async.js
create mode 100644 heroku/node_modules/through/test/auto-destroy.js
create mode 100644 heroku/node_modules/through/test/buffering.js
create mode 100644 heroku/node_modules/through/test/end.js
create mode 100644 heroku/node_modules/through/test/index.js
create mode 100644 heroku/node_modules/timed-out/index.js
create mode 100644 heroku/node_modules/timed-out/license
create mode 100644 heroku/node_modules/timed-out/package.json
create mode 100644 heroku/node_modules/timed-out/readme.md
create mode 100644 heroku/node_modules/tmp/LICENSE
create mode 100644 heroku/node_modules/tmp/README.md
create mode 100644 heroku/node_modules/tmp/lib/tmp.js
create mode 100644 heroku/node_modules/tmp/package.json
create mode 100644 heroku/node_modules/to-buffer/.travis.yml
create mode 100644 heroku/node_modules/to-buffer/LICENSE
create mode 100644 heroku/node_modules/to-buffer/README.md
create mode 100644 heroku/node_modules/to-buffer/index.js
create mode 100644 heroku/node_modules/to-buffer/package.json
create mode 100644 heroku/node_modules/to-buffer/test.js
create mode 100644 heroku/node_modules/to-readable-stream/index.js
create mode 100644 heroku/node_modules/to-readable-stream/license
create mode 100644 heroku/node_modules/to-readable-stream/package.json
create mode 100644 heroku/node_modules/to-readable-stream/readme.md
create mode 100644 heroku/node_modules/treeify/.travis.yml
create mode 100644 heroku/node_modules/treeify/LICENSE
create mode 100644 heroku/node_modules/treeify/README.md
create mode 100644 heroku/node_modules/treeify/examples/eukaryotes.html
create mode 100755 heroku/node_modules/treeify/examples/eukaryotes.js
create mode 100755 heroku/node_modules/treeify/examples/fs_tree.js
create mode 100644 heroku/node_modules/treeify/package.json
create mode 100644 heroku/node_modules/treeify/test/tree-test.js
create mode 100644 heroku/node_modules/treeify/treeify.js
create mode 100644 heroku/node_modules/true-myth/LICENSE
create mode 100644 heroku/node_modules/true-myth/README.md
create mode 100644 heroku/node_modules/true-myth/dist/cjs/index.js
create mode 100644 heroku/node_modules/true-myth/dist/cjs/maybe.js
create mode 100644 heroku/node_modules/true-myth/dist/cjs/result.js
create mode 100644 heroku/node_modules/true-myth/dist/cjs/unit.js
create mode 100644 heroku/node_modules/true-myth/dist/cjs/utils.js
create mode 100644 heroku/node_modules/true-myth/dist/es/index.js
create mode 100644 heroku/node_modules/true-myth/dist/es/maybe.js
create mode 100644 heroku/node_modules/true-myth/dist/es/result.js
create mode 100644 heroku/node_modules/true-myth/dist/es/unit.js
create mode 100644 heroku/node_modules/true-myth/dist/es/utils.js
create mode 100644 heroku/node_modules/true-myth/ember-addon.js
create mode 100644 heroku/node_modules/true-myth/index.d.ts
create mode 100644 heroku/node_modules/true-myth/maybe.d.ts
create mode 100644 heroku/node_modules/true-myth/package.json
create mode 100644 heroku/node_modules/true-myth/result.d.ts
create mode 100644 heroku/node_modules/true-myth/unit.d.ts
create mode 100644 heroku/node_modules/true-myth/utils.d.ts
create mode 100644 heroku/node_modules/tslib/.gitattributes
create mode 100644 heroku/node_modules/tslib/CopyrightNotice.txt
create mode 100644 heroku/node_modules/tslib/LICENSE.txt
create mode 100644 heroku/node_modules/tslib/README.md
create mode 100644 heroku/node_modules/tslib/bower.json
create mode 100644 heroku/node_modules/tslib/docs/generator.md
create mode 100644 heroku/node_modules/tslib/package.json
create mode 100644 heroku/node_modules/tslib/tslib.d.ts
create mode 100644 heroku/node_modules/tslib/tslib.es6.html
create mode 100644 heroku/node_modules/tslib/tslib.es6.js
create mode 100644 heroku/node_modules/tslib/tslib.html
create mode 100644 heroku/node_modules/tslib/tslib.js
create mode 100644 heroku/node_modules/tunnel-agent/LICENSE
create mode 100644 heroku/node_modules/tunnel-agent/README.md
create mode 100644 heroku/node_modules/tunnel-agent/index.js
create mode 100644 heroku/node_modules/tunnel-agent/package.json
create mode 100644 heroku/node_modules/tunnel-ssh/.eslintignore
create mode 100644 heroku/node_modules/tunnel-ssh/README.md
create mode 100644 heroku/node_modules/tunnel-ssh/examples/default.js
create mode 100644 heroku/node_modules/tunnel-ssh/examples/keepAlive.js
create mode 100644 heroku/node_modules/tunnel-ssh/examples/keepAlive_error.js
create mode 100644 heroku/node_modules/tunnel-ssh/examples/loginError.js
create mode 100644 heroku/node_modules/tunnel-ssh/examples/server/index.js
create mode 100644 heroku/node_modules/tunnel-ssh/index.js
create mode 100644 heroku/node_modules/tunnel-ssh/lib/config.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/.coveralls.yml
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/.eslintrc
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/.npmignore
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/.travis.yml
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/CHANGELOG.md
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/LICENSE
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/Makefile
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/README.md
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/component.json
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/karma.conf.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/node.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/package.json
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/src/browser.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/src/debug.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/src/index.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/src/inspector-log.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/debug/src/node.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ms/index.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ms/license.md
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ms/package.json
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ms/readme.md
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/.travis.yml
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/LICENSE
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/README.md
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/SFTPStream.md
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/index.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/lib/constants.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/lib/jsbn.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/lib/keyParser.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/lib/sftp.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/lib/ssh.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/lib/utils.js
create mode 120000 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/node_modules/.bin/semver
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/package.json
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/fixtures/encrypted-dsa.ppk
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/fixtures/encrypted-rsa.ppk
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/fixtures/id_rsa
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/fixtures/id_rsa_enc
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/fixtures/ssh_host_rsa_key
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test-durability-ssh.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test-kexdh.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test-keyparser.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test-packet60.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test-sftp.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test-ssh.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test-utils.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2-streams/test/test.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/.travis.yml
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/LICENSE
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/README.md
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/examples/server-chat.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/examples/sftp-server-download-only.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/lib/Channel.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/lib/SFTPWrapper.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/lib/agent.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/lib/client.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/lib/keepalivemgr.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/lib/server.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/lib/utils.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/package.json
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/bad_rsa_private_key
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/id_dsa
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/id_ecdsa
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/id_rsa
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/id_rsa.ppk
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/id_rsa_enc
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/ssh_host_dsa_key
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/ssh_host_ecdsa_key
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/fixtures/ssh_host_rsa_key
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/test-client-server.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/test-openssh.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/test/test.js
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/util/build_pagent.bat
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/util/pagent.c
create mode 100644 heroku/node_modules/tunnel-ssh/node_modules/ssh2/util/pagent.exe
create mode 100644 heroku/node_modules/tunnel-ssh/package.json
create mode 100644 heroku/node_modules/tunnel-ssh/rewrite.js
create mode 100644 heroku/node_modules/tunnel-ssh/test/config-spec.js
create mode 100644 heroku/node_modules/tunnel-ssh/test/main-spec.js
create mode 100644 heroku/node_modules/tunnel-ssh/test/server/index.js
create mode 100644 heroku/node_modules/type-fest/index.d.ts
create mode 100644 heroku/node_modules/type-fest/license
create mode 100644 heroku/node_modules/type-fest/package.json
create mode 100644 heroku/node_modules/type-fest/readme.md
create mode 100644 heroku/node_modules/type-fest/source/package-json.d.ts
create mode 100644 heroku/node_modules/universalify/LICENSE
create mode 100644 heroku/node_modules/universalify/README.md
create mode 100644 heroku/node_modules/universalify/index.js
create mode 100644 heroku/node_modules/universalify/package.json
create mode 100644 heroku/node_modules/urijs/CHANGELOG.md
create mode 100644 heroku/node_modules/urijs/LICENSE.txt
create mode 100644 heroku/node_modules/urijs/README.md
create mode 100644 heroku/node_modules/urijs/package.json
create mode 100644 heroku/node_modules/urijs/src/IPv6.js
create mode 100644 heroku/node_modules/urijs/src/SecondLevelDomains.js
create mode 100644 heroku/node_modules/urijs/src/URI.fragmentQuery.js
create mode 100644 heroku/node_modules/urijs/src/URI.fragmentURI.js
create mode 100644 heroku/node_modules/urijs/src/URI.js
create mode 100644 heroku/node_modules/urijs/src/URI.min.js
create mode 100644 heroku/node_modules/urijs/src/URITemplate.js
create mode 100644 heroku/node_modules/urijs/src/jquery.URI.js
create mode 100644 heroku/node_modules/urijs/src/jquery.URI.min.js
create mode 100644 heroku/node_modules/urijs/src/punycode.js
create mode 100644 heroku/node_modules/url-parse-lax/index.js
create mode 100644 heroku/node_modules/url-parse-lax/license
create mode 100644 heroku/node_modules/url-parse-lax/package.json
create mode 100644 heroku/node_modules/url-parse-lax/readme.md
create mode 100644 heroku/node_modules/url-parse/LICENSE
create mode 100644 heroku/node_modules/url-parse/README.md
create mode 100644 heroku/node_modules/url-parse/dist/url-parse.js
create mode 100644 heroku/node_modules/url-parse/dist/url-parse.min.js
create mode 100644 heroku/node_modules/url-parse/dist/url-parse.min.js.map
create mode 100644 heroku/node_modules/url-parse/index.js
create mode 100644 heroku/node_modules/url-parse/package.json
create mode 100644 heroku/node_modules/url-to-options/LICENSE
create mode 100644 heroku/node_modules/url-to-options/README.md
create mode 100644 heroku/node_modules/url-to-options/index.js
create mode 100644 heroku/node_modules/url-to-options/package.json
create mode 100644 heroku/node_modules/util-deprecate/History.md
create mode 100644 heroku/node_modules/util-deprecate/LICENSE
create mode 100644 heroku/node_modules/util-deprecate/README.md
create mode 100644 heroku/node_modules/util-deprecate/browser.js
create mode 100644 heroku/node_modules/util-deprecate/node.js
create mode 100644 heroku/node_modules/util-deprecate/package.json
create mode 100644 heroku/node_modules/uuid/.eslintrc.json
create mode 100644 heroku/node_modules/uuid/AUTHORS
create mode 100644 heroku/node_modules/uuid/CHANGELOG.md
create mode 100644 heroku/node_modules/uuid/LICENSE.md
create mode 100644 heroku/node_modules/uuid/README.md
create mode 100644 heroku/node_modules/uuid/README_js.md
create mode 100755 heroku/node_modules/uuid/bin/uuid
create mode 100644 heroku/node_modules/uuid/index.js
create mode 100644 heroku/node_modules/uuid/lib/bytesToUuid.js
create mode 100644 heroku/node_modules/uuid/lib/md5-browser.js
create mode 100644 heroku/node_modules/uuid/lib/md5.js
create mode 100644 heroku/node_modules/uuid/lib/rng-browser.js
create mode 100644 heroku/node_modules/uuid/lib/rng.js
create mode 100644 heroku/node_modules/uuid/lib/sha1-browser.js
create mode 100644 heroku/node_modules/uuid/lib/sha1.js
create mode 100644 heroku/node_modules/uuid/lib/v35.js
create mode 100644 heroku/node_modules/uuid/package.json
create mode 100644 heroku/node_modules/uuid/v1.js
create mode 100644 heroku/node_modules/uuid/v3.js
create mode 100644 heroku/node_modules/uuid/v4.js
create mode 100644 heroku/node_modules/uuid/v5.js
create mode 100644 heroku/node_modules/valid-url/.jshintrc
create mode 100644 heroku/node_modules/valid-url/.travis.yml
create mode 100644 heroku/node_modules/valid-url/LICENSE
create mode 100644 heroku/node_modules/valid-url/Makefile
create mode 100644 heroku/node_modules/valid-url/README.md
create mode 100644 heroku/node_modules/valid-url/index.js
create mode 100644 heroku/node_modules/valid-url/package.json
create mode 100644 heroku/node_modules/valid-url/test/is_http_uri.js
create mode 100644 heroku/node_modules/valid-url/test/is_https_uri.js
create mode 100644 heroku/node_modules/valid-url/test/is_uri.js
create mode 100644 heroku/node_modules/valid-url/test/is_web_uri.js
create mode 100644 heroku/node_modules/validator/CHANGELOG.md
create mode 100644 heroku/node_modules/validator/LICENSE
create mode 100644 heroku/node_modules/validator/README.md
create mode 100644 heroku/node_modules/validator/index.js
create mode 100644 heroku/node_modules/validator/lib/alpha.js
create mode 100644 heroku/node_modules/validator/lib/blacklist.js
create mode 100644 heroku/node_modules/validator/lib/contains.js
create mode 100644 heroku/node_modules/validator/lib/equals.js
create mode 100644 heroku/node_modules/validator/lib/escape.js
create mode 100644 heroku/node_modules/validator/lib/isAfter.js
create mode 100644 heroku/node_modules/validator/lib/isAlpha.js
create mode 100644 heroku/node_modules/validator/lib/isAlphanumeric.js
create mode 100644 heroku/node_modules/validator/lib/isAscii.js
create mode 100644 heroku/node_modules/validator/lib/isBase64.js
create mode 100644 heroku/node_modules/validator/lib/isBefore.js
create mode 100644 heroku/node_modules/validator/lib/isBoolean.js
create mode 100644 heroku/node_modules/validator/lib/isByteLength.js
create mode 100644 heroku/node_modules/validator/lib/isCreditCard.js
create mode 100644 heroku/node_modules/validator/lib/isCurrency.js
create mode 100644 heroku/node_modules/validator/lib/isDataURI.js
create mode 100644 heroku/node_modules/validator/lib/isDecimal.js
create mode 100644 heroku/node_modules/validator/lib/isDivisibleBy.js
create mode 100644 heroku/node_modules/validator/lib/isEmail.js
create mode 100644 heroku/node_modules/validator/lib/isEmpty.js
create mode 100644 heroku/node_modules/validator/lib/isFQDN.js
create mode 100644 heroku/node_modules/validator/lib/isFloat.js
create mode 100644 heroku/node_modules/validator/lib/isFullWidth.js
create mode 100644 heroku/node_modules/validator/lib/isHalfWidth.js
create mode 100644 heroku/node_modules/validator/lib/isHash.js
create mode 100644 heroku/node_modules/validator/lib/isHexColor.js
create mode 100644 heroku/node_modules/validator/lib/isHexadecimal.js
create mode 100644 heroku/node_modules/validator/lib/isIP.js
create mode 100644 heroku/node_modules/validator/lib/isIPRange.js
create mode 100644 heroku/node_modules/validator/lib/isISBN.js
create mode 100644 heroku/node_modules/validator/lib/isISIN.js
create mode 100644 heroku/node_modules/validator/lib/isISO31661Alpha2.js
create mode 100644 heroku/node_modules/validator/lib/isISO31661Alpha3.js
create mode 100644 heroku/node_modules/validator/lib/isISO8601.js
create mode 100644 heroku/node_modules/validator/lib/isISRC.js
create mode 100644 heroku/node_modules/validator/lib/isISSN.js
create mode 100644 heroku/node_modules/validator/lib/isIdentityCard.js
create mode 100644 heroku/node_modules/validator/lib/isIn.js
create mode 100644 heroku/node_modules/validator/lib/isInt.js
create mode 100644 heroku/node_modules/validator/lib/isJSON.js
create mode 100644 heroku/node_modules/validator/lib/isJWT.js
create mode 100644 heroku/node_modules/validator/lib/isLatLong.js
create mode 100644 heroku/node_modules/validator/lib/isLength.js
create mode 100644 heroku/node_modules/validator/lib/isLowercase.js
create mode 100644 heroku/node_modules/validator/lib/isMACAddress.js
create mode 100644 heroku/node_modules/validator/lib/isMD5.js
create mode 100644 heroku/node_modules/validator/lib/isMagnetURI.js
create mode 100644 heroku/node_modules/validator/lib/isMimeType.js
create mode 100644 heroku/node_modules/validator/lib/isMobilePhone.js
create mode 100644 heroku/node_modules/validator/lib/isMongoId.js
create mode 100644 heroku/node_modules/validator/lib/isMultibyte.js
create mode 100644 heroku/node_modules/validator/lib/isNumeric.js
create mode 100644 heroku/node_modules/validator/lib/isPort.js
create mode 100644 heroku/node_modules/validator/lib/isPostalCode.js
create mode 100644 heroku/node_modules/validator/lib/isRFC3339.js
create mode 100644 heroku/node_modules/validator/lib/isSurrogatePair.js
create mode 100644 heroku/node_modules/validator/lib/isURL.js
create mode 100644 heroku/node_modules/validator/lib/isUUID.js
create mode 100644 heroku/node_modules/validator/lib/isUppercase.js
create mode 100644 heroku/node_modules/validator/lib/isVariableWidth.js
create mode 100644 heroku/node_modules/validator/lib/isWhitelisted.js
create mode 100644 heroku/node_modules/validator/lib/ltrim.js
create mode 100644 heroku/node_modules/validator/lib/matches.js
create mode 100644 heroku/node_modules/validator/lib/normalizeEmail.js
create mode 100644 heroku/node_modules/validator/lib/rtrim.js
create mode 100644 heroku/node_modules/validator/lib/stripLow.js
create mode 100644 heroku/node_modules/validator/lib/toBoolean.js
create mode 100644 heroku/node_modules/validator/lib/toDate.js
create mode 100644 heroku/node_modules/validator/lib/toFloat.js
create mode 100644 heroku/node_modules/validator/lib/toInt.js
create mode 100644 heroku/node_modules/validator/lib/trim.js
create mode 100644 heroku/node_modules/validator/lib/unescape.js
create mode 100644 heroku/node_modules/validator/lib/util/assertString.js
create mode 100644 heroku/node_modules/validator/lib/util/includes.js
create mode 100644 heroku/node_modules/validator/lib/util/merge.js
create mode 100644 heroku/node_modules/validator/lib/util/toString.js
create mode 100644 heroku/node_modules/validator/lib/whitelist.js
create mode 100644 heroku/node_modules/validator/package.json
create mode 100644 heroku/node_modules/validator/validator.js
create mode 100644 heroku/node_modules/validator/validator.min.js
create mode 100644 heroku/node_modules/which/CHANGELOG.md
create mode 100644 heroku/node_modules/which/LICENSE
create mode 100644 heroku/node_modules/which/README.md
create mode 100755 heroku/node_modules/which/bin/which
create mode 100644 heroku/node_modules/which/package.json
create mode 100644 heroku/node_modules/which/which.js
create mode 100644 heroku/node_modules/widest-line/index.js
create mode 100644 heroku/node_modules/widest-line/license
create mode 100644 heroku/node_modules/widest-line/node_modules/ansi-regex/index.js
create mode 100644 heroku/node_modules/widest-line/node_modules/ansi-regex/license
create mode 100644 heroku/node_modules/widest-line/node_modules/ansi-regex/package.json
create mode 100644 heroku/node_modules/widest-line/node_modules/ansi-regex/readme.md
create mode 100644 heroku/node_modules/widest-line/node_modules/string-width/index.js
create mode 100644 heroku/node_modules/widest-line/node_modules/string-width/license
create mode 100644 heroku/node_modules/widest-line/node_modules/string-width/package.json
create mode 100644 heroku/node_modules/widest-line/node_modules/string-width/readme.md
create mode 100644 heroku/node_modules/widest-line/node_modules/strip-ansi/index.js
create mode 100644 heroku/node_modules/widest-line/node_modules/strip-ansi/license
create mode 100644 heroku/node_modules/widest-line/node_modules/strip-ansi/package.json
create mode 100644 heroku/node_modules/widest-line/node_modules/strip-ansi/readme.md
create mode 100644 heroku/node_modules/widest-line/package.json
create mode 100644 heroku/node_modules/widest-line/readme.md
create mode 100755 heroku/node_modules/wrap-ansi/index.js
create mode 100644 heroku/node_modules/wrap-ansi/license
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/ansi-regex/index.js
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/ansi-regex/license
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/ansi-regex/package.json
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/ansi-regex/readme.md
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/string-width/index.js
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/string-width/license
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/string-width/package.json
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/string-width/readme.md
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/strip-ansi/index.js
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/strip-ansi/license
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/strip-ansi/package.json
create mode 100644 heroku/node_modules/wrap-ansi/node_modules/strip-ansi/readme.md
create mode 100644 heroku/node_modules/wrap-ansi/package.json
create mode 100644 heroku/node_modules/wrap-ansi/readme.md
create mode 100644 heroku/node_modules/wrappy/LICENSE
create mode 100644 heroku/node_modules/wrappy/README.md
create mode 100644 heroku/node_modules/wrappy/package.json
create mode 100644 heroku/node_modules/wrappy/wrappy.js
create mode 100644 heroku/node_modules/ws/LICENSE
create mode 100644 heroku/node_modules/ws/README.md
create mode 100644 heroku/node_modules/ws/browser.js
create mode 100644 heroku/node_modules/ws/index.js
create mode 100644 heroku/node_modules/ws/lib/buffer-util.js
create mode 100644 heroku/node_modules/ws/lib/constants.js
create mode 100644 heroku/node_modules/ws/lib/event-target.js
create mode 100644 heroku/node_modules/ws/lib/extension.js
create mode 100644 heroku/node_modules/ws/lib/permessage-deflate.js
create mode 100644 heroku/node_modules/ws/lib/receiver.js
create mode 100644 heroku/node_modules/ws/lib/sender.js
create mode 100644 heroku/node_modules/ws/lib/validation.js
create mode 100644 heroku/node_modules/ws/lib/websocket-server.js
create mode 100644 heroku/node_modules/ws/lib/websocket.js
create mode 100644 heroku/node_modules/ws/package.json
create mode 100644 heroku/node_modules/xmldom/.npmignore
create mode 100644 heroku/node_modules/xmldom/.travis.yml
create mode 100644 heroku/node_modules/xmldom/LICENSE
create mode 100644 heroku/node_modules/xmldom/__package__.js
create mode 100644 heroku/node_modules/xmldom/changelog
create mode 100644 heroku/node_modules/xmldom/component.json
create mode 100644 heroku/node_modules/xmldom/dom-parser.js
create mode 100644 heroku/node_modules/xmldom/dom.js
create mode 100644 heroku/node_modules/xmldom/package.json
create mode 100644 heroku/node_modules/xmldom/readme.md
create mode 100644 heroku/node_modules/xmldom/sax.js
create mode 100644 heroku/node_modules/xtend/.jshintrc
create mode 100644 heroku/node_modules/xtend/LICENSE
create mode 100644 heroku/node_modules/xtend/README.md
create mode 100644 heroku/node_modules/xtend/immutable.js
create mode 100644 heroku/node_modules/xtend/mutable.js
create mode 100644 heroku/node_modules/xtend/package.json
create mode 100644 heroku/node_modules/xtend/test.js
create mode 100644 heroku/node_modules/yarn/LICENSE
create mode 100644 heroku/node_modules/yarn/README.md
create mode 100755 heroku/node_modules/yarn/bin/yarn
create mode 100755 heroku/node_modules/yarn/bin/yarn.cmd
create mode 100755 heroku/node_modules/yarn/bin/yarn.js
create mode 100755 heroku/node_modules/yarn/bin/yarnpkg
create mode 100755 heroku/node_modules/yarn/bin/yarnpkg.cmd
create mode 100755 heroku/node_modules/yarn/lib/cli.js
create mode 100644 heroku/node_modules/yarn/lib/v8-compile-cache.js
create mode 100644 heroku/node_modules/yarn/package.json
create mode 100644 heroku/oclif.manifest.json
create mode 100644 heroku/package.json
create mode 100644 heroku/yarn.lock
create mode 100644 lib/assets/.keep
create mode 100644 lib/tasks/.keep
create mode 100644 log/.keep
create mode 100644 package.json
create mode 100644 public/404.html
create mode 100644 public/422.html
create mode 100644 public/500.html
create mode 100644 public/apple-touch-icon-precomposed.png
create mode 100644 public/apple-touch-icon.png
create mode 100644 public/favicon.ico
create mode 100644 public/robots.txt
create mode 100644 test/application_system_test_case.rb
create mode 100644 test/controllers/.keep
create mode 100644 test/fixtures/.keep
create mode 100644 test/fixtures/files/.keep
create mode 100644 test/helpers/.keep
create mode 100644 test/integration/.keep
create mode 100644 test/mailers/.keep
create mode 100644 test/models/.keep
create mode 100644 test/system/.keep
create mode 100644 test/test_helper.rb
create mode 100644 tmp/.keep
create mode 100644 vendor/.keep
ec2-user:~/environment/sample_app (master) $ 
----------------------------

ここまで終わったら、Bitbucketにまずpush
git push -u origin master
うまく行かなかったら
git push -f origin master

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ git push -u origin master
To bitbucket.org:**********/sample_app
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@bitbucket.org:**********/sample_app'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
ec2-user:~/environment/sample_app (master) $ git push -f origin master
Counting objects: 13536, done.
Compressing objects: 100% (12276/12276), done.
Writing objects: 100% (13536/13536), 24.28 MiB | 1.93 MiB/s, done.
Total 13536 (delta 5232), reused 0 (delta 0)
remote: Resolving deltas: 100% (5232/5232), done.
To bitbucket.org:**********/sample_app
+ ec58948...4f35601 master -> master (forced update)
ec2-user:~/environment/sample_app (master) $ 
----------------------------

次に、Herokuにpush
git push heroku master
うまく行かなかったら
git push -f heroku master

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ git push heroku master
Counting objects: 13536, done.
Compressing objects: 100% (12276/12276), done.
Writing objects: 100% (13536/13536), 24.28 MiB | 3.05 MiB/s, done.
Total 13536 (delta 5232), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:                         Detected buildpacks: Ruby,Node.js
remote:                         See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.5.7
remote: -----> Vendoring libpq 5.12.1
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Installing dependencies using bundler 1.17.3
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Fetching gem metadata from https://rubygems.org/............
remote:        Fetching rake 13.0.1
remote:        Installing rake 13.0.1
remote:        Fetching concurrent-ruby 1.1.5
remote:        Fetching minitest 5.10.3
remote:        Fetching thread_safe 0.3.6
remote:        Installing minitest 5.10.3
remote:        Installing thread_safe 0.3.6
remote:        Installing concurrent-ruby 1.1.5
remote:        Fetching builder 3.2.4
remote:        Installing builder 3.2.4
remote:        Fetching erubi 1.9.0
remote:        Installing erubi 1.9.0
remote:        Fetching mini_portile2 2.4.0
remote:        Installing mini_portile2 2.4.0
remote:        Fetching crass 1.0.5
remote:        Fetching rack 2.0.8
remote:        Fetching nio4r 2.5.2
remote:        Installing crass 1.0.5
remote:        Installing nio4r 2.5.2 with native extensions
remote:        Installing rack 2.0.8
remote:        Fetching websocket-extensions 0.1.4
remote:        Installing websocket-extensions 0.1.4
remote:        Fetching mini_mime 1.0.2
remote:        Installing mini_mime 1.0.2
remote:        Fetching arel 8.0.0
remote:        Installing arel 8.0.0
remote:        Using bundler 1.17.3
remote:        Fetching coffee-script-source 1.12.2
remote:        Installing coffee-script-source 1.12.2
remote:        Fetching execjs 2.7.0
remote:        Installing execjs 2.7.0
remote:        Fetching method_source 0.9.2
remote:        Installing method_source 0.9.2
remote:        Fetching thor 1.0.1
remote:        Installing thor 1.0.1
remote:        Fetching ffi 1.11.3
remote:        Fetching multi_json 1.14.1
remote:        Installing multi_json 1.14.1
remote:        Installing ffi 1.11.3 with native extensions
remote:        Fetching pg 0.20.0
remote:        Installing pg 0.20.0 with native extensions
remote:        Fetching puma 3.9.1
remote:        Installing puma 3.9.1 with native extensions
remote:        Fetching rb-fsevent 0.10.3
remote:        Installing rb-fsevent 0.10.3
remote:        Fetching tilt 2.0.10
remote:        Installing tilt 2.0.10
remote:        Fetching turbolinks-source 5.2.0
remote:        Installing turbolinks-source 5.2.0
remote:        Fetching tzinfo 1.2.6
remote:        Installing tzinfo 1.2.6
remote:        Fetching nokogiri 1.10.7
remote:        Installing nokogiri 1.10.7 with native extensions
remote:        Fetching i18n 1.7.0
remote:        Installing i18n 1.7.0
remote:        Fetching websocket-driver 0.6.5
remote:        Installing websocket-driver 0.6.5 with native extensions
remote:        Fetching rack-test 1.1.0
remote:        Installing rack-test 1.1.0
remote:        Fetching sprockets 3.7.2
remote:        Installing sprockets 3.7.2
remote:        Fetching mail 2.7.1
remote:        Installing mail 2.7.1
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching uglifier 3.2.0
remote:        Installing uglifier 3.2.0
remote:        Fetching turbolinks 5.0.1
remote:        Installing turbolinks 5.0.1
remote:        Fetching rb-inotify 0.10.1
remote:        Installing rb-inotify 0.10.1
remote:        Fetching activesupport 5.1.6
remote:        Installing activesupport 5.1.6
remote:        Fetching sass-listen 4.0.0
remote:        Installing sass-listen 4.0.0
remote:        Fetching globalid 0.4.2
remote:        Installing globalid 0.4.2
remote:        Fetching activemodel 5.1.6
remote:        Installing activemodel 5.1.6
remote:        Fetching jbuilder 2.7.0
remote:        Installing jbuilder 2.7.0
remote:        Fetching sass 3.7.4
remote:        Installing sass 3.7.4
remote:        Fetching activejob 5.1.6
remote:        Installing activejob 5.1.6
remote:        Fetching activerecord 5.1.6
remote:        Installing activerecord 5.1.6
remote:        Fetching rails-dom-testing 2.0.3
remote:        Fetching loofah 2.4.0
remote:        Installing rails-dom-testing 2.0.3
remote:        Installing loofah 2.4.0
remote:        Fetching rails-html-sanitizer 1.3.0
remote:        Installing rails-html-sanitizer 1.3.0
remote:        Fetching actionview 5.1.6
remote:        Installing actionview 5.1.6
remote:        Fetching actionpack 5.1.6
remote:        Installing actionpack 5.1.6
remote:        Fetching actionmailer 5.1.6
remote:        Fetching railties 5.1.6
remote:        Fetching actioncable 5.1.6
remote:        Installing actioncable 5.1.6
remote:        Installing actionmailer 5.1.6
remote:        Installing railties 5.1.6
remote:        Fetching sprockets-rails 3.2.1
remote:        Installing sprockets-rails 3.2.1
remote:        Fetching jquery-rails 4.3.1
remote:        Fetching coffee-rails 4.2.2
remote:        Fetching rails 5.1.6
remote:        Installing coffee-rails 4.2.2
remote:        Installing rails 5.1.6
remote:        Fetching sass-rails 5.0.6
remote:        Installing sass-rails 5.0.6
remote:        Installing jquery-rails 4.3.1
remote:        Bundle complete! 20 Gemfile dependencies, 57 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Post-install message from i18n:
remote:        
remote:        HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
remote:        But that may break your application.
remote:        
remote:        Please check your Rails app for 'config.i18n.fallbacks = true'.
remote:        If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
remote:        'config.i18n.fallbacks = [I18n.default_locale]'.
remote:        If not, fallbacks will be broken in your app by I18n 1.1.x.
remote:        
remote:        For more info see:
remote:        https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
remote:        
remote:        Post-install message from sass:
remote:        
remote:        Ruby Sass has reached end-of-life and should no longer be used.
remote:        
remote:        * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote:          primary implementation: https://sass-lang.com/install
remote:        
remote:        * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote:          sassc gem: https://github.com/sass/sassc-ruby#readme
remote:        
remote:        * For more details, please refer to the Sass blog:
remote:          https://sass-lang.com/blog/posts/7828841
remote:        
remote:        Bundle completed (42.98s)
remote:        Cleaning up the bundler cache.
remote: -----> Installing node-v10.15.3-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        I, [2019-12-29T10:31:57.313849 #1475]  INFO -- : Writing /tmp/build_27deda9722fb960d865c02e77d590a62/public/assets/application-7e084e44b9a13db0cda25bad2ac6fdbbfe31462ec93176e245cd0bcbc079f436.js
remote:        I, [2019-12-29T10:31:57.314277 #1475]  INFO -- : Writing /tmp/build_27deda9722fb960d865c02e77d590a62/public/assets/application-7e084e44b9a13db0cda25bad2ac6fdbbfe31462ec93176e245cd0bcbc079f436.js.gz
remote:        I, [2019-12-29T10:31:57.322651 #1475]  INFO -- : Writing /tmp/build_27deda9722fb960d865c02e77d590a62/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css
remote:        I, [2019-12-29T10:31:57.322992 #1475]  INFO -- : Writing /tmp/build_27deda9722fb960d865c02e77d590a62/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz
remote:        Asset precompilation completed (2.86s)
remote:        Cleaning assets
remote:        Running: rake assets:clean
remote: -----> Detecting rails configuration
remote: 
remote: ###### WARNING:
remote: 
remote:        You have not declared a Ruby version in your Gemfile.
remote:        To set your Ruby version add this line to your Gemfile:
remote:        ruby '2.5.7'
remote:        # See https://devcenter.heroku.com/articles/ruby-versions for more information.
remote: 
remote: 
remote: ###### WARNING:
remote: 
remote:        Replacing libpq with version libpq 5.12.1
remote:        
remote:        This version includes a bug fix that can cause an exception
remote:        on boot for applications with incorrectly configured connection
remote:        values. For more information see:
remote:        
remote:          https://devcenter.heroku.com/articles/libpq-5-12-1-breaking-connection-behavior
remote:        
remote:        If your application breaks you can rollback to your last build.
remote:        You can also temporarially opt out of this behavior by setting:
remote:        
remote:        ```
remote:        $ heroku config:set HEROKU_SKIP_LIBPQ12=1
remote:        ```
remote:        
remote:        In the future libpq 5.12 will be the default on the platform and
remote:        you will not be able to opt-out of the library. For more information see:
remote:        
remote:          https://devcenter.heroku.com/articles/libpq-5-12-1-breaking-connection-behavior
remote: 
remote: 
remote: ###### WARNING:
remote: 
remote:        Detecting rails configuration failed
remote:        set HEROKU_DEBUG_RAILS_RUNNER=1 to debug
remote: 
remote: 
remote: ###### WARNING:
remote: 
remote:        No Procfile detected, using the default web server.
remote:        We recommend explicitly declaring how to boot your server process via a Procfile.
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote: 
remote: 
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> console, rake, web
remote: 
remote: -----> Compressing...
remote:        Done: 61.4M
remote: -----> Launching...
remote:        Released v6
remote:        https://jun-killer-rails3.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/jun-killer-rails3.git
* [new branch]      master -> master
ec2-user:~/environment/sample_app (master) $ git push -f heroku master
Everything up-to-date
ec2-user:~/environment/sample_app (master) $ 
----------------------------

ここまで、あらかじめ手順を書いておいてやったが、
見事にスムーズに行った
Cliborにあらかじめコマンドを登録しておいたので、
驚くほどスムーズに行けてかなりびっくりしている
1章、2章でrailsチュートリアル通りにやるとほぼ確実に上手く行かないので、
上手く行く方法を発見できてよかった
3章を始めてから10分もかかってない
これは凄くいい出だし!

以下にrailsアプリ作成が上手く行くざっくり手順を再度書いておきます
①ファイルを修正
②.gitを作成する
③Bitbucketにリポジトリを作成する
④Bitbucketにリモートする
⑤HerokuにWebページを作成する
⑥gitでadd,commitを行う
⑦Bitbucketにpushする
⑧Herokuにpushする

以下はBitbucketの表示

以下はHerokuの表示

・3 2 静的ページ



静的ページを作成していく
コントローラはREST(Representational State Transfer)アーキテクチャを読むと理解が深まる
https://ja.wikipedia.org/wiki/Representational_State_Transfer

controllerとviewを主に弄っていく

常にmasterで作業するのではなく、編集するたびにトピックブランチを作成して
いく習慣をつけるといい
static-pagesというトピックブランチを作成する
git checkout -b static-pages

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ git checkout -b static-pages
Switched to a new branch 'static-pages'
ec2-user:~/environment/sample_app (static-pages) $ git branch
 master
* static-pages
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------


・3 2 1 静的なページの生成


homeとhelpとaboutのコントローラを生成したいが、aboutだけは学習のために今回はコマンドで追加しない

StaticPagesコントローラを生成する
rails generate controller StaticPages home help

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails generate controller StaticPages home help
Running via Spring preloader in process 5763
     create  app/controllers/static_pages_controller.rb
      route  get 'static_pages/help'
      route  get 'static_pages/home'
     invoke  erb
     create    app/views/static_pages
     create    app/views/static_pages/home.html.erb
     create    app/views/static_pages/help.html.erb
     invoke  test_unit
     create    test/controllers/static_pages_controller_test.rb
     invoke  helper
     create    app/helpers/static_pages_helper.rb
     invoke    test_unit
     invoke  assets
     invoke    coffee
     create      app/assets/javascripts/static_pages.coffee
     invoke    scss
     create      app/assets/stylesheets/static_pages.scss
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------
完全なコマンドと短縮形があるので以下にその例を載せる
$ rails server→$ rails s
$ rails console→$ rails c
$ rails generate→$ rails g
$ rails test→$ rails t
$ bundle install→$ bundle

rails generate controllerはよく使いそうな気配を感じたためCliborに登録

Bitbucketにstatic-pagesをプッシュ
git add -A
git commit -m "Add a Static Pages controller"
git push -u origin static-pages

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ git add -A
ec2-user:~/environment/sample_app (static-pages) $ git commit -m "Add a Static Pages controller"
[static-pages 5829d92] Add a Static Pages controller
8 files changed, 37 insertions(+)
create mode 100644 app/assets/javascripts/static_pages.coffee
create mode 100644 app/assets/stylesheets/static_pages.scss
create mode 100644 app/controllers/static_pages_controller.rb
create mode 100644 app/helpers/static_pages_helper.rb
create mode 100644 app/views/static_pages/help.html.erb
create mode 100644 app/views/static_pages/home.html.erb
create mode 100644 test/controllers/static_pages_controller_test.rb
ec2-user:~/environment/sample_app (static-pages) $ git push -u origin static-pages
Counting objects: 21, done.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (21/21), 2.29 KiB | 469.00 KiB/s, done.
Total 21 (delta 4), reused 0 (delta 0)
remote: 
remote: Create pull request for static-pages:
remote:   https://bitbucket.org/********/sample_app/pull-requests/new?source=static-pages&t=1
remote: 
To bitbucket.org:********/sample_app
* [new branch]      static-pages -> static-pages
Branch static-pages set up to track remote branch static-pages from origin.
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

ブランチを指定してpushしたあとは、以降はgit pushだけでBitbucketにプッシュしてくれる

今回は失敗しなかったが、
$ rails generate controller StaticPages home help
で失敗したら
$ rails destroy controller StaticPages home help
で元に戻れる

$ rails generate model User name:string email:string
で失敗したら
$ rails destroy model User
で元に戻れる

rails db:migrate
で失敗したら
rails db:rollback
で元に戻る

rails db:migrate VERSION=1
で2番目の状態に戻る

話を戻して、
StaticPagesコントローラを生成すると、(config/routes.rb)ファイルが自動的に更新されるのを確認。

HTTPメソッドには4つの基本的な動作がある
GET ページを取得する
POST ページに送信する
PATCH サーバー上のなにかを更新
DELETE サーバー上のなにかを削除

・3 2 2 静的なページの調整

少しHTMLを弄るだけ

HomeページのHTMLを修正する
app/views/static_pages/home.html.erb
----------------------------
<h1>Sample App</h1>
<p>
 This is the home page for the
 <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
 sample application.
</p>
----------------------------
HelpページのHTMLを修正する
app/views/static_pages/help.html.erb
----------------------------
<h1>Help</h1>
<p>
 Get help on the Ruby on Rails Tutorial at the
 <a href="https://railstutorial.jp/help">Rails Tutorial help page</a>.
 To get help on this sample app, see the
 <a href="https://railstutorial.jp/#ebook"><em>Ruby on Rails Tutorial</em>
 book</a>.
</p>
----------------------------

・3 3 テストから始める


Aboutについてはイチから作成してみる

自動化テストを作成して、機能が正しく実装されたことを確認する
テストスイートをみっちり作成しておく

テストには3つのメリットがあると筆者は考えている
1.機能停止するバグを防止できる
2.安全にリファクタリングできる
3.設計を決められたり、他システムとの組み合わせ方を決めるのに役立つ

じゃあテストコードはいつ書くの?
オススメは下記
1.本コードよりテストコードのほうが短いならテストコードを先に書く
2.仕様がまだなら本コードを先に書き、仮仕様をあとで書く
3.セキュリティが重要な課題の場合はテストコードを先に書く
4.バグがあるならバグを再現するテストコードを先に書き、回帰バグを防ぐ体制を整えてから修正する
5.すぐ変更しそうな部分のテストコードはあとで書く
6.リファクタリングするときはテストコードを先に書く

テストと書いたりテストコードと書いたり曖昧な記述多めなので、
僕の書いたこの文章は間違っているかも

・3 3 1 最初のテスト


テストファイルは実は既に作成済になっている
sample_app/test/controllers/static_pages_controller_test.rb

中身は以下のようになっている

StaticPagesコントローラのデフォルトのテスト
test/controllers/static_pages_controller_test.rb
----------------------------
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
 test "should get home" do
   get static_pages_home_url
   assert_response :success
 end
 test "should get help" do
   get static_pages_help_url
   assert_response :success
 end
end
----------------------------


Homeページのテスト。
GETリクエストをhomeアクションに対して発行 (=送信) せよ。
そうすれば、リクエストに対するレスポンスは[成功]になるはず

Helpページのテスト。
GETリクエストをhelpアクションに対して発行 (=送信) せよ。
そうすれば、リクエストに対するレスポンスは[成功]になるはず

実はこれを実行するコマンドがある
rails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 5601
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 36561
# Running:
..
Finished in 0.307461s, 6.5049 runs/s, 6.5049 assertions/s.
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

何度も使いそうだからコマンドをCliborに登録した
実行してから終わるまでに時間がかかるが、理由がある
1.Springサーバーを起動してRails環境を事前読み込みするのに時間がかかる。ただしこれは最初の1回のみ。
2.Rubyそのものの起動に時間がかかる。ただし、これは3.6.2で扱うGuardを導入することで改善できる

・3 3 2 Red


Redは失敗を表す

テスト駆動開発のサイクルは以下の通り
1.失敗するテストを最初に書く
2.アプリケーションのコードを書いて成功させる
3.必要ならリファクタリング

Aboutページ用の失敗するテストを書く
test/controllers/static_pages_controller_test.rb
----------------------------
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
 test "should get home" do
   get static_pages_home_url
   assert_response :success
 end
 test "should get help" do
   get static_pages_help_url
   assert_response :success
 end
 test "should get about" do
   get static_pages_about_url
   assert_response :success
 end
end
----------------------------

rails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 5997
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 28847
# Running:
..E
Finished in 0.347449s, 8.6344 runs/s, 5.7562 assertions/s.
 1) Error:
StaticPagesControllerTest#test_should_get_about:
NameError: undefined local variable or method `static_pages_about_url' for #<StaticPagesControllerTest:0x0000000006e64e60>
   test/controllers/static_pages_controller_test.rb:15:in `block in <class:StaticPagesControllerTest>'
3 runs, 2 assertions, 0 failures, 1 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------


・3 3 3 Green


エラーになった理由はAboutページのURLが見つからないためである
about用のルートを追加する必要がある


about用のルートを追加する red
config/routes.rb
----------------------------
Rails.application.routes.draw do
 get  'static_pages/home'
 get  'static_pages/help'
 get  'static_pages/about'
 root 'application#hello'
end
----------------------------

ここでもう一度テストしてみる

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 6149
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 37955
# Running:
E..
Finished in 0.366121s, 8.1940 runs/s, 5.4627 assertions/s.
 1) Error:
StaticPagesControllerTest#test_should_get_about:
AbstractController::ActionNotFound: The action 'about' could not be found for StaticPagesController
   test/controllers/static_pages_controller_test.rb:15:in `block in <class:StaticPagesControllerTest>'
3 runs, 2 assertions, 0 failures, 1 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

StaticPagesコントローラにaboutアクションがない

aboutアクションが追加されたStaticPagesコントローラ red
app/controllers/static_pages_controller.rb
----------------------------
class StaticPagesController < ApplicationController
 def home
 end
 def help
 end
 def about
 end
end
----------------------------

再度テスト

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ 
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 6351
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 60152
# Running:
.E.
Finished in 0.331908s, 9.0386 runs/s, 6.0258 assertions/s.
 1) Error:
StaticPagesControllerTest#test_should_get_about:
ActionController::UnknownFormat: StaticPagesController#about is missing a template for this request format and variant.
request.formats: ["text/html"]
request.variant: []
NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
   test/controllers/static_pages_controller_test.rb:15:in `block in <class:StaticPagesControllerTest>'
3 runs, 2 assertions, 0 failures, 1 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

テンプレートがない

app/views/static_pageに、about.html.erbというファイルを作成する必要がある

unixコマンドでファイルを作成するとカッコイイとか言われてるのでその通りにしてみる
touch app/views/static_pages/about.html.erb

そしてapp/views/static_pages/about.html.erbを書き換える


Aboutページのコードgreen
app/views/static_pages/about.html.erb
----------------------------
<h1>About</h1>
<p>
 <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
 is a <a href="https://railstutorial.jp/#ebook">book</a> and
 <a href="https://railstutorial.jp/#screencast">screencast</a>
 to teach web development with
 <a href="http://rubyonrails.org/">Ruby on Rails</a>.
 This is the sample application for the tutorial.
</p>
----------------------------

これでテストはOKになるはず

rails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 6563
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 405
# Running:
...
Finished in 0.287202s, 10.4456 runs/s, 10.4456 assertions/s.
3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

イイネ!

・3 3 4 Refactor


リファクタリングせずにコード長いと汚くなりやすいから気をつけろよって言われてる

・3 4 少しだけ動的なページ


titleタグは、SEO (Search Engine Optimization: 検索エンジン最適化) において重要な役割を果たす
3つの静的ページのタイトルを「<ページ名> | Ruby on Rails Tutorial Sample App」という形式に変更する

学習のために、application.html.erbをlayout_fileに名前を変更する
mv app/views/layouts/application.html.erb layout_file

…sample_appの直下に移動したけどいいんか?これ。とりあえずほっとくか

次の章から以下のようにする
ページ URL 基本タイトル 追加タイトル
Home /static_pages/home "Ruby on Rails Tutorial Sample App" "Home"
Help /static_pages/help "Ruby on Rails Tutorial Sample App" "Help"
About /static_pages/about "Ruby on Rails Tutorial Sample App" "About"

・3 4 1 タイトルをテストする (Red)

HTMLの基本は以下のような構造

Webページの典型的なHTML構造
----------------------------
<!DOCTYPE html>
<html>
 <head>
   <title>Greeting</title>
 </head>
 <body>
   <p>Hello, world!</p>
 </body>
</html>
----------------------------

assert_selectメソッドでは、特定のHTMLタグが存在するかどうかをテストできる

今回は、title内に「Home | Ruby on Rails Tutorial Sample App」という文字列があるかどうかをチェックする

StaticPagesコントローラのタイトルをテストする red
test/controllers/static_pages_controller_test.rb
----------------------------
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
 test "should get home" do
   get static_pages_home_url
   assert_response :success
   assert_select "title", "Home | Ruby on Rails Tutorial Sample App"
 end
 test "should get help" do
   get static_pages_help_url
   assert_response :success
   assert_select "title", "Help | Ruby on Rails Tutorial Sample App"
 end
 test "should get about" do
   get static_pages_about_url
   assert_response :success
   assert_select "title", "About | Ruby on Rails Tutorial Sample App"
 end
end
----------------------------

ここでテストしてみる
rails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 7208
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 55450
# Running:
FFF
Finished in 0.157012s, 19.1068 runs/s, 38.2137 assertions/s.
 1) Failure:
StaticPagesControllerTest#test_should_get_help [/home/ec2-user/environment/sample_app/test/controllers/static_pages_controller_test.rb:14]:
Expected at least 1 element matching "title", found 0..
Expected 0 to be >= 1.
 2) Failure:
StaticPagesControllerTest#test_should_get_about [/home/ec2-user/environment/sample_app/test/controllers/static_pages_controller_test.rb:20]:
Expected at least 1 element matching "title", found 0..
Expected 0 to be >= 1.
 3) Failure:
StaticPagesControllerTest#test_should_get_home [/home/ec2-user/environment/sample_app/test/controllers/static_pages_controller_test.rb:8]:
Expected at least 1 element matching "title", found 0..
Expected 0 to be >= 1.
3 runs, 6 assertions, 3 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

順不動でfailures出てるな

・3 4 2 タイトルを追加する (Green)

テストがパスするようにする

完全なHTML構造を備えたHomeページのビュー red
app/views/static_pages/home.html.erb
----------------------------
<!DOCTYPE html>
<html>
 <head>
   <title>Home | Ruby on Rails Tutorial Sample App</title>
 </head>
 <body>
   <h1>Sample App</h1>
   <p>
     This is the home page for the
     <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
     sample application.
   </p>
 </body>
</html>
----------------------------
完全なHTML構造を備えたHelpページのビュー red
app/views/static_pages/help.html.erb
----------------------------
<!DOCTYPE html>
<html>
 <head>
   <title>Help | Ruby on Rails Tutorial Sample App</title>
 </head>
 <body>
   <h1>Help</h1>
   <p>  Get help on the Ruby on Rails Tutorial at the
     <a href="https://railstutorial.jp/help">Rails Tutorial help
     page</a>.
     To get help on this sample app, see the
     <a href="https://railstutorial.jp/#ebook">
     <em>Ruby on Rails Tutorial</em> book</a>.
   </p>
 </body>
</html>
----------------------------
完全なHTML構造を備えたAboutページのビュー green
app/views/static_pages/about.html.erb
----------------------------
<!DOCTYPE html>
<html>
 <head>
   <title>About | Ruby on Rails Tutorial Sample App</title>
 </head>
 <body>
   <h1>About</h1>
   <p>
     <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
     is a <a href="https://railstutorial.jp/#ebook">book</a> and
     <a href="https://railstutorial.jp/#screencast">screencast</a>
     to teach web development with
     <a href="http://rubyonrails.org/">Ruby on Rails</a>.
     This is the sample application for the tutorial.
   </p>
 </body>
</html>
----------------------------

そしてrails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 7405
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 12018
# Running:
...
Finished in 0.134338s, 22.3317 runs/s, 44.6633 assertions/s.
3 runs, 6 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

testコードにはいくつか繰り返しがあったので、下記のようにリファクタリングする

基本タイトルを使ったStaticPagesコントローラのテスト green
test/controllers/static_pages_controller_test.rb
----------------------------
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
 def setup
   @base_title = "Ruby on Rails Tutorial Sample App"
 end
 test "should get home" do
   get static_pages_home_url
   assert_response :success
   assert_select "title", "Home | #{@base_title}"
 end
 test "should get help" do
   get static_pages_help_url
   assert_response :success
   assert_select "title", "Help | #{@base_title}"
 end
 test "should get about" do
   get static_pages_about_url
   assert_response :success
   assert_select "title", "About | #{@base_title}"
 end
end
----------------------------

ここで、setupはテストコードにおいて特殊な意味を持つ
たぶんインスタンス化のときに呼び出されるようなメソッド

そしてProgateでおなじみの変数展開が使われてる

rails testをしてみる

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 7518
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 2486
# Running:
...
Finished in 0.135116s, 22.2031 runs/s, 44.4062 assertions/s.
3 runs, 6 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

イイネ!

・3 4 3 レイアウトと埋め込みRuby (Refactor)


同じコードを繰り返すことはRubyの「DRY」(Don’t Repeat Yourself: 繰り返すべからず) という原則に反する

重複を取り除くテクニックの1つとして、ビューで「埋め込みRuby」(Embedded Ruby) が使える。

タイトルにERBを使ったHomeページのビューgreen
app/views/static_pages/home.html.erb
----------------------------
<% provide(:title, "Home") %>
<!DOCTYPE html>
<html>
 <head>
   <title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
 </head>
 <body>
   <h1>Sample App</h1>
   <p>
     This is the home page for the
     <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
     sample application.
   </p>
 </body>
</html>
----------------------------

拡張子のerbはEmbeded Rubyの略

<% provide(:title, "Home") %>とすると、
<%= yield(:title) %>の部分がHomeに変わる

<% ... %>と書くと、中に書かれたコードを単に実行するだけで何も出力しない
<%= ... %>のように等号を追加すると、中のコードの実行結果がテンプレートのその部分に挿入される

これProgateでやってるときどっちがどっちだか分からなかったけどそういうことだったのか!
これからは理解できそう!

rails testしてみる

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 9060
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 18238
# Running:
...
Finished in 0.157230s, 19.0803 runs/s, 38.1605 assertions/s.
3 runs, 6 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

よさげ

タイトルにERBを使ったHelpページのビューgreen
app/views/static_pages/help.html.erb
----------------------------
<% provide(:title, "Help") %>
<!DOCTYPE html>
<html>
 <head>
   <title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
 </head>
 <body>
   <h1>Help</h1>
   <p>  Get help on the Ruby on Rails Tutorial at the
     <a href="https://railstutorial.jp/help">Rails Tutorial help
     section</a>.
     To get help on this sample app, see the
     <a href="https://railstutorial.jp/#ebook">
     <em>Ruby on Rails Tutorial</em> book</a>.
   </p>
 </body>
</html>
----------------------------
タイトルにERBを使ったAboutページのビューgreen
app/views/static_pages/about.html.erb
----------------------------
<% provide(:title, "About") %>
<!DOCTYPE html>
<html>
 <head>
   <title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
 </head>
 <body>
   <h1>About</h1>
   <p>
     <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
     is a <a href="https://railstutorial.jp/#ebook">book</a> and
     <a href="https://railstutorial.jp/#screencast">screencast</a>
     to teach web development with
     <a href="http://rubyonrails.org/">Ruby on Rails</a>.
     This is the sample application for the tutorial.
   </p>
 </body>
</html>
----------------------------

以下のコマンドで、layout_fileを元に戻しておく
mv layout_file app/views/layouts/application.html.erb

そして、以下のコードになる

サンプルアプリケーションのレイアウト green
app/views/layouts/application.html.erb
----------------------------
<!DOCTYPE html>
<html>
 <head>
   <title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
   <%= csrf_meta_tags %>
   <%= stylesheet_link_tag    'application', media: 'all',
                              'data-turbolinks-track': 'reload' %>
   <%= javascript_include_tag 'application',
                              'data-turbolinks-track': 'reload' %>
 </head>
 <body>
   <%= yield %>
 </body>
</html>
----------------------------

bodyは各erbの内容にしますよという意味
headにもともとある3行はcsrf_meta_tag、スタイルシート、javascriptをページ内で展開するためのもの

HTML構造を削除したHomeページ green
app/views/static_pages/home.html.erb
----------------------------
<% provide(:title, "Home") %>
<h1>Sample App</h1>
<p>
 This is the home page for the
 <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
 sample application.
</p>
----------------------------
HTML構造を削除したHelpページ green
app/views/static_pages/help.html.erb
----------------------------
<% provide(:title, "Help") %>
<h1>Help</h1>
<p>  Get help on the Ruby on Rails Tutorial at the
 <a href="https://railstutorial.jp/help">Rails Tutorial help section</a>.
 To get help on this sample app, see the
 <a href="https://railstutorial.jp/#ebook"><em>Ruby on Rails Tutorial</em>
 book</a>.
</p>
----------------------------
HTML構造を削除したAboutページ green
app/views/static_pages/about.html.erb
----------------------------
<% provide(:title, "About") %>
<h1>About</h1>
<p>
 <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
 is a <a href="https://railstutorial.jp/#ebook">book</a> and
 <a href="https://railstutorial.jp/#screencast">screencast</a>
 to teach web development with
 <a href="http://rubyonrails.org/">Ruby on Rails</a>.
 This is the sample application for the tutorial.
</p>
----------------------------

ここでテストする

rails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 9866
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 13540
# Running:
...
Finished in 0.353501s, 8.4865 runs/s, 16.9731 assertions/s.
3 runs, 6 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

コンタクトページを作成してみる

コンタクトのerbを追加するコマンドは下記の通り
touch app/views/static_pages/contact.html.erb

コンタクトのerbコードは下記の通り

Contactページで使うコード
app/views/static_pages/contact.html.erb
----------------------------
<% provide(:title, "Contact") %>
<h1>Contact</h1>
<p>
 Contact the Ruby on Rails Tutorial about the sample app at the
 <a href="https://railstutorial.jp/contact">contact page</a>.
</p>
----------------------------

備忘録に残したAboutの追加手順を真似して
rails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 10739
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 15391
# Running:
....
Finished in 0.331781s, 12.0561 runs/s, 24.1123 assertions/s.
4 runs, 8 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

イイネ!

・3 4 4 ルーティングの設定


rootを変更しておく
root 'application#hello'
から
root 'static_pages#home'
にする

演習をやってみる

演習1
rootに対するテストコードを書いてみて

演習2
rootを変更しないとテストが失敗するか確認してみて


rootルーティングに対するテスト green
test/controllers/static_pages_controller_test.rb
----------------------------
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
 test "should get root" do
   get root_url
   assert_response :success
 end
 
 test "should get home" do
   get static_pages_home_url
   assert_response :success
 end
 test "should get help" do
   get static_pages_help_url
   assert_response :success
 end
 test "should get about" do
   get static_pages_about_url
   assert_response :success
 end
end
----------------------------

そしてrails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 11284
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 14822
# Running:
.....
Finished in 0.368737s, 13.5598 runs/s, 24.4077 assertions/s.
5 runs, 9 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

rootルーティングをコメントアウトしてテストを失敗させる red
config/routes.rb
----------------------------
Rails.application.routes.draw do
#   root 'static_pages#home'
 get  'static_pages/home'
 get  'static_pages/help'
 get  'static_pages/about'
end
----------------------------

そしてrails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 11346
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 63393
# Running:
E....
Finished in 0.337619s, 14.8096 runs/s, 23.6954 assertions/s.
 1) Error:
StaticPagesControllerTest#test_should_get_root:
NameError: undefined local variable or method `root_url' for #<StaticPagesControllerTest:0x00007ff88cd15538>
   test/controllers/static_pages_controller_test.rb:10:in `block in <class:StaticPagesControllerTest>'
5 runs, 8 assertions, 0 failures, 1 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

またコメント外してrails test

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ rails test
Running via Spring preloader in process 11392
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Run options: --seed 56066
# Running:
.....
Finished in 0.373158s, 13.3992 runs/s, 24.1185 assertions/s.
5 runs, 9 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------


・3 5 最後に


手順無視する

static-pagesにpushしておこう
git add -A
git commit -m "Finish static pages"
git push -u origin static-pages

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ git add -A
ec2-user:~/environment/sample_app (static-pages) $ git commit -m "Finish static pages"
[static-pages 8a88bae] Finish static pages
8 files changed, 81 insertions(+), 20 deletions(-)
rewrite app/views/layouts/application.html.erb (67%)
create mode 100644 app/views/static_pages/about.html.erb
create mode 100644 app/views/static_pages/contact.html.erb
ec2-user:~/environment/sample_app (static-pages) $ git push -u origin static-pages
Counting objects: 18, done.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 2.14 KiB | 547.00 KiB/s, done.
Total 18 (delta 8), reused 0 (delta 0)
remote: 
remote: Create pull request for static-pages:
remote:   https://bitbucket.org/********/sample_app/pull-requests/new?source=static-pages&t=1
remote: 
To bitbucket.org:********/sample_app
  5829d92..8a88bae  static-pages -> static-pages
Branch static-pages set up to track remote branch static-pages from origin.
ec2-user:~/environment/sample_app (static-pages) $ 
ec2-user:~/environment/sample_app (static-pages) $ 
----------------------------

そしてmasterにマージしよう
git checkout master
git merge static-pages

ログ
----------------------------
ec2-user:~/environment/sample_app (static-pages) $ git checkout master
Switched to branch 'master'
ec2-user:~/environment/sample_app (master) $ git merge static-pages
Updating 4f35601..8a88bae
Fast-forward
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
.../javascripts/static_pages.coffee       |  3 ++
app/assets/stylesheets/static_pages.scss  |  3 ++
.../static_pages_controller.rb            | 13 ++++++
app/helpers/static_pages_helper.rb        |  2 +
app/views/layouts/application.html.erb    | 11 ++---
app/views/static_pages/about.html.erb     | 10 +++++
app/views/static_pages/contact.html.erb   |  6 +++
app/views/static_pages/help.html.erb      |  8 ++++
app/views/static_pages/home.html.erb      |  7 +++
config/routes.rb                          | 10 ++++-
.../static_pages_controller_test.rb       | 37 ++++++++++++++++
11 files changed, 104 insertions(+), 6 deletions(-)
create mode 100644 app/assets/javascripts/static_pages.coffee
create mode 100644 app/assets/stylesheets/static_pages.scss
create mode 100644 app/controllers/static_pages_controller.rb
create mode 100644 app/helpers/static_pages_helper.rb
create mode 100644 app/views/static_pages/about.html.erb
create mode 100644 app/views/static_pages/contact.html.erb
create mode 100644 app/views/static_pages/help.html.erb
create mode 100644 app/views/static_pages/home.html.erb
create mode 100644 test/controllers/static_pages_controller_test.rb
ec2-user:~/environment/sample_app (master) $ 
----------------------------


この時点でBitbucketのmasterも書き換わっているはずなので
masterをpushする操作は必要ない

Herokuにもプッシュしよう
git push heroku master

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ git push heroku master
Counting objects: 39, done.
Compressing objects: 100% (30/30), done.
Writing objects: 100% (39/39), 4.12 KiB | 1.03 MiB/s, done.
Total 39 (delta 14), reused 33 (delta 8)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.5.7
remote: -----> Vendoring libpq 5.12.1
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Installing dependencies using bundler 1.17.3
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Using rake 13.0.1
remote:        Using concurrent-ruby 1.1.5
remote:        Using i18n 1.7.0
remote:        Using minitest 5.10.3
remote:        Using thread_safe 0.3.6
remote:        Using tzinfo 1.2.6
remote:        Using activesupport 5.1.6
remote:        Using builder 3.2.4
remote:        Using erubi 1.9.0
remote:        Using mini_portile2 2.4.0
remote:        Using nokogiri 1.10.7
remote:        Using rails-dom-testing 2.0.3
remote:        Using crass 1.0.5
remote:        Using loofah 2.4.0
remote:        Using rails-html-sanitizer 1.3.0
remote:        Using actionview 5.1.6
remote:        Using rack 2.0.8
remote:        Using rack-test 1.1.0
remote:        Using actionpack 5.1.6
remote:        Using nio4r 2.5.2
remote:        Using websocket-extensions 0.1.4
remote:        Using websocket-driver 0.6.5
remote:        Using actioncable 5.1.6
remote:        Using globalid 0.4.2
remote:        Using activejob 5.1.6
remote:        Using mini_mime 1.0.2
remote:        Using mail 2.7.1
remote:        Using actionmailer 5.1.6
remote:        Using activemodel 5.1.6
remote:        Using arel 8.0.0
remote:        Using activerecord 5.1.6
remote:        Using bundler 1.17.3
remote:        Using coffee-script-source 1.12.2
remote:        Using execjs 2.7.0
remote:        Using coffee-script 2.4.1
remote:        Using method_source 0.9.2
remote:        Using thor 1.0.1
remote:        Using railties 5.1.6
remote:        Using coffee-rails 4.2.2
remote:        Using ffi 1.11.3
remote:        Using multi_json 1.14.1
remote:        Using jbuilder 2.7.0
remote:        Using jquery-rails 4.3.1
remote:        Using pg 0.20.0
remote:        Using puma 3.9.1
remote:        Using sprockets 3.7.2
remote:        Using sprockets-rails 3.2.1
remote:        Using rails 5.1.6
remote:        Using rb-fsevent 0.10.3
remote:        Using rb-inotify 0.10.1
remote:        Using sass-listen 4.0.0
remote:        Using sass 3.7.4
remote:        Using tilt 2.0.10
remote:        Using sass-rails 5.0.6
remote:        Using turbolinks-source 5.2.0
remote:        Using turbolinks 5.0.1
remote:        Using uglifier 3.2.0
remote:        Bundle complete! 20 Gemfile dependencies, 57 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Bundle completed (0.41s)
remote:        Cleaning up the bundler cache.
remote: -----> Installing node-v10.15.3-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        I, [2019-12-29T18:21:44.862332 #326]  INFO -- : Writing /tmp/build_5ceddcb16337980fcfab630d9dc5bf9b/public/assets/application-86a3fd3b1e217ceb8f2069261313e734793e5074b3f462c54a813438e80e7839.js
remote:        I, [2019-12-29T18:21:44.863725 #326]  INFO -- : Writing /tmp/build_5ceddcb16337980fcfab630d9dc5bf9b/public/assets/application-86a3fd3b1e217ceb8f2069261313e734793e5074b3f462c54a813438e80e7839.js.gz
remote:        Asset precompilation completed (3.15s)
remote:        Cleaning assets
remote:        Running: rake assets:clean
remote: -----> Detecting rails configuration
remote: 
remote: ###### WARNING:
remote: 
remote:        You have not declared a Ruby version in your Gemfile.
remote:        To set your Ruby version add this line to your Gemfile:
remote:        ruby '2.5.7'
remote:        # See https://devcenter.heroku.com/articles/ruby-versions for more information.
remote: 
remote: 
remote: ###### WARNING:
remote: 
remote:        No Procfile detected, using the default web server.
remote:        We recommend explicitly declaring how to boot your server process via a Procfile.
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote: 
remote: 
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> console, rake, web
remote: 
remote: -----> Compressing...
remote:        Done: 61.4M
remote: -----> Launching...
remote:        Released v7
remote:        https://jun-killer-rails3.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/jun-killer-rails3.git
  4f35601..8a88bae  master -> master
ec2-user:~/environment/sample_app (master) $ 
----------------------------

できた!
https://jun-killer-rails3.herokuapp.com/

あ、herokuにpushする前にrails testを実行する習慣を身に着けるといいみたい
確かに仕事する時とかはそういう確認は必要だよね
今回は実行し忘れた
まあ次から気をつけよ

・3 5 1 本章のまとめ


新しいrailsアプリケーションは3回作った
gemのインストール、リモートリポジトリのプッシュ、production環境も行った
コントローラを新規作成するためのrailsコマンドはrails generate controller controllerName アクション名
新しいルーティングはconfig/routes.rb
railsビューでは静的HTMLのほかにERB(埋め込みRuby:EmbeddedRuby)が使える
常に自動化テストを使って新機能開発を進めることで、自信を持ってリファクタリングでき、回帰バグも素早くキャッチできるようになる
テスト駆動開発では「RED・GREEN・REFACTOR」サイクルを繰り返す
Railsのレイアウトでは、アプリケーションのページの共通部分をテンプレートに置くことでコードの重複を解決することができる

・3 6 高度なセットアップ


テスト用設定する
とりあえずmasterにブランチを変えておこう
cd ~/environment/sample_app
git branch master

・3 6 1 minitest reporters


red や green を表示できるようにする
test/test_helper.rb
----------------------------
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
 # Setup all fixtures in test/fixtures/*.yml for all tests
 # in alphabetical order.
 fixtures :all
 # Add more helper methods to be used by all tests here...
end
----------------------------

これでIDE上の表示が赤から緑に変わるらしい
試しにrails testを実行してみょ!

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ rails test
Running via Spring preloader in process 4167
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Started with run options --seed 28818
                                                                

 5/5: [====================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.44287s
5 tests, 9 assertions, 0 failures, 0 errors, 0 skips
ec2-user:~/environment/sample_app (master) $ rails test
Running via Spring preloader in process 4231
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Started with run options --seed 47620
ERROR["test_should_get_root", StaticPagesControllerTest, 0.37471539300003087]
test_should_get_root#StaticPagesControllerTest (0.38s)
NameError:         NameError: undefined local variable or method `root_url' for #<StaticPagesControllerTest:0x0000000004dede20>
           test/controllers/static_pages_controller_test.rb:10:in `block in <class:StaticPagesControllerTest>'
 5/5: [====================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.40507s
5 tests, 8 assertions, 0 failures, 1 errors, 0 skips
ec2-user:~/environment/sample_app (master) $ 
----------------------------

IDE上では「文字」が緑色になったり赤色になったりした!
これは今後便利になるね!

・3 6 2 Guardによるテストの自動化


ファイルを変更したときにいちいちrails test実行するの面倒だよねって言われてる
(えっCliborにコマンド登録しちゃったよ。まあいいか)

home.html.erbファイルが変更されたらstatic_pages_controller_test.rbを自動的に実行する
といったことをしてくれる

使えるようにするには以下のコマンドだけでok
bundle exec guard init

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ bundle exec guard init
Deprecation warning: Expected string default value for '--listen-on'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
04:10:34 - INFO - Writing new Guardfile to /home/ec2-user/environment/sample_app/Guardfile
04:10:34 - INFO - minitest guard added to Guardfile, feel free to edit it
ec2-user:~/environment/sample_app (master) $ 
----------------------------

cloud9を使ってる人は、Guardの通知を有効にするためにtmuxが必要
以下のコマンドでok
sudo yum install -y tmux

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ sudo yum install -y tmux
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                                 | 2.1 kB     00:00     
amzn-updates                              | 2.5 kB     00:00     
1067 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package tmux.x86_64 0:1.8-4.12.amzn1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================
Package   Arch        Version              Repository      Size
=================================================================
Installing:
tmux      x86_64      1.8-4.12.amzn1       amzn-main      254 k
Transaction Summary
=================================================================
Install  1 Package
Total download size: 254 k
Installed size: 543 k
Downloading packages:
tmux-1.8-4.12.amzn1.x86_64.rpm              | 254 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : tmux-1.8-4.12.amzn1.x86_64                    1/1 
 Verifying  : tmux-1.8-4.12.amzn1.x86_64                    1/1 
Installed:
 tmux.x86_64 0:1.8-4.12.amzn1                                   
Complete!
ec2-user:~/environment/sample_app (master) $ 
----------------------------

んで、以下のようにGuardfileを変更


Guardfile
----------------------------
# Guardのマッチング規則を定義
guard :minitest, spring: "bin/rails test", all_on_start: false do
 watch(%r{^test/(.*)/?(.*)_test\.rb$})
 watch('test/test_helper.rb') { 'test' }
 watch('config/routes.rb')    { integration_tests }
 watch(%r{^app/models/(.*?)\.rb$}) do |matches|
   "test/models/#{matches[1]}_test.rb"
 end
 watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches|
   resource_tests(matches[1])
 end
 watch(%r{^app/views/([^/]*?)/.*\.html\.erb$}) do |matches|
   ["test/controllers/#{matches[1]}_controller_test.rb"] +
   integration_tests(matches[1])
 end
 watch(%r{^app/helpers/(.*?)_helper\.rb$}) do |matches|
   integration_tests(matches[1])
 end
 watch('app/views/layouts/application.html.erb') do
   'test/integration/site_layout_test.rb'
 end
 watch('app/helpers/sessions_helper.rb') do
   integration_tests << 'test/helpers/sessions_helper_test.rb'
 end
 watch('app/controllers/sessions_controller.rb') do
   ['test/controllers/sessions_controller_test.rb',
    'test/integration/users_login_test.rb']
 end
 watch('app/controllers/account_activations_controller.rb') do
   'test/integration/users_signup_test.rb'
 end
 watch(%r{app/views/users/*}) do
   resource_tests('users') +
   ['test/integration/microposts_interface_test.rb']
 end
end
# 与えられたリソースに対応する統合テストを返す
def integration_tests(resource = :all)
 if resource == :all
   Dir["test/integration/*"]  else
   Dir["test/integration/#{resource}_*.rb"]
 end
end
# 与えられたリソースに対応するコントローラのテストを返す
def controller_test(resource)
 "test/controllers/#{resource}_controller_test.rb"
end
# 与えられたリソースに対応するすべてのテストを返す
def resource_tests(resource)
 integration_tests(resource) << controller_test(resource)
end
----------------------------

一番最初の行で、GuardからSpringサーバーを使って読み込み時間を短縮してる
(springはrailsの機能の1つ)

Guard使用時のSpringとGitの競合を防ぐには、.gitignoreファイルにspring/を追加する
ただし手順は以下の通り
1.ナビゲーションパネルの右上にある歯車アイコンをポチ
2.show hidden filesを選択して非表示ファイルを表示
3..gitignoreを開いて以下を末尾に追加
# Ignore Spring files.
/spring/*.pid


ログ
----------------------------
ec2-user:~/environment $ cd ~/environment/sample_app
ec2-user:~/environment/sample_app (master) $ bundle exec guard
Deprecation warning: Expected string default value for '--listen-on'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
04:36:45 - INFO - Guard::Minitest 2.4.4 is running, with Minitest::Unit 5.10.3!
04:36:45 - INFO - Guard is now watching at '/home/ec2-user/environment/sample_app'
/home/ec2-user/.rvm/gems/ruby-2.6.3/gems/guard-2.13.0/lib/guard/jobs/pry_wrapper.rb:279: warning: method Pry#input_array is deprecated. Use Pry#input_ring instead
[1] guard(main)> 
04:36:47 - INFO - Run all
04:36:47 - INFO - Running: all tests
Running via Spring preloader in process 6910
/home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded.
Started with run options --seed 46831
 5/5: [====================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.41825s
5 tests, 9 assertions, 0 failures, 0 errors, 0 skips

/home/ec2-user/.rvm/gems/ruby-2.6.3/gems/guard-2.13.0/lib/guard/jobs/pry_wrapper.rb:279: warning: method Pry#input_array is deprecated. Use Pry#input_ring instead
[1] guard(main)> 
----------------------------

Guardを終了するときはCtrl+D


springが悪さをして重くなることがあるので、必要に応じてSpringをkillするといい
下記のコマンドで、システム上で動いているすべてのプロセスが確認可能
ps aux
プロセスの種類まで指定する場合は下記のコマンド
ps aux | grep spring

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ ps aux | grep springec2-user  4158  0.0  2.3 500876 23952 pts/1    Sl   03:58   0:00 

                                                                spring server | sample_app | started 30 mins ago                                         
ec2-user  4250  0.1  8.1 672308 82204 ?        Ssl  03:59   0:02 spring app    | sample_app | started 29 mins ago | test mode                                                                                                            
ec2-user  5202  0.0  0.2 110520  2200 pts/1    S+   04:29   0:00 grep --color=auto spring
ec2-user:~/environment/sample_app (master) $ 
----------------------------

springの一括キルは以下のコマンド
spring stop

それでも効かない場合は以下のコマンドでキル
pkill -15 -f spring

Guardの話に戻って、下記のコマンドを別ターミナルで実行
bundle exec guard

そうすると、ファイルの修正に反応してrails testしてくれるっぽい
ちなみに失敗してるので深追いせずにここら辺で終了

ログ
----------------------------
ec2-user:~/environment/sample_app (master) $ bundle exec guard
Deprecation warning: Expected string default value for '--listen-on'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
05:25:06 - ERROR - No Guard plugins found in Guardfile, please add at least one.
05:25:07 - INFO - Guard is now watching at '/home/ec2-user/environment/sample_app'
/home/ec2-user/.rvm/gems/ruby-2.6.3/gems/guard-2.13.0/lib/guard/jobs/pry_wrapper.rb:279: warning: method Pry#input_array is deprecated. Use Pry#input_ring instead
[1] guard(main)> 
05:25:08 - INFO - Run all
/home/ec2-user/.rvm/gems/ruby-2.6.3/gems/guard-2.13.0/lib/guard/jobs/pry_wrapper.rb:279: warning: method Pry#input_array is deprecated. Use Pry#input_ring instead
[1] guard(main)> 
----------------------------


専門用語


TDD
Test テスト
Driven 駆動
Development 開発

この記事が気に入ったらサポートをしてみませんか?