lib/testingbot.rb in testingbot-0.0.6 vs lib/testingbot.rb in testingbot-0.0.7
- old
+ new
@@ -114,31 +114,33 @@
session_id = nil
if !@selenium_driver.nil?
session_id = @selenium_driver.session_id_backup
elsif defined?(Capybara)
- session_id = Capybara.drivers[:testingbot].call.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
+ begin
+ session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
+ rescue Exception => e
+ p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
+ end
end
- if session_id.nil?
- return
- end
-
- params = {
- "session_id" => session_id,
- "client_key" => client_key,
- "client_secret" => client_secret,
- "status_message" => @execution_error,
- "success" => !actual_failure?,
- "name" => description.to_s,
- "kind" => 2,
- "extra" => @selenium_driver.extra
- }
+ if !session_id.nil?
+ params = {
+ "session_id" => session_id,
+ "client_key" => client_key,
+ "client_secret" => client_secret,
+ "status_message" => @execution_error,
+ "success" => !actual_failure?,
+ "name" => description.to_s,
+ "kind" => 2,
+ "extra" => @selenium_driver.extra
+ }
- url = URI.parse('http://testingbot.com/hq')
- http = Net::HTTP.new(url.host, url.port)
- response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
+ url = URI.parse('http://testingbot.com/hq')
+ http = Net::HTTP.new(url.host, url.port)
+ response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
+ end
else
puts "Can't post test results to TestingBot since I could not a .testingbot file in your home-directory."
end
end
end
@@ -148,10 +150,11 @@
# rspec 2
begin
require 'rspec'
::RSpec.configuration.after :each do
+ p
if File.exists?(File.expand_path("~/.testingbot"))
str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
client_key, client_secret = str.split(':')
test_name = ""
@@ -164,33 +167,35 @@
session_id = nil
if !@selenium_driver.nil?
session_id = @selenium_driver.session_id_backup
elsif defined?(Capybara)
- session_id = Capybara.drivers[:testingbot].call.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
+ begin
+ session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
+ rescue Exception => e
+ p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
+ end
end
- if session_id.nil?
- return
- end
+ if !session_id.nil?
+ params = {
+ "session_id" => session_id,
+ "client_key" => client_key,
+ "client_secret" => client_secret,
+ "status_message" => @execution_error,
+ "success" => example.exception.nil?,
+ "name" => test_name,
+ "kind" => 2
+ }
- params = {
- "session_id" => session_id,
- "client_key" => client_key,
- "client_secret" => client_secret,
- "status_message" => @execution_error,
- "success" => example.exception.nil?,
- "name" => test_name,
- "kind" => 2
- }
-
- if @selenium_driver && @selenium_driver.extra
- params["extra"] = @selenium_driver.extra
- end
+ if @selenium_driver && @selenium_driver.extra
+ params["extra"] = @selenium_driver.extra
+ end
- url = URI.parse('http://testingbot.com/hq')
- http = Net::HTTP.new(url.host, url.port)
- response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
+ url = URI.parse('http://testingbot.com/hq')
+ http = Net::HTTP.new(url.host, url.port)
+ response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
+ end
else
puts "Can't post test results to TestingBot since I could not a .testingbot file in your home-directory."
end
end
rescue LoadError
\ No newline at end of file