Plis I wish indications a site to train automated software testing [closed] - ruby

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
describe 'Visit script' do
it 'visitar a pagina' do
puts "visitando a pagina"
visit "https://www.google.com/"
expect(page.title).to eql "Google"
end

Don't use the standard RSpec matchers with Capybara objects - the standard matchers don't have waiting/retrying behavior. Instead use the Capybara provided matchers
it 'visitar a pagina' do
puts "visitando a pagina"
visit "https://www.google.com/"
expect(page).to have_title("Google")
end

Related

How to download video via viddl-rb? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to download video files from youtube.com, according links from my database.
I found gem viddl-rb, but I see only console way to download in documentation - viddl-rb youtube.com/watch/myvideoid
How to download video, using require viddl-rb in console?
Please be warned that it may be against Youtube's ToS to download videos from Youtube; but anyways, following code might help you do it:
require 'open-uri'
require 'viddl-rb'
YouTubeLinks = %w[
https://www.youtube.com/watch?v=Z8wLQ3NCBgg
https://www.youtube.com/watch?v=QH2-TGUlwu4
]
youtube_hashes = YouTubeLinks.map do |link|
ViddlRb.get_urls_names(link).first
end
youtube_hashes.each do |yt|
puts "Downloading: #{yt[:name]}"
File.open(yt[:name], 'wb') do |video_file|
open(yt[:url]) { |video| video_file.write video.read }
end
end

rubymine column selection mode select few lines [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm trying to edit in column selection mode on Rubymine but I have some lines I wish to skip.
In the code below I would like to edit both "to_change" at the same time.
I wish to duplicate the cursor and every edit action will occur in them both.
In this code if I will select the start of both "to_change" and press '#', the code here:
def a
to_change
end
def b
to_change
end
will turn to
def a
#to_change
end
def b
#to_change
end
Multiple selection/editing is not supported yet, you can follow this feature request.

Time difference compare to presence like Twitter in Ruby [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Is there a gem or another easy way to get time difference compare to present time like Twitter?
Of course I can write it myself, but I don't want to reinvent the wheel.
If you are using rails, you could do
distance_of_time_in_words_to_now #user.created_at
#=> "15 days"
or
time_ago_in_words #post.created_at
#=> "about 13 hours"

How to refactor following unless statement in Ruby [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
While learning Ruby, I got stucked with unless statement. Doing a full unless statement is sometimes too much. Please refactor the method below to use a single-line unless statement
games = ["Super Mario Bros.", "Contra", "Metroid", "Mega Man 2"]
unless games.empty?
puts "Games in your vast collection: #{games.count}"
end
This code doesn't changes the unless statement to be inline, Please help me to modify this code so that it may work, Thanks.
use then
games = ["Super Mario Bros.", "Contra", "Metroid", "Mega Man 2"]
puts "Games in your vast collection: #{games.count}" unless games.empty?
# >> Games in your vast collection: 4

Should I use File.write? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I recently run into problems converting a ruby script to .EXE because I had a File.write statement in it. The documentation doesn't mention the write method but when I do a
pp File.methods
it is there. So should I use File.write? In a normal Ruby script the following works
File.write("test.txt", "test")
But is it good practice and why doesn't the documentation mention it?
File.write is in fact IO.write (File is a child of IO) which can be verified by monkey-patching:
class IO
def IO.write
puts "IO's class method write was called."
end
end
File.write # outputs "IO's class method write was called."
It is very well in the documentation.
Thus, I see no reason not to use it.

Resources