Last active
June 28, 2020 02:28
-
-
Save zetter/0c3cfcb503849d4f9ce5 to your computer and use it in GitHub Desktop.
Enrolment cucumber-like rspec feature spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
I love this.