18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/saucer/config/sauce.rb', line 18
def initialize(opt = {})
opt[:browser_name] ||= ENV['BROWSER']
opt[:platform] ||= ENV['PLATFORM']
opt[:version] ||= ENV['VERSION']
@gems = {}
Bundler.definition.specs.map(&:name).each do |gem_name|
next if Bundler.environment.specs.to_hash[gem_name].empty?
@gems[gem_name] = Bundler.environment.specs.to_hash[gem_name].first.version.version
end
@selenium = @gems['selenium-webdriver']
frameworks = @gems.select { |gem| FRAMEWORKS.include? gem }
@framework = frameworks.first if frameworks.size == 1
page_objects = @gems.select { |gem| PAGE_OBJECTS.include? gem }
@page_object = page_objects.first if page_objects.size == 1
@name = opt[:name] if opt.key? :name
@build = opt[:build] || ENV['BUILD_TAG'] || "Build - #{Time.now.to_i}"
if RSpec.respond_to?(:current_example) && !RSpec.current_example.nil?
@name ||= RSpec.current_example.full_description
@location = RSpec.current_example.location
@harness = ["rspec", @gems["rspec"]]
elsif @@scenario
@name ||= @@scenario.source.map(&:name).join(" ")
@location = @@scenario.location.to_s
@harness = ["cucumber", @gems["cucumber"]]
end
@language = 'Ruby'
@host_os = ::Selenium::WebDriver::Platform.os
@version = ::Selenium::WebDriver::Platform.ruby_version
@ci = ::Selenium::WebDriver::Platform.ci
@ip = ::Selenium::WebDriver::Platform.ip
end
|