From e59615192101ceb896e9111132a591c07baf6138 Mon Sep 17 00:00:00 2001 From: Travis Grathwell Date: Mon, 27 Mar 2017 22:03:09 -0700 Subject: [PATCH] Feature specs: get rid of 'should' (in names) and most usages of 'given' --- .../events/event_detail_request_spec.rb | 6 ++-- .../events/event_listing_request_spec.rb | 24 +++++++++++----- .../events/event_rsvp_request_spec.rb | 24 ++++++++-------- .../events/event_survey_request_spec.rb | 28 ++++++++++--------- .../features/events/new_event_request_spec.rb | 16 +++++------ .../attendee_details_request_spec.rb | 12 +------- .../organizer/event_email_request_spec.rb | 6 ++-- .../event_organizer_dashboard_request_spec.rb | 2 +- .../locations/locations_request_spec.rb | 8 +++--- spec/features/users/profiles_request_spec.rb | 4 +-- .../users/sign_in_menu_request_spec.rb | 6 ++-- 11 files changed, 69 insertions(+), 67 deletions(-) diff --git a/spec/features/events/event_detail_request_spec.rb b/spec/features/events/event_detail_request_spec.rb index 5bdd4145c..9fc8593b8 100644 --- a/spec/features/events/event_detail_request_spec.rb +++ b/spec/features/events/event_detail_request_spec.rb @@ -133,7 +133,7 @@ end context "when user has not rsvp'd to event" do - it "should allow user to rsvp as a volunteer or student" do + it "allows user to rsvp as a volunteer or student" do visit event_path(@event) expect(page).to have_link("Volunteer") expect(page).to have_link(attend_as_student_text) @@ -146,13 +146,13 @@ allow_any_instance_of(Event).to receive(:volunteers_at_limit?).and_return(true) end - it "should allow the user to join the student waitlist" do + it "allows the user to join the student waitlist" do visit event_path(@event) expect(page).not_to have_link(attend_as_student_text) expect(page).to have_link(join_student_waitlist_text) end - it "should allow the user to join the volunteer waitlist" do + it "allows the user to join the volunteer waitlist" do visit event_path(@event) expect(page).not_to have_link(attend_as_volunteer_text) expect(page).to have_link(join_volunteer_waitlist_text) diff --git a/spec/features/events/event_listing_request_spec.rb b/spec/features/events/event_listing_request_spec.rb index 1940f8ec6..105ccda23 100644 --- a/spec/features/events/event_listing_request_spec.rb +++ b/spec/features/events/event_listing_request_spec.rb @@ -18,7 +18,7 @@ expect(page).to have_content('Secondary Location') end - it "listing should show formatted dates" do + it "shows formatted dates" do next_year = Time.now.year + 1 event = create(:event, location_id: nil, @@ -80,7 +80,7 @@ end end - it "should not show event organizers column" do + it "does not show event organizers column" do user_organizer = create(:user, email: "orgainzer@mail.com", first_name: "Sam", last_name: "Spade") event = create(:event) event.organizers << user_organizer @@ -91,7 +91,7 @@ end context "chapter show page" do - it 'should show organizers for each event' do + it 'shows organizers for each event' do chapter = create(:chapter) user_organizer = create(:user, email: "orgainzer@mail.com", first_name: "Sam", last_name: "Spade") event = create(:event) @@ -111,7 +111,7 @@ @user = create(:user) end - it "listing should redirect to event detail page when non-logged in user volunteers" do + it "redirects to event detail page when non-logged in user volunteers" do event = create(:event, time_zone: 'Pacific Time (US & Canada)') event.event_sessions.first.update_attributes( starts_at: 365.days.from_now, @@ -209,7 +209,7 @@ expect(Event.last.allow_student_rsvp).to be false end - it "should display frontend content for frontend events" do + it "displays frontend content for frontend events" do visit events_path click_link "Organize Event" expand_all_event_sections @@ -238,8 +238,18 @@ before(:each) do @event = create(:event) @session1 = @event.event_sessions.first - @session1.update_attributes!(name: 'Installfest', starts_at: 10.days.from_now, ends_at: 11.days.from_now) - @session2 = create(:event_session, event: @event, name: 'Curriculum', starts_at: 12.days.from_now, ends_at: 13.days.from_now) + @session1.update_attributes!( + name: 'Installfest', + starts_at: 10.days.from_now, + ends_at: 11.days.from_now + ) + @session2 = create( + :event_session, + event: @event, + name: 'Curriculum', + starts_at: 12.days.from_now, + ends_at: 13.days.from_now + ) @event.reload end diff --git a/spec/features/events/event_rsvp_request_spec.rb b/spec/features/events/event_rsvp_request_spec.rb index e9912a693..0ddd9a04b 100644 --- a/spec/features/events/event_rsvp_request_spec.rb +++ b/spec/features/events/event_rsvp_request_spec.rb @@ -16,7 +16,7 @@ def fill_in_valid_volunteer_details sign_in_as @user end - context "given a new volunteer rsvp" do + context "with a new volunteer rsvp" do before do visit volunteer_new_event_rsvp_path(@event) end @@ -39,7 +39,7 @@ def fill_in_valid_volunteer_details fill_in_valid_volunteer_details end - it "should allow the user to update their gender" do + it "allows the user to update their gender" do expect(page.find("#user_gender").value).to eq(@user.gender) fill_in "user_gender", with: "human" click_on "Submit" @@ -47,7 +47,7 @@ def fill_in_valid_volunteer_details expect(page.find("#user_gender").value).to eq("human") end - it "should allow the user to affiliate themselves with the event's region" do + it "allows the user to affiliate themselves with the event's region" do check 'affiliate_with_region' expect { click_on "Submit" @@ -58,7 +58,7 @@ def fill_in_valid_volunteer_details end context 'with an invalid RSVP' do - it 'should maintain state when the form is submitted' do + it 'maintains state when the form is submitted' do check 'Vegetarian' click_on 'Submit' @@ -68,7 +68,7 @@ def fill_in_valid_volunteer_details end end - context "given an rsvp with childcare info" do + context "with an rsvp with childcare info" do before do @rsvp = create(:rsvp, user: @user, childcare_info: "Bobbie: 17, Susie: 20000007") visit edit_event_rsvp_path @rsvp.event, @rsvp @@ -87,16 +87,16 @@ def fill_in_valid_volunteer_details end end - context "given an rsvp toggling food options" do + context "with an rsvp toggling food options" do let(:food_text) { "The food's on us. Let us know if you have any dietary restrictions." } - it "should have food options when enabled" do + it "has food options when enabled" do expect(@event.food_provided).to eq true visit volunteer_new_event_rsvp_path(@event) expect(page).to have_content(food_text) end - it "should not have food options when disabled" do + it "does not have food options when disabled" do @event.update(food_provided: false) expect(@event.food_provided?).to eq(false) visit volunteer_new_event_rsvp_path(@event) @@ -104,7 +104,7 @@ def fill_in_valid_volunteer_details end end - context 'given an rsvp with dietary restrictions' do + context 'with an rsvp with dietary restrictions' do let(:rsvp) { create(:rsvp, user: @user, @@ -130,7 +130,7 @@ def fill_in_valid_volunteer_details let(:plus_one_host_text) { "If you are not a member of this workshop's target demographic" } context "when enabled" do - it "should ask for the name of the person's host (if they are a plus-one)" do + it "asks for the name of the person's host (if they are a plus-one)" do visit learn_new_event_rsvp_path(@event) expect(page).to have_content plus_one_host_text end @@ -141,7 +141,7 @@ def fill_in_valid_volunteer_details @event.update_attribute(:plus_one_host_toggle, false) end - it "should not show the plus-one host form" do + it "does not show the plus-one host form" do visit learn_new_event_rsvp_path(@event) expect(page).not_to have_content plus_one_host_text end @@ -186,7 +186,7 @@ def fill_in_valid_volunteer_details visit volunteer_new_event_rsvp_path(@event) end - it "should require subject experience" do + it "requires subject experience" do fill_in "rsvp_subject_experience", with: "I organized the February workshop after attending one in January" click_on "Submit" expect(page).to have_content "Thanks for signing up!" diff --git a/spec/features/events/event_survey_request_spec.rb b/spec/features/events/event_survey_request_spec.rb index c83adaa66..e0e732248 100644 --- a/spec/features/events/event_survey_request_spec.rb +++ b/spec/features/events/event_survey_request_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' describe 'the post-workshop survey' do + let(:submit_button_text) { 'Submit' } + before do @event = create(:event) @user = create(:user) @@ -15,11 +17,11 @@ visit preview_event_surveys_path(@event) end - it 'should not allow organizer to submit survey' do - expect(page).not_to have_content("Submit") + it 'does not allow organizer to submit survey' do + expect(page).not_to have_content(submit_button_text) end - it 'should allow organizer to email RSVPs the survey' do + it 'allows organizer to email RSVPs the survey' do expect(page).to have_content("Send Survey") end end @@ -31,19 +33,19 @@ end context 'with a new survey' do - it 'should have survey questions' do + it 'has survey questions' do expect(page).to have_content "How was #{@event.title}" within(".survey-form") do expect(page).to have_content "What was great?" - expect(page).to have_button "Submit" + expect(page).to have_button submit_button_text end end - it 'should take you home on submit' do + it 'redirects home on submit' do within(".survey-form") do fill_in 'What was great?', with: "Hotdogs" - click_button 'Submit' + click_button submit_button_text end expect(page).to have_content "Thanks for taking the survey!" @@ -53,20 +55,20 @@ context 'with an already-taken survey' do before do fill_in 'What was great?', with: "Hotdogs" - click_button 'Submit' + click_button submit_button_text visit new_event_rsvp_survey_path(@event, @rsvp) end - it 'should have a flash warning' do + it 'has a flash warning' do expect(page).to have_content "It looks like you've already taken this survey!" end - it 'should show you your previous answers' do + it 'shows you your previous answers' do expect(page).to have_content "Hotdogs" end - it 'should not have a submit button' do - expect(page).to_not have_button "Submit" + it 'does not have a submit button' do + expect(page).to_not have_button submit_button_text end end end @@ -84,7 +86,7 @@ visit event_surveys_path(@event) end - it 'should show the feedback' do + it 'shows the feedback' do expect(page).to have_content "Those dog stickers were great" end end diff --git a/spec/features/events/new_event_request_spec.rb b/spec/features/events/new_event_request_spec.rb index 0454bd6fa..d3067b6e9 100644 --- a/spec/features/events/new_event_request_spec.rb +++ b/spec/features/events/new_event_request_spec.rb @@ -18,13 +18,13 @@ sign_in_as(@user_organizer) end - it "should pre-fill the event details textarea" do + it "pre-fills the event details textarea" do visit_new_events_form_and_expand_all_sections expect(page.find_field('event_details')[:value]).to match(/Workshop Description/) end - it "should have a public organizer email field" do + it "has a public organizer email field" do visit_new_events_form_and_expand_all_sections label = "What email address should users contact you at with questions?" @@ -32,7 +32,7 @@ expect(page.field_labeled(label)[:value]).to eq("organizer@mail.com") end - it "should have the code of conduct checkbox checked" do + it "has the code of conduct checkbox unchecked" do visit_new_events_form_and_expand_all_sections expect(page).to have_unchecked_field("coc") @@ -56,7 +56,7 @@ expect(page).to have_unchecked_field('coc') end - it "should have appropriate locations available" do + it "has appropriate locations available" do visit_new_events_form_and_expand_all_sections live_location = create(:location) @@ -70,7 +70,7 @@ ]) end - it "should have a food options toggle" do + it "has a food options toggle" do visit_new_events_form_and_expand_all_sections expect(page).to have_checked_field('event_food_provided_true') @@ -102,7 +102,7 @@ end describe "the location form modal" do - it "should show errors if a location form is invalid" do + it "shows errors if a location form is invalid" do visit_new_events_form_and_expand_all_sections click_link "add it" @@ -111,7 +111,7 @@ expect(page).to have_css('#error_explanation') end - it "should accept and add a valid location" do + it "accepts and adds a valid location" do @region = create(:region) visit_new_events_form_and_expand_all_sections @@ -171,7 +171,7 @@ click_on 'Add another session' end - it 'should have two event session options, of which only the second can be removed' do + it 'has two event session options, of which only the second can be removed' do expect(page).to have_selector('.event-sessions > .fields', count: 2) find(:link, 'Remove Session', visible: true).click diff --git a/spec/features/events/organizer/attendee_details_request_spec.rb b/spec/features/events/organizer/attendee_details_request_spec.rb index 9e4e784b7..43e1c439f 100644 --- a/spec/features/events/organizer/attendee_details_request_spec.rb +++ b/spec/features/events/organizer/attendee_details_request_spec.rb @@ -17,20 +17,10 @@ end end - it "should list the student's operating system" do + it "lists the student's RSVP details" do within '.modal-body' do expect(page).to have_content(@student_rsvp.operating_system_title) - end - end - - it "should list the student's class level title" do - within '.modal-body' do expect(page).to have_content(@student_rsvp.level_title) - end - end - - it "it should list the student's job details" do - within '.modal-body' do expect(page).to have_content(@student_rsvp.job_details) end end diff --git a/spec/features/events/organizer/event_email_request_spec.rb b/spec/features/events/organizer/event_email_request_spec.rb index d388e338d..4b5c6775e 100644 --- a/spec/features/events/organizer/event_email_request_spec.rb +++ b/spec/features/events/organizer/event_email_request_spec.rb @@ -37,7 +37,7 @@ def choose_dropdown_option(dropdown_name, dropdown_option) click_link 'Email Attendees' end - it 'should show an accurate count of the # of people to be emailed when clicking buttons' do + it 'shows an accurate count of the # of people to be emailed when clicking buttons' do choose_dropdown_option('Add', 'Volunteers') expect(page).to have_content('2 people') @@ -99,11 +99,11 @@ def choose_dropdown_option(dropdown_name, dropdown_option) expect(recipients.length).to eq(3) end - it 'should have a "CC Organizers" checkbox' do + it 'has a "CC Organizers" checkbox' do expect(page).to have_unchecked_field('CC Organizers') end - it "should show an accurate count of the # of cc'd recipients when selecting cc checkboxes" do + it "shows an accurate count of the # of cc'd recipients when selecting cc checkboxes" do expect(page).to_not have_content('1 event organizer') check 'CC Organizers' diff --git a/spec/features/events/organizer/event_organizer_dashboard_request_spec.rb b/spec/features/events/organizer/event_organizer_dashboard_request_spec.rb index 39e605e8e..24d4dc7db 100644 --- a/spec/features/events/organizer/event_organizer_dashboard_request_spec.rb +++ b/spec/features/events/organizer/event_organizer_dashboard_request_spec.rb @@ -8,7 +8,7 @@ sign_in_as(@organizer) end - it "should have a page" do + it "displays the event title" do visit event_organizer_tools_path(@event) expect(page).to have_content('RailsBridge for Dik Diks') end diff --git a/spec/features/locations/locations_request_spec.rb b/spec/features/locations/locations_request_spec.rb index 995a342b5..c8a204025 100644 --- a/spec/features/locations/locations_request_spec.rb +++ b/spec/features/locations/locations_request_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe 'Locations' do - describe "should display a sortable list of locations" do #without user sign-in + describe "displays a sortable list of locations" do #without user sign-in before do @my_location = create(:location) end @@ -28,7 +28,7 @@ end end - it "should create a new location" do + it "creates a new location" do @user = create(:user) region = create(:region, name: "Green Hill Zone") @@ -83,12 +83,12 @@ end end - it "should not create a new location if user is not signed in" do + it "does not create a new location if user is not signed in" do visit new_location_path expect(page).to have_content("You need to sign in or sign up before continuing") end - it "should not allow location editing if user is not signed in" do + it "does not allow location editing if user is not signed in" do @location = create(:location) visit edit_location_path(@location.id) expect(page).to have_content("You need to sign in or sign up before continuing") diff --git a/spec/features/users/profiles_request_spec.rb b/spec/features/users/profiles_request_spec.rb index 80e025027..64e39cf5e 100644 --- a/spec/features/users/profiles_request_spec.rb +++ b/spec/features/users/profiles_request_spec.rb @@ -38,7 +38,7 @@ expect(page).to have_content("Linux") end - it "user should be able to add his/her skills" do + it "allows user to add skills" do skill_settings = { "Childcare" => false, "Writer" => false, @@ -91,7 +91,7 @@ event.rsvps << create(:rsvp, user: @user, event: event) end - it "should be able to see workshop history" do + it "is able to see workshop history" do visit user_profile_path(@user) expect(page).to have_content("Workshop History") expect(page).to have_content("BridgeBridge") diff --git a/spec/features/users/sign_in_menu_request_spec.rb b/spec/features/users/sign_in_menu_request_spec.rb index 17f884ca4..60a85138b 100644 --- a/spec/features/users/sign_in_menu_request_spec.rb +++ b/spec/features/users/sign_in_menu_request_spec.rb @@ -6,14 +6,14 @@ @user = create(:user) end - it "should show on home page on click" do + it "shows on home page on click" do visit "/" page.find('#sign_in_dialog', visible: false) click_link('Sign In') page.find('#sign_in_dialog', visible: true) end - it "should not show if signed in" do + it "does not show if signed in" do sign_in_as(@user) visit "/" expect(page).to have_link("Sign Out") @@ -73,7 +73,7 @@ @user = create(:user) end - it "should be able to sign in from the home page" do + it "can sign in from the home page" do visit "/" within("#sign_in_dialog") do fill_in "Email", with: @user.email