From 47c193394dab3ce57195260ad7688536098f2502 Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 19:29:06 +0000 Subject: [PATCH 1/8] writing new scenario --- rails_root/features/initial_ui_design.feature | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/rails_root/features/initial_ui_design.feature b/rails_root/features/initial_ui_design.feature index 2ce47b9..59c2b90 100644 --- a/rails_root/features/initial_ui_design.feature +++ b/rails_root/features/initial_ui_design.feature @@ -1,6 +1,16 @@ Feature: Initial UI Design Verify ui design +Background: Questions and responses exist + Given the following questions exist: + | text | explanation | section | + | Are you ok? | explanation 1 | 0 | + | question 2 | explanation 2 | 1 | + | question 3 | explanation 3 | 2 | + | question 4 | explanation 4 | 3 | + | question 5 | I am fine | 4 | + + Scenario: Verify survey profile page Given I am on the site When I visit survey profile page @@ -12,15 +22,10 @@ Feature: Initial UI Design Then I can see survey sections Scenario: Verify survey qustions - Given the following questions exist: - | text | explanation | section | - | Are you ok? | explanation 1 | 0 | - | question 2 | explanation 2 | 1 | - | question 3 | explanation 3 | 2 | - | question 4 | explanation 4 | 3 | - | question 5 | I am fine | 4 | When I visit survey form page Then I can see "Are you ok?" - + Scenario: Verify explanation on survey_responses page + Given I have a response + When I visit the sur From 125518216ea3fed291f54311f42f3d6360324533 Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 19:29:06 +0000 Subject: [PATCH 2/8] writing new scenario --- rails_root/features/initial_ui_design.feature | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/rails_root/features/initial_ui_design.feature b/rails_root/features/initial_ui_design.feature index 2ce47b9..59c2b90 100644 --- a/rails_root/features/initial_ui_design.feature +++ b/rails_root/features/initial_ui_design.feature @@ -1,6 +1,16 @@ Feature: Initial UI Design Verify ui design +Background: Questions and responses exist + Given the following questions exist: + | text | explanation | section | + | Are you ok? | explanation 1 | 0 | + | question 2 | explanation 2 | 1 | + | question 3 | explanation 3 | 2 | + | question 4 | explanation 4 | 3 | + | question 5 | I am fine | 4 | + + Scenario: Verify survey profile page Given I am on the site When I visit survey profile page @@ -12,15 +22,10 @@ Feature: Initial UI Design Then I can see survey sections Scenario: Verify survey qustions - Given the following questions exist: - | text | explanation | section | - | Are you ok? | explanation 1 | 0 | - | question 2 | explanation 2 | 1 | - | question 3 | explanation 3 | 2 | - | question 4 | explanation 4 | 3 | - | question 5 | I am fine | 4 | When I visit survey form page Then I can see "Are you ok?" - + Scenario: Verify explanation on survey_responses page + Given I have a response + When I visit the sur From 4469c95316b5dd7a01464c509bbd1f43c5781bd0 Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 20:14:00 +0000 Subject: [PATCH 3/8] add cucumber for explanation --- rails_root/features/initial_ui_design.feature | 15 +++++++++---- .../initial_ui_design_steps.rb | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/rails_root/features/initial_ui_design.feature b/rails_root/features/initial_ui_design.feature index 59c2b90..87c4266 100644 --- a/rails_root/features/initial_ui_design.feature +++ b/rails_root/features/initial_ui_design.feature @@ -4,12 +4,17 @@ Feature: Initial UI Design Background: Questions and responses exist Given the following questions exist: | text | explanation | section | - | Are you ok? | explanation 1 | 0 | + | Are you ok? | No I am not | 0 | | question 2 | explanation 2 | 1 | | question 3 | explanation 3 | 2 | | question 4 | explanation 4 | 3 | | question 5 | I am fine | 4 | - + + Given the survey profiles exist: + |user_id| first_name| last_name| campus_name| district_name| + | 1 | John |Doe|Campus 1|District 1| + | 2 | Jane |Doe|Campus 2|District 2| + Scenario: Verify survey profile page Given I am on the site @@ -26,6 +31,8 @@ Background: Questions and responses exist Then I can see "Are you ok?" Scenario: Verify explanation on survey_responses page - Given I have a response - When I visit the sur + Given user 1 responses to question "Are you ok?" + When I am on the survey responses page of user 1 + Then I can see "Are you ok?" + And I can see "No I am not" diff --git a/rails_root/features/step_definitions/initial_ui_design_steps.rb b/rails_root/features/step_definitions/initial_ui_design_steps.rb index e353e47..5ef2daa 100644 --- a/rails_root/features/step_definitions/initial_ui_design_steps.rb +++ b/rails_root/features/step_definitions/initial_ui_design_steps.rb @@ -28,3 +28,24 @@ Then('I can see {string}') do |string| expect(page).to have_content(string) end + +Given('the survey profiles exist:') do |table| + table.hashes.each do |profile| + SurveyProfile.create profile + end +end + +Given('user {int} responses to question {string}') do |int, string| + question = SurveyQuestion.find_by(text: string) + profile = SurveyProfile.find_by(user_id: int) + response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") + SurveyAnswer.create!(choice: 0, question: question, response: response) + +end + +When('I am on the survey responses page of user {int}') do |int| + profile = SurveyProfile.find_by(user_id: int) + response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") + puts survey_response_path(response) + visit survey_response_path(response) +end From 32994a6e9f6a835d844c012d39de83c459d4eca4 Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 20:18:37 +0000 Subject: [PATCH 4/8] rubocop --- rails_root/Gemfile | 2 +- .../step_definitions/initial_ui_design_steps.rb | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rails_root/Gemfile b/rails_root/Gemfile index 0c323ef..9f9a70c 100644 --- a/rails_root/Gemfile +++ b/rails_root/Gemfile @@ -35,7 +35,7 @@ gem 'jbuilder' # gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data'#, platforms: %i[windows jruby] +gem 'tzinfo-data' # , platforms: %i[windows jruby] # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', require: false diff --git a/rails_root/features/step_definitions/initial_ui_design_steps.rb b/rails_root/features/step_definitions/initial_ui_design_steps.rb index 5ef2daa..8eb2ed6 100644 --- a/rails_root/features/step_definitions/initial_ui_design_steps.rb +++ b/rails_root/features/step_definitions/initial_ui_design_steps.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -# frozen_string_literal: true Given(/the following questions exist/) do |survey_questions_table| survey_questions_table.hashes.each do |question| @@ -20,7 +19,7 @@ end Then('I can see survey sections') do - ['Part 1','Part 2','Part 3','Part 4'].each do |string| + ['Part 1', 'Part 2', 'Part 3', 'Part 4'].each do |string| expect(page).to have_content(string) end end @@ -38,14 +37,13 @@ Given('user {int} responses to question {string}') do |int, string| question = SurveyQuestion.find_by(text: string) profile = SurveyProfile.find_by(user_id: int) - response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") - SurveyAnswer.create!(choice: 0, question: question, response: response) - + response = SurveyResponse.find_or_create_by!(profile:, share_code: "debug#{profile.user_id}") + SurveyAnswer.create!(choice: 0, question:, response:) end When('I am on the survey responses page of user {int}') do |int| profile = SurveyProfile.find_by(user_id: int) - response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") + response = SurveyResponse.find_or_create_by!(profile:, share_code: "debug#{profile.user_id}") puts survey_response_path(response) visit survey_response_path(response) end From 4dd0f1c2935de6f4567f7b720da2a464639182c7 Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 19:29:06 +0000 Subject: [PATCH 5/8] writing new scenario --- rails_root/features/initial_ui_design.feature | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/rails_root/features/initial_ui_design.feature b/rails_root/features/initial_ui_design.feature index 2ce47b9..59c2b90 100644 --- a/rails_root/features/initial_ui_design.feature +++ b/rails_root/features/initial_ui_design.feature @@ -1,6 +1,16 @@ Feature: Initial UI Design Verify ui design +Background: Questions and responses exist + Given the following questions exist: + | text | explanation | section | + | Are you ok? | explanation 1 | 0 | + | question 2 | explanation 2 | 1 | + | question 3 | explanation 3 | 2 | + | question 4 | explanation 4 | 3 | + | question 5 | I am fine | 4 | + + Scenario: Verify survey profile page Given I am on the site When I visit survey profile page @@ -12,15 +22,10 @@ Feature: Initial UI Design Then I can see survey sections Scenario: Verify survey qustions - Given the following questions exist: - | text | explanation | section | - | Are you ok? | explanation 1 | 0 | - | question 2 | explanation 2 | 1 | - | question 3 | explanation 3 | 2 | - | question 4 | explanation 4 | 3 | - | question 5 | I am fine | 4 | When I visit survey form page Then I can see "Are you ok?" - + Scenario: Verify explanation on survey_responses page + Given I have a response + When I visit the sur From 5b2b7354007a0181e78a07c941aa18e6673bea3d Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 20:14:00 +0000 Subject: [PATCH 6/8] add cucumber for explanation --- rails_root/features/initial_ui_design.feature | 15 +++++++++---- .../initial_ui_design_steps.rb | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/rails_root/features/initial_ui_design.feature b/rails_root/features/initial_ui_design.feature index 59c2b90..87c4266 100644 --- a/rails_root/features/initial_ui_design.feature +++ b/rails_root/features/initial_ui_design.feature @@ -4,12 +4,17 @@ Feature: Initial UI Design Background: Questions and responses exist Given the following questions exist: | text | explanation | section | - | Are you ok? | explanation 1 | 0 | + | Are you ok? | No I am not | 0 | | question 2 | explanation 2 | 1 | | question 3 | explanation 3 | 2 | | question 4 | explanation 4 | 3 | | question 5 | I am fine | 4 | - + + Given the survey profiles exist: + |user_id| first_name| last_name| campus_name| district_name| + | 1 | John |Doe|Campus 1|District 1| + | 2 | Jane |Doe|Campus 2|District 2| + Scenario: Verify survey profile page Given I am on the site @@ -26,6 +31,8 @@ Background: Questions and responses exist Then I can see "Are you ok?" Scenario: Verify explanation on survey_responses page - Given I have a response - When I visit the sur + Given user 1 responses to question "Are you ok?" + When I am on the survey responses page of user 1 + Then I can see "Are you ok?" + And I can see "No I am not" diff --git a/rails_root/features/step_definitions/initial_ui_design_steps.rb b/rails_root/features/step_definitions/initial_ui_design_steps.rb index e353e47..5ef2daa 100644 --- a/rails_root/features/step_definitions/initial_ui_design_steps.rb +++ b/rails_root/features/step_definitions/initial_ui_design_steps.rb @@ -28,3 +28,24 @@ Then('I can see {string}') do |string| expect(page).to have_content(string) end + +Given('the survey profiles exist:') do |table| + table.hashes.each do |profile| + SurveyProfile.create profile + end +end + +Given('user {int} responses to question {string}') do |int, string| + question = SurveyQuestion.find_by(text: string) + profile = SurveyProfile.find_by(user_id: int) + response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") + SurveyAnswer.create!(choice: 0, question: question, response: response) + +end + +When('I am on the survey responses page of user {int}') do |int| + profile = SurveyProfile.find_by(user_id: int) + response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") + puts survey_response_path(response) + visit survey_response_path(response) +end From ad07bffbf88c52a081dcb90b1a0e69130a2dc513 Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 20:18:37 +0000 Subject: [PATCH 7/8] rubocop --- rails_root/Gemfile | 2 +- .../step_definitions/initial_ui_design_steps.rb | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rails_root/Gemfile b/rails_root/Gemfile index 0c323ef..9f9a70c 100644 --- a/rails_root/Gemfile +++ b/rails_root/Gemfile @@ -35,7 +35,7 @@ gem 'jbuilder' # gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data'#, platforms: %i[windows jruby] +gem 'tzinfo-data' # , platforms: %i[windows jruby] # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', require: false diff --git a/rails_root/features/step_definitions/initial_ui_design_steps.rb b/rails_root/features/step_definitions/initial_ui_design_steps.rb index 5ef2daa..8eb2ed6 100644 --- a/rails_root/features/step_definitions/initial_ui_design_steps.rb +++ b/rails_root/features/step_definitions/initial_ui_design_steps.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -# frozen_string_literal: true Given(/the following questions exist/) do |survey_questions_table| survey_questions_table.hashes.each do |question| @@ -20,7 +19,7 @@ end Then('I can see survey sections') do - ['Part 1','Part 2','Part 3','Part 4'].each do |string| + ['Part 1', 'Part 2', 'Part 3', 'Part 4'].each do |string| expect(page).to have_content(string) end end @@ -38,14 +37,13 @@ Given('user {int} responses to question {string}') do |int, string| question = SurveyQuestion.find_by(text: string) profile = SurveyProfile.find_by(user_id: int) - response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") - SurveyAnswer.create!(choice: 0, question: question, response: response) - + response = SurveyResponse.find_or_create_by!(profile:, share_code: "debug#{profile.user_id}") + SurveyAnswer.create!(choice: 0, question:, response:) end When('I am on the survey responses page of user {int}') do |int| profile = SurveyProfile.find_by(user_id: int) - response = SurveyResponse.find_or_create_by!(profile: profile, share_code: "debug#{profile.user_id}") + response = SurveyResponse.find_or_create_by!(profile:, share_code: "debug#{profile.user_id}") puts survey_response_path(response) visit survey_response_path(response) end From 0428747c16c3a485268811690b588aec27fce53f Mon Sep 17 00:00:00 2001 From: Chengyuan Qian Date: Fri, 8 Mar 2024 20:27:15 +0000 Subject: [PATCH 8/8] rubycritic --- rails_root/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rails_root/Gemfile b/rails_root/Gemfile index 09ee04d..1f8c6fd 100644 --- a/rails_root/Gemfile +++ b/rails_root/Gemfile @@ -51,10 +51,10 @@ group :development, :test do gem 'rspec-rails' gem 'rubocop' gem 'rubocop-rails' + gem 'rubycritic', require: false gem 'selenium-webdriver' gem 'simplecov', require: false gem 'sqlite3', '~> 1.4' - gem 'rubycritic', require: false end group :development do