RSpecでテストケースを書いていたときの話。
expect(hoge_date).to eq Date.new(2018,01,01) ・・・ expect(hoge_date).to eq Date.new(2018,09,01)
としたとき、
Date.new(2018,09,01) SyntaxError: (eval):2: Invalid octal digit Date.new(2018,09,01)
のような事を言われてしまう。
09
の部分が問題で、Rubyでは0始まりの数字はデフォルトで8進数になるから。
知らなかったのだが、Shellでも同じなため割と一般的なのか?
ちなみに
expect(hoge_date).to eq Date.new(2018,01,01) ・・・ expect(hoge_date).to eq Date.new(2018,09,01)
は
expect(hoge_date).to eq Date.new(2018,01,01) ・・・ expect(hoge_date).to eq Date.new(2018, 9,01)
こう書きました😇