タグ

2019年7月29日のブックマーク (1件)

  • RSpecのshared_examplesとかshared_examples_forとか - Qiita

    Ruby初心者である私が、いろいろと奮闘している途中で学んだことその2。 RSpecを書いている時に、共通の内容があるときはshared_examplesを使うとよい。 書き方はこんな感じ。 shared_examples_for 'Some Example' do it 'should be something' do # Some Tests here end end describe 'なにかのとき' do context '何かの場合' do it_behaves_like 'Some Example' end end 書いていてよくわからなかったのが、調べているとこんな風にいろんな書き方があった。 shared_examples shared_examples_for shared_context なんの違いだろうと思って確認したが、あまり情報が見つからず、下記のコード内で発見。

    RSpecのshared_examplesとかshared_examples_forとか - Qiita