Class: HowFast::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/how_fast/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/how_fast/cli.rb', line 3

def call
  puts "Beep, boop, beep. Beginning speed test..."

  session = Capybara.current_session
  session.visit("https://fast.com/")

  while !session.has_css?('.speed-results-container.succeeded')
    print_phrase
    sleep 1
  end

  speed = session.find_by_id('speed-value').text
  units = session.find_by_id('speed-units').text
  
  puts ""
  puts "YOUR SPEED IS: #{speed} #{units}"
end


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/how_fast/cli.rb', line 21

def print_phrase
  phrases = [
    "Hang tight, we're almost there...", 
    "Still movin'...", 
    "Patience is a virtue...", 
    "There's light at the end of the tunnel...",
    "Chug, chug, chug...",
    "So, how's your day going?",
    "Life is too short to have slow internet.",
    "Making progress...",
    "Wait for it..."
  ]

  puts phrases.sample
end