>>57aa1b (lb)
Sorry if this was covered already but I'm typing on mobile and it took awhile.
This looks like a basic form of js without the usual brackets. I imagine it does just like it reads to humans.
>def visit_twitter_and_log_in
Starts definition of a method (executable code that resolves to a defined value after it ends running) named "visit_twitter_and_log_in".
> visit 'https://cards-dev.twitter.com/validator'
First step, execute method named "visit" to assumably navigate to a subdomain of Twitter, "cards-dev". The name it implies cards for devs to use on their own sites/apps. Cards are the visual widgets you interact with on sites, like to validate your user login with Twitter or Google, etc. This is going to the validator card for Twitter, aka Log In.
>> find('input.js-username-field').set(ENV['TWITTER_USERNAME'])
Selects the username field on the card and adds the username which is stored in the environment file. Env is common to hold such info.
>> find('input.js-password-field').set(ENV['TWITTER_PASSWORD'])
Same as above but with password field.
>> click_on('Log in')
Navigates to "Log In" element to submit the form.
>> end
End first step.
>> def enter_url_and_click_preview(url)
Start defining a private method that exists in the top level method and executes every time the top level method executes. This one is called "enter_url_and_click_preview" and takes a URL as an argument (data passed in to the method for use inside of it).
>> find('input.FormControl').set(url)
Finds the form input coming from the URL, which I imagine is the output from step 1.
> click_on('Preview card')
Clicks on the preview of the card
>> result = has_content?('Page fetched successfully')
Stores a True or False value in variable named "result". The Boolean tests whether the page content sent via the URL has content. If so, provide preview. If false, move on.
>> visit 'https://cards-dev.twitter.com/validator'
Visit the same validator card as above, aka log in
>> end
Ends second step
>>end
Ends top level method
This might be code for a bit to log in to Twitter.
The env holding user credentials could be swapped around automatically without Twitter being any the wiser.