Skip to content

Commit

Permalink
Feature specs: get rid of 'should' (in names) and most usages of 'given'
Browse files Browse the repository at this point in the history
  • Loading branch information
tjgrathwell committed Mar 28, 2017
1 parent 5ffa3bf commit e596151
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 67 deletions.
6 changes: 3 additions & 3 deletions spec/features/events/event_detail_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
24 changes: 17 additions & 7 deletions spec/features/events/event_listing_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
24 changes: 12 additions & 12 deletions spec/features/events/event_rsvp_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,15 +39,15 @@ 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"
visit edit_user_registration_path
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"
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -87,24 +87,24 @@ 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)
expect(page).to_not have_content(food_text)
end
end

context 'given an rsvp with dietary restrictions' do
context 'with an rsvp with dietary restrictions' do
let(:rsvp) {
create(:rsvp,
user: @user,
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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!"
Expand Down
28 changes: 15 additions & 13 deletions spec/features/events/event_survey_request_spec.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -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!"
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions spec/features/events/new_event_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
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?"
expect(page).to have_field(label)
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")
Expand All @@ -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)
Expand All @@ -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')
Expand Down Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions spec/features/events/organizer/attendee_details_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/features/events/organizer/event_email_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit e596151

Please sign in to comment.