Just do IT

思うは招く

2021-01-01から1年間の記事一覧

RubyMine で RSpec を実行して you have already activated spring 2.1.1〜 エラー

問題 RubyMine 内で RSpec を実行すると以下のエラーが出る。 You have already activated spring 2.1.1, but your Gemfile requires spring 2.1.0.~ しかし、ターミナルからRSpecを実行してもエラーは出ない。 解決 バンドラーをアップデートすると解決した…

GitHub で PR の diff を2つに分割して見やすくする

これを 分割してない エディタで見るような感じでこうしたい。 分割した PR上にある設定マークから「split」を選ぶ。

ディレクトリ間を一瞬で移動する z コマンドを zsh に入れる方法

ディレクトリを爆速で移動できるzコマンドを先輩に教えていただいた。 どんなものかというと、普通のcdコマンドならこう。 username ~ $ cd ~/dev/rails username ~/dev/rails zコマンドならたったこれだけで移動できる。 username ~ $ z rails username ~/d…

homebrew update をすると Error: homebrew-core is a shallow clone

問題 $ brew update をしたら以下のエラーが出た。 Error: homebrew-core is a shallow clone. To `brew update` first run: git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow This restriction has been made on GitHu…

Everyday Rails でセットアップできない問題を解決

問題 everydayrails/everydayrails-rspec-2017: Sample source for the 2017 edition of Everyday Rails Testing with RSpec. サンプルコードをGitHubからクローンして、bundleコマンドを打つとこんなエラーが出る。 An error occurred while installing ffi…

RSpec 時刻制御系テストには travel_to が使いやすい

rails_helper.rbにtravel_toを使う設定をする RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers end 例 it "3日後であること" do travel_to Date.new(2020, 1, 1) + 3.day do expect(Date.current).to eq '2020-01-04'.to_d…

PG::ConnectionBad - could not connect to server: Connection refused エラーを解決

直面したエラー rails sでサーバーを起動しようとしたら、こんなエラー画面が出てPostgreSQLが起動できない。 PG::ConnectionBad - could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP…

Rails before_xxx で throw(:abort) をする意味

before_save とは オブジェクトがsaveされる前に発動されるコールバック 引数としてメソッドが渡された場合、それをクリアしないとsaveされない バリデーションの一種 Rails 4 での仕様 before_xxx では、false を返した場合のみ保存処理が停止していた nil …