Method: Cyperful.setup

Defined in:
lib/cyperful.rb

.setup(test_class, test_name) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cyperful.rb', line 53

def self.setup(test_class, test_name)
  @test_framework =
    if defined?(RSpec::Core::ExampleGroup) &&
         test_class < RSpec::Core::ExampleGroup
      :rspec
    elsif defined?(ActiveSupport::TestCase) &&
          test_class < ActiveSupport::TestCase
      :minitest
    else
      raise "Unsupported test framework for class: #{test_class.name}"
    end

  logger.puts "init test: \"#{rspec? ? test_name : "#{test_class}##{test_name}"}\""

  # must set `Cyperful.current` before calling `async_setup`
  @current ||= Cyperful::Driver.new
  @current.set_current_test(test_class, test_name)

  nil
rescue => err
  unless err.is_a?(Cyperful::AbstractCommand)
    warn "Error setting up Cyperful:\n\n#{err.message}\n#{err.backtrace.slice(0, 4).join("\n")}\n"
  end

  raise err
end