LoginSignup
0
0

More than 1 year has passed since last update.

画面要素出し分けのABテスト時のRSpec(Capybara)の記述

Last updated at Posted at 2022-04-24

ABテストで画面要素の出し分け時、画面表示のspecを書く際の記述を思い出すのに時間がかかったのでメモ

show.html.slim
- case @ab_test_pattern
- when 'existing_question'
  - f.select :do_you_like_mushroom_mountain, id: 'mushroom_mountain'
- when 'new_question'
  - f.select :do_you_like_bamboo_grove,      id: 'bamboo_grove'
show_spec.rb
# TODO: ABテスト決着後、条件分岐削除
# ref: https://github.com/xxx/issues/yyy
it 'should have correct fields' do
  if page.all('#mushroom_mountain').empty?
    expect(page).to have_selector 'select#bamboo_grove'
  else
    expect(page).to have_selector 'select#mushroom_mountain'
  end
end

決着がついた後の条件分岐削除は大体忘れ去られるので、負債にしないためにもアノテーションコメントを入れておくのがbetter.
split(ABテスト用のGem)の場合ダッシュボードで勝敗決定することができますが、勝敗決定をトリガーにしてコード修正する仕組みがあれば便利そうだなってふと思った

0
0
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
0
0