Skip to content

Instantly share code, notes, and snippets.

@zetter
Last active June 28, 2020 02:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zetter/0c3cfcb503849d4f9ce5 to your computer and use it in GitHub Desktop.
Save zetter/0c3cfcb503849d4f9ce5 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
@ReganRyanNZ
Copy link

I love this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment