0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

結合テスト ベーシック認証を通す

Posted at

参考:@taka_no_okapi

https://qiita.com/takashimayuusuke7316/items/937dd4d52220bcbe3073

メソッド: Capybara.current_session

Capybara - Poltergeistで動いているサーバのhostとポートを知る
サーバ:Capybara.current_session.server.host
ポート:Capybara.current_session.server.port

@ms2sato
https://qiita.com/ms2sato/items/ca288acb070bae87c80f

def basic_pass(path)
  username = ENV["BASIC_AUTH_USER"]
  password = ENV["BASIC_AUTH_PASSWORD"]
  visit "http://#{username}:#{password}@#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}#{path}"
end

# 省略
RSpec.describe "ユーザー新規登録", type: :system do
  before do
    @user = FactoryBot.build(:user)
  end
  context 'ユーザー新規登録ができるとき' do
    it '正しい情報を入力すればユーザー新規登録ができてトップページへ移動する'do
    # トップページへ移動する
    basic_pass root_path
    visit root_path
# 省略
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?