LoginSignup
4
5

More than 5 years have passed since last update.

[WIP] Hanamiの環境構築(Herokuへのデプロイ、テスト実行環境のセットアップ)

Posted at

最近知ったRuby製のフレームワーク「Hanami」に興味が湧いたので簡単なツールを作成してみる。リポジトリは一旦Bitbucketに作成して進める。

Herokuへのデプロイ

参考)Hanamiで静的なWebページを作って、Herokuへデプロイしてみた

# インストールと初期設定
gem install hanami
hanami new project_name
cd project_root_dir
bundle install --path=vendor/bundle

# サーバ起動
bundle exec hanami server -p 3000

# gem を幾つか追加
bundle add sqlite3 -g "development, test"
bundle add wdm -g "development, test"
bundle add listen -g "development,test"
bundle add puma -g "production"
bundle add pg -g "production"

# herokuにpush
heroku login
heroku apps:create app_name
git push heroku master
heroku run bundle exec hanami db migrate

herokuの不具合対応

デフォルトで参照している下記2つの環境変数を設定してやる必要があった
一旦下記の内容で仮登録しておく

SMTP_HOST=localhost
SMTP_PORT=25

テスティング

参考)RubyのHanamiチュートリアルをやってみた

# test環境用のDBのセットアップ
HANAMI_ENV=test bundle exec hanami db prepare

一部自動生成されるテストコードのマッチャーの書き方がminitestの記法になっているので、適宜Rspecの書き方に修正する。
例えば下記のように。

-    response[0].must_equal 200
+    expect(response[0]).to eq 200

CI環境の設定

参考)Heroku CIを使ってみた

Githubにリポジトリが存在する必要があったので今回は割愛。

フロントエンド環境の設定

参考) 2018-03-25
Hanami + Vue.jsでTODOアプリを作った

詳細は後日追記

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5