From ab2203d69e79802ad2d82a22fc4a842912016271 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Fri, 16 Apr 2021 15:44:32 +0900 Subject: [PATCH 01/15] Add spec --- spec/factories/users.rb | 9 ++ spec/rails_helper.rb | 1 + spec/spec_helper.rb | 4 +- spec/system/posts_spec.rb | 90 +++++++++++++++++ spec/system/user_sessions_spec.rb | 163 ++++++++++++++++++++++++++++++ spec/system/users_spec.rb | 113 +++++++++++++++++++++ 6 files changed, 378 insertions(+), 2 deletions(-) create mode 100644 spec/factories/users.rb create mode 100644 spec/system/posts_spec.rb create mode 100644 spec/system/user_sessions_spec.rb create mode 100644 spec/system/users_spec.rb diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 0000000..054b03c --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,9 @@ +FactoryBot.define do + factory :user do + email { Faker::Internet.unique.email } + password { 'password' } + password_confirmation { 'password' } + first_name { Faker::Name.first_name } + last_name { Faker::Name.last_name } + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 00345af..7fa16d7 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -61,4 +61,5 @@ config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") + config.include FactoryBot::Syntax::Methods end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce33d66..f83124b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -46,14 +46,14 @@ # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. -=begin + # This allows you to limit a spec run to individual examples or groups # you care about by tagging them with `:focus` metadata. When nothing # is tagged with `:focus`, all examples get run. RSpec also provides # aliases for `it`, `describe`, and `context` that include `:focus` # metadata: `fit`, `fdescribe` and `fcontext`, respectively. config.filter_run_when_matching :focus - +=begin # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. We recommend # you configure your source control system to ignore this file. diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb new file mode 100644 index 0000000..7665f5b --- /dev/null +++ b/spec/system/posts_spec.rb @@ -0,0 +1,90 @@ +require 'rails_helper' + +RSpec.describe "Posts", type: :system do + describe '確認観点4:投稿機能' do + let!(:user){ create(:user) } + let(:another_user){ create(:user, email: 'another_user@example.com') } + + before do + # 確認対象の画面に移動 + visit '/login' + + # labelの存在確認 + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # ログイン用ボタンの存在確認 + expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + + # ユーザーログイン処理 + fill_in 'Email', with: user.email + fill_in 'Password', with: 'password' + click_button 'ログイン' + end + + it '4-1:自分の投稿を編集することができる' do + create(:post, user: user) + + # 確認対象の画面に移動 + visit '/posts' + + # 編集リンクの存在確認 + expect(page).to have_content('Edit'), '自分の投稿に編集用のリンクが表示されているかを確認してください' + click_on 'Edit' + + # labelの存在確認 + expect(page).to have_content('Title'), 'Title というラベルが表示されていることを確認してください' + expect(page).to have_content('Content'), 'Content というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='post_title']"), 'Title というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='post_content']"), 'Content というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # 更新ボタンの存在確認 + expect(page).to have_button('Update Post'), '編集画面に更新用のボタンが表示されているかを確認してください' + + # 投稿編集と更新処理 + fill_in 'Title', with: 'edited_title' + fill_in 'Content', with: 'edited_content' + click_on 'Update Post' + + expect(page).to have_content('Post was successfully updated.'), '投稿編集成功のメッセージが表示されていません' + expect(current_path).to eq(post_path(Post.find_by(title: 'edited_title'))), '投稿編集後に投稿詳細画面に遷移できていません' + expect(page).to have_content('edited_title'), '編集した投稿のタイトルが表示されていません' + expect(page).to have_content('edited_content'), '編集した投稿の本文が表示されていません' + end + + it '4-2:自分の投稿を削除することができる' do + create(:post, user: user) + + # 確認対象の画面に移動 + visit '/posts' + + # 削除リンクの存在確認 + expect(page).to have_content('Destroy'), '自分の投稿に削除用のリンクが表示されているかを確認してください' + page.accept_confirm { click_on 'Destroy' } + expect(page).to have_content('Post was successfully destroyed.'), '投稿削除成功のメッセージが表示されていません' + expect(current_path).to eq(posts_path), '投稿編集後に投稿一覧画面に遷移できていません' + end + + it '4-3:他人の投稿に編集リンクが表示されない' do + create(:post, user: another_user) + + # 確認対象の画面に移動 + visit '/posts' + expect(page).not_to have_link('Edit'), '他人の投稿に編集リンクが表示されています' + end + + it '4-4:他人の投稿に削除リンクが表示されない' do + create(:post, user: another_user) + + # 確認対象の画面に移動 + visit '/posts' + expect(page).not_to have_link('Destroy'), '他人の投稿に削除リンクが表示されています' + end + end +end diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb new file mode 100644 index 0000000..6c268fd --- /dev/null +++ b/spec/system/user_sessions_spec.rb @@ -0,0 +1,163 @@ + +require 'rails_helper' + +RSpec.describe "UserSessions", type: :system do + describe '確認観点2:ユーザーログイン' do + it '2-1:ユーザーのログインができる' do + # テストデータの用意 + user = create(:user) # describe使わないので、let!を使わずに記載 + + # 確認対象の画面に移動 + visit '/login' + + # labelの存在確認 + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # ログイン用ボタンの存在確認 + expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + + # ユーザーログイン処理 + fill_in 'Email', with: user.email + fill_in 'Password', with: 'password' + click_button 'ログイン' + + # 処理結果の確認 + expect(page).to have_content('Login successful.'), 'ログイン成功のメッセージが表示されていません' + expect(current_path).to eq(posts_path), 'ログイン後に投稿一覧画面に遷移できていません' + end + + it '2-2:入力項目が不足している場合にログインができない' do + # テストデータの用意 + user = create(:user) # describe使わないので、let!を使わずに記載 + + # 確認対象の画面に移動 + visit '/login' + + # labelの存在確認 + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # ログイン用ボタンの存在確認 + expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + + # ユーザーログイン処理 + fill_in 'Email', with: nil + fill_in 'Password', with: nil + click_button 'ログイン' + + # 処理結果の確認 + expect(page).not_to have_content('Login successful.'), 'ログイン成功のメッセージが表示されています' + expect(page).to have_content('Login failed.'), 'ログイン失敗のメッセージが表示されていません' + end + + it '2-3:存在しないユーザーでログインができない' do + # テストデータの用意 + user = create(:user) # describe使わないので、let!を使わずに記載 + + # 確認対象の画面に移動 + visit '/login' + + # labelの存在確認 + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # ログイン用ボタンの存在確認 + expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + + # ユーザーログイン処理 + fill_in 'Email', with: 'another_user@example.com' + fill_in 'Password', with: 'password' + click_button 'ログイン' + + # 処理結果の確認 + expect(page).not_to have_content('Login successful.'), 'ログイン成功のメッセージが表示されています' + expect(page).to have_content('Login failed.'), 'ログイン失敗のメッセージが表示されていません' + end + + it '2-4:パスワードが間違っている場合にログインができない' do + # テストデータの用意 + user = create(:user) # describe使わないので、let!を使わずに記載 + + # 確認対象の画面に移動 + visit '/login' + + # labelの存在確認 + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # ログイン用ボタンの存在確認 + expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + + # ユーザーログイン処理 + fill_in 'Email', with: user.email + fill_in 'Password', with: 'wrong_password' + click_button 'ログイン' + + # 処理結果の確認 + expect(page).not_to have_content('Login successful.'), 'ログイン成功のメッセージが表示されています' + expect(page).to have_content('Login failed.'), 'ログイン失敗のメッセージが表示されていません' + end + end + + describe '確認観点3:ユーザーログアウト' do + it '3-1:ユーザーのログアウトができる' do + # テストデータの用意 + user = create(:user) # describe使わないので、let!を使わずに記載 + + # 確認対象の画面に移動 + visit '/login' + + # labelの存在確認 + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # ログイン用ボタンの存在確認 + expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + + # ユーザーログイン処理 + fill_in 'Email', with: user.email + fill_in 'Password', with: 'password' + click_button 'ログイン' + + # ユーザーログアウト処理 + find('#header-profile').click + + # ログアウト用ボタンの存在確認 + expect(page).to have_link('ログアウト'), 'ログアウトのボタンが表示されていることを確認してください' + + click_on 'ログアウト' + + # 処理結果の確認 + expect(page).to have_content('Logout successful.'), 'ログアウト成功のメッセージが表示されていません' + end + + it '3-2:ログインしていない場合、ユーザーのログアウトリンクが表示されない' do + # 確認対象の画面に移動 + visit '/login' + + # 処理結果の確認 + expect(page).not_to have_link('ログアウト'), 'ログアウトリンクが表示されています' + end + end +end diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb new file mode 100644 index 0000000..b9af20f --- /dev/null +++ b/spec/system/users_spec.rb @@ -0,0 +1,113 @@ + +require 'rails_helper' + +RSpec.describe "Users", type: :system do + let(:user) { create(:user) } + + describe '確認観点1:ユーザー新規登録' do + it '1-1:ユーザーの新規登録ができる' do + # 確認対象の画面に移動 + visit 'users/new' + + # labelの存在確認 + expect(page).to have_content('Last name'), 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_content('First name'), 'First name というラベルが表示されていることを確認してください' + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_content('Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_first_name']"), 'First name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_password_confirmation']"), 'Password confirmation というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # 登録ボタンの存在確認 + expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' + + # ユーザー新規登録処理 + fill_in 'Last name', with: 'test01' + fill_in 'First name', with: 'test01' + fill_in 'Email', with: 'test01@example.com' + fill_in 'Password', with: 'password' + fill_in 'Password confirmation', with: 'password' + click_on '登録' + + # 処理結果の確認 + expect(page).to have_content('User was successfully created.'), 'ユーザー作成のメッセージが表示されていません' + expect(current_path).to eq(login_path), 'ユーザー作成後にログイン画面に遷移できていません' + end + + it '1-2:同じメールアドレスのユーザーは新規登録できない' do + # テストデータの用意 + user = create(:user) # describe使わないので、let!を使わずに記載 + + # 確認対象の画面に移動 + visit 'users/new' + + # labelの存在確認 + expect(page).to have_content('Last name'), 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_content('First name'), 'First name というラベルが表示されていることを確認してください' + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_content('Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_first_name']"), 'First name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_password_confirmation']"), 'Password confirmation というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # 登録ボタンの存在確認 + expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' + + # ユーザー新規登録処理 + fill_in 'Last name', with: 'test01' + fill_in 'First name', with: 'test01' + fill_in 'Email', with: user.email + fill_in 'Password', with: 'password' + fill_in 'Password confirmation', with: 'password' + click_on '登録' + + # 処理結果の確認 + expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成のメッセージが表示されています' + expect(page).to have_content('User creation failed.'), 'ユーザー作成失敗のメッセージが表示されていません' + end + + it '1-3:入力項目が不足している場合に新規登録ができない' do + # 確認対象の画面に移動 + visit 'users/new' + + # labelの存在確認 + expect(page).to have_content('Last name'), 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_content('First name'), 'First name というラベルが表示されていることを確認してください' + expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_content('Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_first_name']"), 'First name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='user_password_confirmation']"), 'Password confirmation というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # 登録ボタンの存在確認 + expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' + + # ユーザー新規登録処理 + fill_in 'Last name', with: nil + fill_in 'First name', with: nil + fill_in 'Email', with: nil + fill_in 'Password', with: nil + fill_in 'Password confirmation', with: nil + click_on '登録' + + # 処理結果の確認 + expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成のメッセージが表示されています' + expect(page).to have_content('User creation failed.'), 'ユーザー作成失敗のメッセージが表示されていません' + end + end +end From 7ff5cae2309758cc9b96965553a6ca4fd3b3aa48 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Mon, 19 Apr 2021 17:53:00 +0900 Subject: [PATCH 02/15] =?UTF-8?q?Fix:=20=E4=B8=8D=E8=A6=81=E3=81=AAemail?= =?UTF-8?q?=E3=81=AE=E6=8C=87=E5=AE=9A=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 7665f5b..02ebf1f 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -3,7 +3,7 @@ RSpec.describe "Posts", type: :system do describe '確認観点4:投稿機能' do let!(:user){ create(:user) } - let(:another_user){ create(:user, email: 'another_user@example.com') } + let(:another_user){ create(:user) } before do # 確認対象の画面に移動 From bdd9a53b1ed71760f52dd5b52854525ca2af3768 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Mon, 19 Apr 2021 22:58:13 +0900 Subject: [PATCH 03/15] =?UTF-8?q?Fix:=20Label=E7=A2=BA=E8=AA=8D=E7=94=A8?= =?UTF-8?q?=E3=83=9E=E3=83=83=E3=83=81=E3=83=A3=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 8 ++++---- spec/system/user_sessions_spec.rb | 20 ++++++++++---------- spec/system/users_spec.rb | 30 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 02ebf1f..7925418 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -10,8 +10,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -37,8 +37,8 @@ click_on 'Edit' # labelの存在確認 - expect(page).to have_content('Title'), 'Title というラベルが表示されていることを確認してください' - expect(page).to have_content('Content'), 'Content というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Title', 'Title というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Content', 'Content というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='post_title']"), 'Title というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index 6c268fd..d92abba 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -11,8 +11,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -39,8 +39,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -67,8 +67,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -95,8 +95,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -125,8 +125,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb index b9af20f..e01498f 100644 --- a/spec/system/users_spec.rb +++ b/spec/system/users_spec.rb @@ -10,11 +10,11 @@ visit 'users/new' # labelの存在確認 - expect(page).to have_content('Last name'), 'Last name というラベルが表示されていることを確認してください' - expect(page).to have_content('First name'), 'First name というラベルが表示されていることを確認してください' - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' - expect(page).to have_content('Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Last name', 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'First name', 'First name というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password confirmation', 'Password confirmation というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -47,11 +47,11 @@ visit 'users/new' # labelの存在確認 - expect(page).to have_content('Last name'), 'Last name というラベルが表示されていることを確認してください' - expect(page).to have_content('First name'), 'First name というラベルが表示されていることを確認してください' - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' - expect(page).to have_content('Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Last name', 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'First name', 'First name というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password confirmation', 'Password confirmation というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -81,11 +81,11 @@ visit 'users/new' # labelの存在確認 - expect(page).to have_content('Last name'), 'Last name というラベルが表示されていることを確認してください' - expect(page).to have_content('First name'), 'First name というラベルが表示されていることを確認してください' - expect(page).to have_content('Email'), 'Email というラベルが表示されていることを確認してください' - expect(page).to have_content('Password'), 'Password というラベルが表示されていることを確認してください' - expect(page).to have_content('Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Last name', 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'First name', 'First name というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector 'label', text: 'Password confirmation', 'Password confirmation というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' From 9e037d53ab740c8f45cf10c8974eab46e0b07554 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Mon, 19 Apr 2021 23:01:26 +0900 Subject: [PATCH 04/15] =?UTF-8?q?Fix:=20path=E3=81=AE=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=81=AF=E6=96=87=E5=AD=97=E5=88=97=E3=81=A7=E8=A1=8C=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 2 +- spec/system/user_sessions_spec.rb | 2 +- spec/system/users_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 7925418..25af648 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -68,7 +68,7 @@ expect(page).to have_content('Destroy'), '自分の投稿に削除用のリンクが表示されているかを確認してください' page.accept_confirm { click_on 'Destroy' } expect(page).to have_content('Post was successfully destroyed.'), '投稿削除成功のメッセージが表示されていません' - expect(current_path).to eq(posts_path), '投稿編集後に投稿一覧画面に遷移できていません' + expect(current_path).to eq('/posts'), '投稿編集後に投稿一覧画面に遷移できていません' end it '4-3:他人の投稿に編集リンクが表示されない' do diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index d92abba..93e785f 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -28,7 +28,7 @@ # 処理結果の確認 expect(page).to have_content('Login successful.'), 'ログイン成功のメッセージが表示されていません' - expect(current_path).to eq(posts_path), 'ログイン後に投稿一覧画面に遷移できていません' + expect(current_path).to eq('/posts'), 'ログイン後に投稿一覧画面に遷移できていません' end it '2-2:入力項目が不足している場合にログインができない' do diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb index e01498f..f973d8d 100644 --- a/spec/system/users_spec.rb +++ b/spec/system/users_spec.rb @@ -36,7 +36,7 @@ # 処理結果の確認 expect(page).to have_content('User was successfully created.'), 'ユーザー作成のメッセージが表示されていません' - expect(current_path).to eq(login_path), 'ユーザー作成後にログイン画面に遷移できていません' + expect(current_path).to eq('/login'), 'ユーザー作成後にログイン画面に遷移できていません' end it '1-2:同じメールアドレスのユーザーは新規登録できない' do From 36e7fea70ad7a5caa8951b40223aa5c6c09cb69a Mon Sep 17 00:00:00 2001 From: yuji91 Date: Mon, 19 Apr 2021 23:26:23 +0900 Subject: [PATCH 05/15] =?UTF-8?q?Fix:=20=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E7=A2=BA=E8=AA=8D=E5=A4=B1=E6=95=97=E6=99=82?= =?UTF-8?q?=E3=81=AE=E8=A1=A8=E7=A4=BA=E6=96=87=E8=A8=80=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 6 +++--- spec/system/user_sessions_spec.rb | 18 +++++++++--------- spec/system/users_spec.rb | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 25af648..01e3247 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -52,7 +52,7 @@ fill_in 'Content', with: 'edited_content' click_on 'Update Post' - expect(page).to have_content('Post was successfully updated.'), '投稿編集成功のメッセージが表示されていません' + expect(page).to have_content('Post was successfully updated.'), '投稿編集の成功時に『Post was successfully updated.』のメッセージが表示されていません' expect(current_path).to eq(post_path(Post.find_by(title: 'edited_title'))), '投稿編集後に投稿詳細画面に遷移できていません' expect(page).to have_content('edited_title'), '編集した投稿のタイトルが表示されていません' expect(page).to have_content('edited_content'), '編集した投稿の本文が表示されていません' @@ -67,8 +67,8 @@ # 削除リンクの存在確認 expect(page).to have_content('Destroy'), '自分の投稿に削除用のリンクが表示されているかを確認してください' page.accept_confirm { click_on 'Destroy' } - expect(page).to have_content('Post was successfully destroyed.'), '投稿削除成功のメッセージが表示されていません' - expect(current_path).to eq('/posts'), '投稿編集後に投稿一覧画面に遷移できていません' + expect(page).to have_content('Post was successfully destroyed.'), '投稿削除の成功時に『Post was successfully destroyed.』のメッセージが表示されていません' + expect(current_path).to eq('/posts'), '投稿削除後に投稿一覧画面に遷移できていません' end it '4-3:他人の投稿に編集リンクが表示されない' do diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index 93e785f..bf32331 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -27,7 +27,7 @@ click_button 'ログイン' # 処理結果の確認 - expect(page).to have_content('Login successful.'), 'ログイン成功のメッセージが表示されていません' + expect(page).to have_content('Login successful.'), 'ログインの成功時に『Login successful.』のメッセージが表示されていません' expect(current_path).to eq('/posts'), 'ログイン後に投稿一覧画面に遷移できていません' end @@ -55,8 +55,8 @@ click_button 'ログイン' # 処理結果の確認 - expect(page).not_to have_content('Login successful.'), 'ログイン成功のメッセージが表示されています' - expect(page).to have_content('Login failed.'), 'ログイン失敗のメッセージが表示されていません' + expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' + expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end it '2-3:存在しないユーザーでログインができない' do @@ -83,8 +83,8 @@ click_button 'ログイン' # 処理結果の確認 - expect(page).not_to have_content('Login successful.'), 'ログイン成功のメッセージが表示されています' - expect(page).to have_content('Login failed.'), 'ログイン失敗のメッセージが表示されていません' + expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' + expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end it '2-4:パスワードが間違っている場合にログインができない' do @@ -111,8 +111,8 @@ click_button 'ログイン' # 処理結果の確認 - expect(page).not_to have_content('Login successful.'), 'ログイン成功のメッセージが表示されています' - expect(page).to have_content('Login failed.'), 'ログイン失敗のメッセージが表示されていません' + expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' + expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end end @@ -149,7 +149,7 @@ click_on 'ログアウト' # 処理結果の確認 - expect(page).to have_content('Logout successful.'), 'ログアウト成功のメッセージが表示されていません' + expect(page).to have_content('Logout successful.'), 'ログアウトの成功時に『Logout successful.』のメッセージが表示されていません' end it '3-2:ログインしていない場合、ユーザーのログアウトリンクが表示されない' do @@ -157,7 +157,7 @@ visit '/login' # 処理結果の確認 - expect(page).not_to have_link('ログアウト'), 'ログアウトリンクが表示されています' + expect(page).not_to have_link('ログアウト'), 'ログインしていない場合でも、ログアウトリンクが表示されています' end end end diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb index f973d8d..7130094 100644 --- a/spec/system/users_spec.rb +++ b/spec/system/users_spec.rb @@ -35,7 +35,7 @@ click_on '登録' # 処理結果の確認 - expect(page).to have_content('User was successfully created.'), 'ユーザー作成のメッセージが表示されていません' + expect(page).to have_content('User was successfully created.'), 'ユーザー作成の成功後に『User was successfully created.』のメッセージが表示されていません' expect(current_path).to eq('/login'), 'ユーザー作成後にログイン画面に遷移できていません' end @@ -72,8 +72,8 @@ click_on '登録' # 処理結果の確認 - expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成のメッセージが表示されています' - expect(page).to have_content('User creation failed.'), 'ユーザー作成失敗のメッセージが表示されていません' + expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成の失敗時に『User was successfully created.』のメッセージが表示されています' + expect(page).to have_content('User creation failed.'), 'ユーザー作成の失敗時に『User creation failed.』のメッセージが表示されていません' end it '1-3:入力項目が不足している場合に新規登録ができない' do @@ -106,8 +106,8 @@ click_on '登録' # 処理結果の確認 - expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成のメッセージが表示されています' - expect(page).to have_content('User creation failed.'), 'ユーザー作成失敗のメッセージが表示されていません' + expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成の失敗時に『User was successfully created.』のメッセージが表示されています' + expect(page).to have_content('User creation failed.'), 'ユーザー作成の失敗時に『User creation failed.』のメッセージが表示されていません' end end end From 4cd483edb6508d1ab97118530e17a175a01112ae Mon Sep 17 00:00:00 2001 From: yuji91 Date: Tue, 20 Apr 2021 01:28:00 +0900 Subject: [PATCH 06/15] =?UTF-8?q?Fix:=20SyntaxError=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 8 ++++---- spec/system/user_sessions_spec.rb | 20 ++++++++++---------- spec/system/users_spec.rb | 30 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 01e3247..a3d6ae8 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -10,8 +10,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label',text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -37,8 +37,8 @@ click_on 'Edit' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Title', 'Title というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Content', 'Content というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Title'), 'Title というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Content'), 'Content というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='post_title']"), 'Title というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index bf32331..561da2b 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -11,8 +11,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -39,8 +39,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -67,8 +67,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -95,8 +95,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -125,8 +125,8 @@ visit '/login' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb index 7130094..be91e9c 100644 --- a/spec/system/users_spec.rb +++ b/spec/system/users_spec.rb @@ -10,11 +10,11 @@ visit 'users/new' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Last name', 'Last name というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'First name', 'First name というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password confirmation', 'Password confirmation というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Last name'), 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'First name'), 'First name というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -47,11 +47,11 @@ visit 'users/new' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Last name', 'Last name というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'First name', 'First name というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password confirmation', 'Password confirmation というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Last name'), 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'First name'), 'First name というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' @@ -81,11 +81,11 @@ visit 'users/new' # labelの存在確認 - expect(page).to have_selector 'label', text: 'Last name', 'Last name というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'First name', 'First name というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Email', 'Email というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password', 'Password というラベルが表示されていることを確認してください' - expect(page).to have_selector 'label', text: 'Password confirmation', 'Password confirmation というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Last name'), 'Last name というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'First name'), 'First name というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password confirmation'), 'Password confirmation というラベルが表示されていることを確認してください' # labelとフィールドの対応付け確認 expect(page).to have_css("label[for='user_last_name']"), 'Last name というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' From 3563faf0e97a95f7d7114ea39feb1377328bc7d6 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Thu, 22 Apr 2021 15:52:33 +0900 Subject: [PATCH 07/15] =?UTF-8?q?Fix:=20=E3=83=95=E3=83=A9=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E4=BB=A5=E5=A4=96=E3=81=AE=E7=A2=BA=E8=AA=8D=E8=A6=B3=E7=82=B9?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 3 ++- spec/system/user_sessions_spec.rb | 7 +++++ spec/system/users_spec.rb | 43 +++++++++++++++++-------------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index a3d6ae8..702ea08 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -59,7 +59,7 @@ end it '4-2:自分の投稿を削除することができる' do - create(:post, user: user) + post = create(:post, user: user) # 確認対象の画面に移動 visit '/posts' @@ -68,6 +68,7 @@ expect(page).to have_content('Destroy'), '自分の投稿に削除用のリンクが表示されているかを確認してください' page.accept_confirm { click_on 'Destroy' } expect(page).to have_content('Post was successfully destroyed.'), '投稿削除の成功時に『Post was successfully destroyed.』のメッセージが表示されていません' + expect(page).not_to have_content post.title, '投稿が削除できているかを確認してください' expect(current_path).to eq('/posts'), '投稿削除後に投稿一覧画面に遷移できていません' end diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index 561da2b..48565d7 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -55,6 +55,8 @@ click_button 'ログイン' # 処理結果の確認 + expect(current_path).not_to eq('/posts'), '入力項目が不足している場合にログインできていないかを確認してください' + expect(current_path).to eq('/login'), 'ログインの失敗時に別の画面の遷移していないかを確認してください' expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end @@ -83,6 +85,8 @@ click_button 'ログイン' # 処理結果の確認 + expect(current_path).not_to eq('/posts'), '存在しないユーザーでログインできていないかを確認してください' + expect(current_path).to eq('/login'), 'ログインの失敗時に別の画面の遷移していないかを確認してください' expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end @@ -111,6 +115,8 @@ click_button 'ログイン' # 処理結果の確認 + expect(current_path).not_to eq('/posts'), 'パスワードが間違っている場合にログインできていないかを確認してください' + expect(current_path).to eq('/login'), 'ログインの失敗時に別の画面の遷移していないかを確認してください' expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end @@ -149,6 +155,7 @@ click_on 'ログアウト' # 処理結果の確認 + expect(page).to have_button('ログイン'), 'ログアウトができているかを確認してください' expect(page).to have_content('Logout successful.'), 'ログアウトの成功時に『Logout successful.』のメッセージが表示されていません' end diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb index be91e9c..d8123f6 100644 --- a/spec/system/users_spec.rb +++ b/spec/system/users_spec.rb @@ -27,12 +27,14 @@ expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' # ユーザー新規登録処理 - fill_in 'Last name', with: 'test01' - fill_in 'First name', with: 'test01' - fill_in 'Email', with: 'test01@example.com' - fill_in 'Password', with: 'password' - fill_in 'Password confirmation', with: 'password' - click_on '登録' + expect { + fill_in 'Last name', with: 'test01' + fill_in 'First name', with: 'test01' + fill_in 'Email', with: 'test01@example.com' + fill_in 'Password', with: 'password' + fill_in 'Password confirmation', with: 'password' + click_on '登録' + }.to change { User.count }.by(1) # 処理結果の確認 expect(page).to have_content('User was successfully created.'), 'ユーザー作成の成功後に『User was successfully created.』のメッセージが表示されていません' @@ -64,12 +66,14 @@ expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' # ユーザー新規登録処理 - fill_in 'Last name', with: 'test01' - fill_in 'First name', with: 'test01' - fill_in 'Email', with: user.email - fill_in 'Password', with: 'password' - fill_in 'Password confirmation', with: 'password' - click_on '登録' + expect { + fill_in 'Last name', with: 'test01' + fill_in 'First name', with: 'test01' + fill_in 'Email', with: user.email + fill_in 'Password', with: 'password' + fill_in 'Password confirmation', with: 'password' + click_on '登録' + }.to change { User.count }.by(0) # 処理結果の確認 expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成の失敗時に『User was successfully created.』のメッセージが表示されています' @@ -98,13 +102,14 @@ expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' # ユーザー新規登録処理 - fill_in 'Last name', with: nil - fill_in 'First name', with: nil - fill_in 'Email', with: nil - fill_in 'Password', with: nil - fill_in 'Password confirmation', with: nil - click_on '登録' - + expect { + fill_in 'Last name', with: nil + fill_in 'First name', with: nil + fill_in 'Email', with: nil + fill_in 'Password', with: nil + fill_in 'Password confirmation', with: nil + click_on '登録' + }.to change { User.count }.by(0) # 処理結果の確認 expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成の失敗時に『User was successfully created.』のメッセージが表示されています' expect(page).to have_content('User creation failed.'), 'ユーザー作成の失敗時に『User creation failed.』のメッセージが表示されていません' From 4671d01b1828d7d90ab2832ebfc1afef13e65645 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Thu, 22 Apr 2021 19:28:19 +0900 Subject: [PATCH 08/15] =?UTF-8?q?Fix:=20=E3=83=95=E3=83=A9=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=82=92=E7=A2=BA=E8=AA=8D=E8=A6=B3=E7=82=B9=E3=81=8B=E3=82=89?= =?UTF-8?q?=E9=99=A4=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 5 +++-- spec/system/user_sessions_spec.rb | 9 +-------- spec/system/users_spec.rb | 16 +++------------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 702ea08..aed6970 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -52,7 +52,7 @@ fill_in 'Content', with: 'edited_content' click_on 'Update Post' - expect(page).to have_content('Post was successfully updated.'), '投稿編集の成功時に『Post was successfully updated.』のメッセージが表示されていません' + # 処理結果の確認 expect(current_path).to eq(post_path(Post.find_by(title: 'edited_title'))), '投稿編集後に投稿詳細画面に遷移できていません' expect(page).to have_content('edited_title'), '編集した投稿のタイトルが表示されていません' expect(page).to have_content('edited_content'), '編集した投稿の本文が表示されていません' @@ -67,7 +67,8 @@ # 削除リンクの存在確認 expect(page).to have_content('Destroy'), '自分の投稿に削除用のリンクが表示されているかを確認してください' page.accept_confirm { click_on 'Destroy' } - expect(page).to have_content('Post was successfully destroyed.'), '投稿削除の成功時に『Post was successfully destroyed.』のメッセージが表示されていません' + + # 処理結果の確認 expect(page).not_to have_content post.title, '投稿が削除できているかを確認してください' expect(current_path).to eq('/posts'), '投稿削除後に投稿一覧画面に遷移できていません' end diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index 48565d7..4f49282 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -27,7 +27,7 @@ click_button 'ログイン' # 処理結果の確認 - expect(page).to have_content('Login successful.'), 'ログインの成功時に『Login successful.』のメッセージが表示されていません' + expect(current_path).to eq('/login'), 'ログイン処理が正しく行えるかを確認してください' expect(current_path).to eq('/posts'), 'ログイン後に投稿一覧画面に遷移できていません' end @@ -57,8 +57,6 @@ # 処理結果の確認 expect(current_path).not_to eq('/posts'), '入力項目が不足している場合にログインできていないかを確認してください' expect(current_path).to eq('/login'), 'ログインの失敗時に別の画面の遷移していないかを確認してください' - expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' - expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end it '2-3:存在しないユーザーでログインができない' do @@ -87,8 +85,6 @@ # 処理結果の確認 expect(current_path).not_to eq('/posts'), '存在しないユーザーでログインできていないかを確認してください' expect(current_path).to eq('/login'), 'ログインの失敗時に別の画面の遷移していないかを確認してください' - expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' - expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end it '2-4:パスワードが間違っている場合にログインができない' do @@ -117,8 +113,6 @@ # 処理結果の確認 expect(current_path).not_to eq('/posts'), 'パスワードが間違っている場合にログインできていないかを確認してください' expect(current_path).to eq('/login'), 'ログインの失敗時に別の画面の遷移していないかを確認してください' - expect(page).not_to have_content('Login successful.'), 'ログインの失敗時に『Login successful.』のメッセージが表示されています' - expect(page).to have_content('Login failed.'), 'ログインの失敗時に『Login failed.』のメッセージが表示されていません' end end @@ -156,7 +150,6 @@ # 処理結果の確認 expect(page).to have_button('ログイン'), 'ログアウトができているかを確認してください' - expect(page).to have_content('Logout successful.'), 'ログアウトの成功時に『Logout successful.』のメッセージが表示されていません' end it '3-2:ログインしていない場合、ユーザーのログアウトリンクが表示されない' do diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb index d8123f6..0b6e979 100644 --- a/spec/system/users_spec.rb +++ b/spec/system/users_spec.rb @@ -34,10 +34,7 @@ fill_in 'Password', with: 'password' fill_in 'Password confirmation', with: 'password' click_on '登録' - }.to change { User.count }.by(1) - - # 処理結果の確認 - expect(page).to have_content('User was successfully created.'), 'ユーザー作成の成功後に『User was successfully created.』のメッセージが表示されていません' + }.to change { User.count }.by(1) # 処理結果の確認 expect(current_path).to eq('/login'), 'ユーザー作成後にログイン画面に遷移できていません' end @@ -73,11 +70,7 @@ fill_in 'Password', with: 'password' fill_in 'Password confirmation', with: 'password' click_on '登録' - }.to change { User.count }.by(0) - - # 処理結果の確認 - expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成の失敗時に『User was successfully created.』のメッセージが表示されています' - expect(page).to have_content('User creation failed.'), 'ユーザー作成の失敗時に『User creation failed.』のメッセージが表示されていません' + }.to change { User.count }.by(0) # 処理結果の確認 end it '1-3:入力項目が不足している場合に新規登録ができない' do @@ -109,10 +102,7 @@ fill_in 'Password', with: nil fill_in 'Password confirmation', with: nil click_on '登録' - }.to change { User.count }.by(0) - # 処理結果の確認 - expect(page).not_to have_content('User was successfully created.'), 'ユーザー作成の失敗時に『User was successfully created.』のメッセージが表示されています' - expect(page).to have_content('User creation failed.'), 'ユーザー作成の失敗時に『User creation failed.』のメッセージが表示されていません' + }.to change { User.count }.by(0) # 処理結果の確認 end end end From bc63c69874c36cd9ffe89f6fbe5661f6dba519d6 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Thu, 22 Apr 2021 19:44:05 +0900 Subject: [PATCH 09/15] =?UTF-8?q?Fix:=20=E3=82=BF=E3=82=A4=E3=83=9D?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 2 +- spec/system/user_sessions_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index aed6970..818971c 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -69,8 +69,8 @@ page.accept_confirm { click_on 'Destroy' } # 処理結果の確認 - expect(page).not_to have_content post.title, '投稿が削除できているかを確認してください' expect(current_path).to eq('/posts'), '投稿削除後に投稿一覧画面に遷移できていません' + expect(page).not_to have_content(post.title), '投稿が削除できているかを確認してください' end it '4-3:他人の投稿に編集リンクが表示されない' do diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index 4f49282..a1acfe4 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -27,7 +27,7 @@ click_button 'ログイン' # 処理結果の確認 - expect(current_path).to eq('/login'), 'ログイン処理が正しく行えるかを確認してください' + expect(current_path).not_to eq('/login'), 'ログイン処理が正しく行えるかを確認してください' expect(current_path).to eq('/posts'), 'ログイン後に投稿一覧画面に遷移できていません' end From ebeec70fecbb1ee1c9a73ba0aac99dbe97c4ac15 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Thu, 3 Jun 2021 11:51:16 +0900 Subject: [PATCH 10/15] Apply headless_chrome --- spec/spec_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f83124b..d10f957 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -93,4 +93,9 @@ # as the one that triggered the failure. Kernel.srand config.seed =end + + config.before(:each, type: :system) do + driven_by :selenium, using: :headless_chrome, screen_size: [1920, 1080] + # driven_by :selenium, using: :chrome, screen_size: [1080, 1080] # ローカルでの確認用 + end end From 8463e3a5af48ee53c06e3e39238aeda326b5cdeb Mon Sep 17 00:00:00 2001 From: yuji91 Date: Wed, 4 Aug 2021 18:55:58 +0900 Subject: [PATCH 11/15] =?UTF-8?q?Add:=20=E8=A4=87=E6=95=B0=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=83=BC=E7=99=BB=E9=8C=B2=E6=99=82=E3=81=AB?= =?UTF-8?q?=E6=8C=99=E5=8B=95=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/user_sessions_spec.rb | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index a1acfe4..584c043 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -114,6 +114,40 @@ expect(current_path).not_to eq('/posts'), 'パスワードが間違っている場合にログインできていないかを確認してください' expect(current_path).to eq('/login'), 'ログインの失敗時に別の画面の遷移していないかを確認してください' end + + it '2-5:複数ユーザー登録時に問題なくログインができる' do + # テストデータの用意 + first_user = create(:user) # describe使わないので、let!を使わずに記載 + second_user = create(:user) # describe使わないので、let!を使わずに記載 + third_user = create(:user) # describe使わないので、let!を使わずに記載 + + # 確認対象の画面に移動 + visit '/login' + + # labelの存在確認 + expect(page).to have_selector('label', text: 'Email'), 'Email というラベルが表示されていることを確認してください' + expect(page).to have_selector('label', text: 'Password'), 'Password というラベルが表示されていることを確認してください' + + # labelとフィールドの対応付け確認 + expect(page).to have_css("label[for='email']"), 'Email というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' + + # ログイン用ボタンの存在確認 + expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + + # ユーザーログイン処理 + fill_in 'Email', with: second_user.email + fill_in 'Password', with: 'password' + click_button 'ログイン' + + # 処理結果の確認 + expect(current_path).not_to eq('/login'), 'ログイン処理が正しく行えるかを確認してください' + + find('#header-profile').click + expect(page).not_to have_content("#{first_user.last_name} #{first_user.first_name}"), '最初に登録されたユーザーでログインされています。ログイン時のロジックを確認してください' + expect(page).to have_content("#{second_user.last_name} #{second_user.first_name}"), '複数のユーザーを作成した状態で、正しくログインができるかを確認してください' + expect(page).not_to have_content("#{third_user.last_name} #{third_user.first_name}"), '最後に登録されたユーザーでログインされています。ログイン時のロジックを確認してください' + end end describe '確認観点3:ユーザーログアウト' do From 232b74c5a4a3f8c35531c1586966ee5dfe140559 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Tue, 22 Mar 2022 18:12:51 +0900 Subject: [PATCH 12/15] =?UTF-8?q?Modify:=20Login,=20Logout=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=82=92=E8=8B=B1=E8=AA=9E=E8=A1=A8=E8=A8=98?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/posts_spec.rb | 4 ++-- spec/system/user_sessions_spec.rb | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 818971c..91ca0a9 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -18,12 +18,12 @@ expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' # ログイン用ボタンの存在確認 - expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + expect(page).to have_button('Login'), 'ログイン用のボタンが表示されていることを確認してください' # ユーザーログイン処理 fill_in 'Email', with: user.email fill_in 'Password', with: 'password' - click_button 'ログイン' + click_button 'Login' end it '4-1:自分の投稿を編集することができる' do diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index 584c043..befc807 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -19,12 +19,12 @@ expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' # ログイン用ボタンの存在確認 - expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + expect(page).to have_button('Login'), 'ログイン用のボタンが表示されていることを確認してください' # ユーザーログイン処理 fill_in 'Email', with: user.email fill_in 'Password', with: 'password' - click_button 'ログイン' + click_button 'Login' # 処理結果の確認 expect(current_path).not_to eq('/login'), 'ログイン処理が正しく行えるかを確認してください' @@ -47,12 +47,12 @@ expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' # ログイン用ボタンの存在確認 - expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + expect(page).to have_button('Login'), 'ログイン用のボタンが表示されていることを確認してください' # ユーザーログイン処理 fill_in 'Email', with: nil fill_in 'Password', with: nil - click_button 'ログイン' + click_button 'Login' # 処理結果の確認 expect(current_path).not_to eq('/posts'), '入力項目が不足している場合にログインできていないかを確認してください' @@ -75,7 +75,7 @@ expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' # ログイン用ボタンの存在確認 - expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + expect(page).to have_button('Login'), 'ログイン用のボタンが表示されていることを確認してください' # ユーザーログイン処理 fill_in 'Email', with: 'another_user@example.com' @@ -103,12 +103,12 @@ expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' # ログイン用ボタンの存在確認 - expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + expect(page).to have_button('Login'), 'ログイン用のボタンが表示されていることを確認してください' # ユーザーログイン処理 fill_in 'Email', with: user.email fill_in 'Password', with: 'wrong_password' - click_button 'ログイン' + click_button 'Login' # 処理結果の確認 expect(current_path).not_to eq('/posts'), 'パスワードが間違っている場合にログインできていないかを確認してください' @@ -133,12 +133,12 @@ expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' # ログイン用ボタンの存在確認 - expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + expect(page).to have_button('Login'), 'ログイン用のボタンが表示されていることを確認してください' # ユーザーログイン処理 fill_in 'Email', with: second_user.email fill_in 'Password', with: 'password' - click_button 'ログイン' + click_button 'Login' # 処理結果の確認 expect(current_path).not_to eq('/login'), 'ログイン処理が正しく行えるかを確認してください' @@ -167,23 +167,23 @@ expect(page).to have_css("label[for='password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' # ログイン用ボタンの存在確認 - expect(page).to have_button('ログイン'), 'ログイン用のボタンが表示されていることを確認してください' + expect(page).to have_button('Login'), 'ログイン用のボタンが表示されていることを確認してください' # ユーザーログイン処理 fill_in 'Email', with: user.email fill_in 'Password', with: 'password' - click_button 'ログイン' + click_button 'Login' # ユーザーログアウト処理 find('#header-profile').click # ログアウト用ボタンの存在確認 - expect(page).to have_link('ログアウト'), 'ログアウトのボタンが表示されていることを確認してください' + expect(page).to have_link('Logout'), 'ログアウトのボタンが表示されていることを確認してください' click_on 'ログアウト' # 処理結果の確認 - expect(page).to have_button('ログイン'), 'ログアウトができているかを確認してください' + expect(page).to have_button('Login'), 'ログアウトができているかを確認してください' end it '3-2:ログインしていない場合、ユーザーのログアウトリンクが表示されない' do @@ -191,7 +191,7 @@ visit '/login' # 処理結果の確認 - expect(page).not_to have_link('ログアウト'), 'ログインしていない場合でも、ログアウトリンクが表示されています' + expect(page).not_to have_link('Logout'), 'ログインしていない場合でも、ログアウトリンクが表示されています' end end end From d7f653b227a6ab26455201aa14bd308de3186067 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Tue, 22 Mar 2022 19:01:12 +0900 Subject: [PATCH 13/15] =?UTF-8?q?Modify:=20Create=20User=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=82=92=E8=8B=B1=E8=AA=9E=E8=A1=A8=E8=A8=98=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/users_spec.rb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/system/users_spec.rb b/spec/system/users_spec.rb index 0b6e979..01eb89b 100644 --- a/spec/system/users_spec.rb +++ b/spec/system/users_spec.rb @@ -4,8 +4,8 @@ RSpec.describe "Users", type: :system do let(:user) { create(:user) } - describe '確認観点1:ユーザー新規登録' do - it '1-1:ユーザーの新規登録ができる' do + describe '確認観点1:ユーザー新規作成' do + it '1-1:ユーザーの新規作成ができる' do # 確認対象の画面に移動 visit 'users/new' @@ -23,22 +23,22 @@ expect(page).to have_css("label[for='user_password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' expect(page).to have_css("label[for='user_password_confirmation']"), 'Password confirmation というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' - # 登録ボタンの存在確認 - expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' + # ユーザー作成用ボタンの存在確認 + expect(page).to have_button('Create User'), 'ユーザー作成用のボタンが表示されていることを確認してください' - # ユーザー新規登録処理 + # ユーザー新規作成用の処理 expect { fill_in 'Last name', with: 'test01' fill_in 'First name', with: 'test01' fill_in 'Email', with: 'test01@example.com' fill_in 'Password', with: 'password' fill_in 'Password confirmation', with: 'password' - click_on '登録' + click_on 'Create User' }.to change { User.count }.by(1) # 処理結果の確認 expect(current_path).to eq('/login'), 'ユーザー作成後にログイン画面に遷移できていません' end - it '1-2:同じメールアドレスのユーザーは新規登録できない' do + it '1-2:同じメールアドレスのユーザーは新規作成できない' do # テストデータの用意 user = create(:user) # describe使わないので、let!を使わずに記載 @@ -59,21 +59,21 @@ expect(page).to have_css("label[for='user_password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' expect(page).to have_css("label[for='user_password_confirmation']"), 'Password confirmation というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' - # 登録ボタンの存在確認 - expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' + # ユーザー作成用ボタンの存在確認 + expect(page).to have_button('Create User'), 'ユーザー作成用のボタンが表示されていることを確認してください' - # ユーザー新規登録処理 + # ユーザー新規作成用の処理 expect { fill_in 'Last name', with: 'test01' fill_in 'First name', with: 'test01' fill_in 'Email', with: user.email fill_in 'Password', with: 'password' fill_in 'Password confirmation', with: 'password' - click_on '登録' + click_on 'Create User' }.to change { User.count }.by(0) # 処理結果の確認 end - it '1-3:入力項目が不足している場合に新規登録ができない' do + it '1-3:入力項目が不足している場合に新規作成ができない' do # 確認対象の画面に移動 visit 'users/new' @@ -91,17 +91,17 @@ expect(page).to have_css("label[for='user_password']"), 'Password というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' expect(page).to have_css("label[for='user_password_confirmation']"), 'Password confirmation というラベルをクリックすると対応するフィールドにフォーカスすることを確認してください' - # 登録ボタンの存在確認 - expect(page).to have_button('登録'), '登録ボタンが表示されていることを確認してください' + # ユーザー作成用ボタンの存在確認 + expect(page).to have_button('Create User'), 'ユーザー作成用のボタンが表示されていることを確認してください' - # ユーザー新規登録処理 + # ユーザー新規作成用の処理 expect { fill_in 'Last name', with: nil fill_in 'First name', with: nil fill_in 'Email', with: nil fill_in 'Password', with: nil fill_in 'Password confirmation', with: nil - click_on '登録' + click_on 'Create User' }.to change { User.count }.by(0) # 処理結果の確認 end end From 7cea1cd0049c0d972988ea9ebf5fdadb3b33666f Mon Sep 17 00:00:00 2001 From: yuji91 Date: Tue, 22 Mar 2022 19:34:47 +0900 Subject: [PATCH 14/15] =?UTF-8?q?Modify:=20Logout=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=82=92=E8=8B=B1=E8=AA=9E=E8=A1=A8=E8=A8=98=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/user_sessions_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index befc807..1dae907 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -80,7 +80,7 @@ # ユーザーログイン処理 fill_in 'Email', with: 'another_user@example.com' fill_in 'Password', with: 'password' - click_button 'ログイン' + click_button 'Login' # 処理結果の確認 expect(current_path).not_to eq('/posts'), '存在しないユーザーでログインできていないかを確認してください' From 78f6ae43d63e7a02205a2483b3ebfd32f5d9b859 Mon Sep 17 00:00:00 2001 From: yuji91 Date: Tue, 22 Mar 2022 19:58:01 +0900 Subject: [PATCH 15/15] =?UTF-8?q?Modify:=20Logout=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=82=92=E8=8B=B1=E8=AA=9E=E8=A1=A8=E8=A8=98=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/system/user_sessions_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/user_sessions_spec.rb b/spec/system/user_sessions_spec.rb index 1dae907..107f3b2 100644 --- a/spec/system/user_sessions_spec.rb +++ b/spec/system/user_sessions_spec.rb @@ -180,7 +180,7 @@ # ログアウト用ボタンの存在確認 expect(page).to have_link('Logout'), 'ログアウトのボタンが表示されていることを確認してください' - click_on 'ログアウト' + click_on 'Logout' # 処理結果の確認 expect(page).to have_button('Login'), 'ログアウトができているかを確認してください'