0
0
Ruby on Railsframework~10 mins

System tests with Capybara in Ruby on Rails - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to visit the home page in a system test.

Ruby on Rails
visit [1]
Drag options to blanks, or click blank then click option'
A"/index"
B"/"
C"/home"
D"/dashboard"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a path that does not exist like "/home" or "/index".
Forgetting to put quotes around the path.
2fill in blank
medium

Complete the code to check if the page has the text 'Welcome'.

Ruby on Rails
expect(page).to have_content([1])
Drag options to blanks, or click blank then click option'
A'Welcome'
B'Hello'
C'Goodbye'
D'Home'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for the wrong text like 'Hello' or 'Goodbye'.
Forgetting to put quotes around the text.
3fill in blank
hard

Fix the error in the code to fill in a form field labeled 'Email'.

Ruby on Rails
fill_in [1], with: 'user@example.com'
Drag options to blanks, or click blank then click option'
A'Email'
B'email'
C:email
D:Email
Attempts:
3 left
💡 Hint
Common Mistakes
Using symbols instead of strings for labels.
Using wrong case like 'email' instead of 'Email'.
4fill in blank
hard

Fill both blanks to click a button labeled 'Submit' and then check the page has 'Success'.

Ruby on Rails
click_button([1])
expect(page).to have_content([2])
Drag options to blanks, or click blank then click option'
A'Submit'
B'Success'
C'Failed'
D'Cancel'
Attempts:
3 left
💡 Hint
Common Mistakes
Clicking the wrong button label.
Checking for wrong text after clicking.
5fill in blank
hard

Fill all three blanks to fill in 'Name', select 'Male' from 'Gender', and submit the form.

Ruby on Rails
fill_in [1], with: 'John'
select [2], from: 'Gender'
click_button [3]
Drag options to blanks, or click blank then click option'
A'Name'
B'Male'
C'Submit'
D'Female'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong labels or options.
Forgetting quotes around labels.