class LearnTest::Strategy

Attributes

options[R]
runner[R]

Public Class Methods

new(runner) click to toggle source
# File lib/learn_test/strategy.rb, line 7
def initialize(runner)
  @runner  = runner
  @options = runner.options
end

Public Instance Methods

argv() click to toggle source
# File lib/learn_test/strategy.rb, line 50
def argv
  options[:argv]
end
check_dependencies() click to toggle source
# File lib/learn_test/strategy.rb, line 16
def check_dependencies; end
cleanup() click to toggle source
# File lib/learn_test/strategy.rb, line 36
def cleanup; end
configure() click to toggle source
# File lib/learn_test/strategy.rb, line 18
def configure; end
die(message) click to toggle source
# File lib/learn_test/strategy.rb, line 54
def die(message)
  puts message.red
  exit
end
learn_oauth_token() click to toggle source
# File lib/learn_test/strategy.rb, line 46
def learn_oauth_token
  @learn_oauth_token ||= LearnTest::LearnOauthTokenParser.get_learn_oauth_token
end
output() click to toggle source
# File lib/learn_test/strategy.rb, line 24
def output
  raise NotImplementedError, 'you must implement how the test gets its raw output'
end
push_results?() click to toggle source
# File lib/learn_test/strategy.rb, line 32
def push_results?
  true
end
results() click to toggle source
# File lib/learn_test/strategy.rb, line 28
def results
  output
end
run() click to toggle source
# File lib/learn_test/strategy.rb, line 20
def run
  raise NotImplementedError, 'you must implement how this strategy runs its tests'
end
run_install(command, npm_install: false) click to toggle source

npm_install option added to fix the proxying of the npm install progress bar output.

# File lib/learn_test/strategy.rb, line 62
def run_install(command, npm_install: false)
  if npm_install
    system(command)
  else
    Open3.popen3(command) do |_, stdout, stderr, wait_thr|
      while out = stdout.gets do
        puts out
      end

      while err = stderr.gets do
        puts err
      end

      if wait_thr.value.exitstatus != 0
        die("There was an error running #{command}")
      end
    end
  end
end
service_endpoint() click to toggle source
# File lib/learn_test/strategy.rb, line 12
def service_endpoint
  raise NotImplementedError, 'you must add the service endpoint to the test strategy'
end
user_id() click to toggle source
# File lib/learn_test/strategy.rb, line 42
def user_id
  @user_id ||= LearnTest::UserIdParser.get_user_id
end
username() click to toggle source
# File lib/learn_test/strategy.rb, line 38
def username
  @username ||= LearnTest::UsernameParser.get_username
end