Skip to content

Instantly share code, notes, and snippets.

@vandamon
Forked from zetter/enrolment_cuke_spec.rb
Created June 28, 2020 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vandamon/56489b7342cbdca7ca3b157033f2701f to your computer and use it in GitHub Desktop.
Save vandamon/56489b7342cbdca7ca3b157033f2701f to your computer and use it in GitHub Desktop.
Enrolment cucumber-like rspec feature spec
feature 'Enrolment' do
scenario 'Enrolling in a course' do
given_there_is_a_course
and_i_am_logged_in_as_a_learner
when_i_enrol_on_a_course
then_the_course_should_appear_in_my_courses
end
def given_there_is_a_course
@course = FactoryGirl.create(:course)
end
def and_i_am_logged_in_as_a_learner
@learner = FactoryGirl.create(:learner)
login_as @learner
end
def when_i_enrol_on_a_course
visit course_path(@course)
find('.join').click
expect(page).to have_content('Thanks for joining!')
end
def then_the_course_should_appear_in_my_courses
visit '/'
expect(page).to have_main_header('My Courses')
expect(page).to have_content(@course.full_title)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment