???RSpec??д???п???????????
???????????? ???????[ 2014/8/28 11:43:51 ] ??????????????? ??????? ???
????Chris Zetter??FutureLearn?????????????????????????????????С??????????????????????????????????Cucumber?滻?RSpec????????????д??????
?????????????????????????????????????????????????FutureLearn??????????1??????????????д????????????????????Щ?1?????????????????????????????????????????
???????????????Cucumber
????Cucumber???????????д??????????ù??????????????????????????????????????????????????????????д???????????????????
Feature: Enrolment
Scenario: Enrolling in a course
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'
???????????????Cucumber????????????????????±?д?????ü????У?????д????????????????????Cucumber???Щ??????????????????????????????????RSpec????????Cucumber??ζ??????????????????????Σ??????????DSLs????????????????????????????????л???????????????????????????Cucumber???????????????????Ruby?????????????????????????????????????
??????д?????RSpec features
??????????????????????????????????????Cucumber???
?????????????????RSpec features?????Cucumber?????????????????????????
feature 'Enrolment' do
scenario 'Enrolling in a course' do
course = FactoryGirl.create(:course)
learner = FactoryGirl.create(:learner)
login_as learner
visit course_path(course)
find('.join').click
expect(page).to have_content('Thanks for joining!')
visit '/'
expect(page).to have_main_header('My Courses')
expect(page).to have_content(course.full_title)
end
end
?????????????????ú???????????????便???????Щ????????????????????Arrange?? Act?? Assert????Cucumber????????’Given’??’When’??’Then’????Щ?????????????????????Щ?????????????????????????Щ?????????????????????????????????????Щ???????????????????
????????????????????????????д?????????????????????????????????????????????????????????????β????????????????????Cucumber???????????Щ????????????????????ɡ?
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
?????????кη???
??????????????????Cucumber?????????????????д??????????RSpec features??????д??????????????????Cucumber????????????????ò????????????д???????
????????????????????????????????features????????????????и????????????????????ò????????????????????д???feature?μ????scenario????????????????д????á?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11