sauce 0.14.2 → 0.15.0.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -1,32 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "sauce"
8
- gem.summary = "Ruby access to Sauce Labs' features"
9
- gem.description = "A Ruby interface to Sauce Labs' services. Start/stop tunnels, retrieve Selenium logs, access video replays, etc."
10
- gem.email = "help@saucelabs.com"
11
- gem.homepage = "http://github.com/saucelabs/sauce"
12
- gem.authors = ["Sean Grove", "Eric Allen", "Steven Hazel"]
13
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
- gem.add_development_dependency "jeweler", ">= 1.4.0"
15
- gem.add_runtime_dependency "rest-client", ">= 0"
16
- gem.add_runtime_dependency "net-ssh", ">= 0"
17
- gem.add_runtime_dependency "net-ssh-gateway", ">= 0"
18
- gem.add_runtime_dependency "selenium-webdriver", ">= 0.1.2"
19
- gem.add_runtime_dependency "childprocess", ">= 0.1.6"
20
- gem.add_runtime_dependency "json", ">= 1.2.0"
21
- gem.add_runtime_dependency "cmdparse", ">= 2.0.2"
22
- gem.add_runtime_dependency "highline", ">= 1.5.0"
23
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
24
- end
25
- Jeweler::GemcutterTasks.new
26
- rescue LoadError
27
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
28
- end
29
-
30
4
  require 'rake/testtask'
31
5
  Rake::TestTask.new(:test) do |test|
32
6
  test.libs << 'lib' << 'test'
@@ -42,7 +16,7 @@ namespace :test do
42
16
  end
43
17
  Rake::TestTask.new(:integrations) do |test|
44
18
  test.libs << 'lib' << 'test'
45
- test.pattern = 'test/integrations/test_*.rb'
19
+ test.pattern = 'test/test_integrations.rb'
46
20
  test.verbose = true
47
21
  end
48
22
  end
@@ -66,8 +40,6 @@ rescue LoadError
66
40
  end
67
41
  end
68
42
 
69
- task :test => :check_dependencies
70
-
71
43
  task :default => :test
72
44
 
73
45
  require 'rake/rdoctask'
@@ -0,0 +1,54 @@
1
+ module Sauce
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../templates", __FILE__)
5
+
6
+ desc "Prep application for Sauce OnDemand Selenium tests"
7
+
8
+ argument :username, :type => :string, :required => false
9
+ argument :api_key, :type => :string, :required => false
10
+
11
+ def copy_rake_tasks
12
+ copy_file "sauce.rake", "lib/tasks/sauce.rake"
13
+ end
14
+
15
+ def configure_credentials
16
+ if username
17
+ system("sauce config #{username} #{api_key}")
18
+ end
19
+ end
20
+
21
+ def setup_spec
22
+ if File.directory? 'spec'
23
+ empty_directory "spec/selenium"
24
+ append_file "spec/spec_helper.rb", generate_config
25
+ end
26
+ end
27
+
28
+ def setup_test
29
+ if File.directory? 'test'
30
+ empty_directory "test/selenium"
31
+ append_file "test/test_helper.rb", generate_config
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def generate_config
38
+ @random_id ||= rand(100000)
39
+ return <<-CONFIG
40
+ require 'sauce'
41
+
42
+ Sauce.config do |conf|
43
+ conf.browser_url = "http://#{@random_id}.test/"
44
+ conf.browsers = [
45
+ ["Windows 2003", "firefox", "3."]
46
+ ]
47
+ conf.application_host = "127.0.0.1"
48
+ conf.application_port = "3001"
49
+ end
50
+ CONFIG
51
+ end
52
+ end
53
+ end
54
+ end
data/lib/sauce/config.rb CHANGED
@@ -36,6 +36,7 @@ module Sauce
36
36
  @opts.merge! DEFAULT_OPTIONS
37
37
  @opts.merge! load_options_from_yaml
38
38
  @opts.merge! load_options_from_environment
39
+ @opts.merge! load_options_from_heroku
39
40
  @opts.merge! Sauce.get_config.opts rescue {}
40
41
  @opts.merge! opts
41
42
  end
@@ -80,30 +81,31 @@ module Sauce
80
81
  private
81
82
 
82
83
  def load_options_from_environment
83
- opts = {}
84
- opts[:host] = ENV['SAUCE_HOST']
85
- opts[:port] = ENV['SAUCE_PORT']
86
- opts[:browser_url] = ENV['SAUCE_BROWSER_URL']
87
-
88
- opts[:username] = ENV['SAUCE_USERNAME']
89
- opts[:access_key] = ENV['SAUCE_ACCESS_KEY']
90
-
91
- opts[:os] = ENV['SAUCE_OS']
92
- opts[:browser] = ENV['SAUCE_BROWSER']
93
- opts[:browser_version] = ENV['SAUCE_BROWSER_VERSION']
94
- opts[:job_name] = ENV['SAUCE_JOB_NAME']
95
-
96
- opts[:firefox_profile_url] = ENV['SAUCE_FIREFOX_PROFILE_URL']
97
- opts[:user_extensions_url] = ENV['SAUCE_USER_EXTENSIONS_URL']
84
+ return extract_options_from_hash(ENV)
85
+ end
98
86
 
99
- return opts.delete_if {|key, value| value.nil?}
87
+ def load_options_from_heroku
88
+ @@herkou_environment ||= begin
89
+ buffer = IO.popen("heroku config --shell") { |out| out.read }
90
+ if $?.exitstatus == 0
91
+ env = {}
92
+ buffer.split("\n").each do |line|
93
+ key, value = line.split("=")
94
+ env[key] = value
95
+ end
96
+ extract_options_from_hash(env)
97
+ else
98
+ {}
99
+ end
100
+ end
101
+ return @@herkou_environment
100
102
  end
101
103
 
102
104
  def load_options_from_yaml
103
105
  paths = [
104
106
  "ondemand.yml",
105
107
  File.join("config", "ondemand.yml"),
106
- File.join(File.dirname(File.dirname(File.expand_path(File.dirname(__FILE__)))), "ondemand.yml"),
108
+ File.expand_path("../../../ondemand.yml", __FILE__),
107
109
  File.join(File.expand_path("~"), ".sauce", "ondemand.yml")
108
110
  ]
109
111
 
@@ -115,5 +117,34 @@ module Sauce
115
117
  end
116
118
  return {}
117
119
  end
120
+
121
+ def extract_options_from_hash(env)
122
+ opts = {}
123
+ opts[:host] = env['SAUCE_HOST']
124
+ opts[:port] = env['SAUCE_PORT']
125
+ opts[:browser_url] = env['SAUCE_BROWSER_URL']
126
+
127
+ opts[:username] = env['SAUCE_USERNAME']
128
+ opts[:access_key] = env['SAUCE_ACCESS_KEY']
129
+
130
+ opts[:os] = env['SAUCE_OS']
131
+ opts[:browser] = env['SAUCE_BROWSER']
132
+ opts[:browser_version] = env['SAUCE_BROWSER_VERSION']
133
+ opts[:job_name] = env['SAUCE_JOB_NAME']
134
+
135
+ opts[:firefox_profile_url] = env['SAUCE_FIREFOX_PROFILE_URL']
136
+ opts[:user_extensions_url] = env['SAUCE_USER_EXTENSIONS_URL']
137
+
138
+ if env.include? 'URL'
139
+ opts['SAUCE_BROWSER_URL'] = "http://#{env['URL']}/"
140
+ end
141
+
142
+ if env.include? 'SAUCE_BROWSERS'
143
+ browsers = JSON.parse(env['SAUCE_BROWSERS'])
144
+ opts[:browsers] = browsers.map { |x| [x['os'], x['browser'], x['version']] }
145
+ end
146
+
147
+ return opts.delete_if {|key, value| value.nil?}
148
+ end
118
149
  end
119
150
  end
data/lib/sauce/connect.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Sauce
2
2
  class Connect
3
+ TIMEOUT = 300
4
+
3
5
  attr_reader :status, :error
4
6
 
5
7
  def initialize(options={})
@@ -14,7 +16,7 @@ module Sauce
14
16
  options.delete(:tunnel_port)
15
17
  config = Sauce::Config.new(options)
16
18
  args = ['-u', config.username, '-k', config.access_key, '-s', host, '-p', port, '-d', config.domain, '-t', tunnel_port]
17
- @pipe = IO.popen(([Sauce::Connect.find_sauce_connect] + args).join(' '))
19
+ @pipe = IO.popen((["exec", "\"#{Sauce::Connect.find_sauce_connect}\""] + args).join(' '))
18
20
  at_exit do
19
21
  Process.kill("INT", @pipe.pid)
20
22
  while @ready
@@ -39,9 +41,14 @@ module Sauce
39
41
  end
40
42
 
41
43
  def wait_until_ready
42
- while(!@ready)
44
+ start = Time.now
45
+ while !@ready and (Time.now-start) < TIMEOUT
43
46
  sleep 0.4
44
47
  end
48
+
49
+ if !@ready
50
+ raise "Sauce Connect failed to connect after #{TIMEOUT} seconds"
51
+ end
45
52
  end
46
53
 
47
54
  def disconnect
@@ -14,16 +14,19 @@ begin
14
14
 
15
15
  before :suite do
16
16
  config = Sauce::Config.new
17
- if @@need_tunnel && config.application_host && !config.local?
18
- @@tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
19
- @@tunnel.wait_until_ready
17
+ if @@need_tunnel
18
+ if config.application_host && !config.local?
19
+ @@tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
20
+ @@tunnel.wait_until_ready
21
+ end
22
+ @@server = Sauce::Utilities::RailsServer.new
23
+ @@server.start
20
24
  end
21
25
  end
22
26
 
23
27
  after :suite do
24
- if defined? @@tunnel
25
- @@tunnel.disconnect
26
- end
28
+ @@tunnel.disconnect if defined? @@tunnel
29
+ @@server.stop if defined? @@server
27
30
  end
28
31
 
29
32
  def execute(*args)
@@ -102,11 +105,15 @@ begin
102
105
  @@tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
103
106
  @@tunnel.wait_until_ready
104
107
  end
108
+
109
+ if ::RSpec.configuration.settings[:files_to_run].any? {|file| file =~ /spec\/selenium\//}
110
+ @@server = Sauce::Utilities::RailsServer.new
111
+ @@server.start
112
+ end
105
113
  end
106
114
  ::RSpec.configuration.after :suite do
107
- if defined? @@tunnel
108
- @@tunnel.disconnect
109
- end
115
+ @@tunnel.disconnect if defined? @@tunnel
116
+ @@server.stop if defined? @@server
110
117
  end
111
118
  end
112
119
  end
@@ -177,11 +184,12 @@ begin
177
184
  @sauce_tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
178
185
  @sauce_tunnel.wait_until_ready
179
186
  end
187
+ @server = Sauce::Utilities::RailsServer.new
188
+ @server.start
180
189
  end
181
190
  result = run_without_tunnel.bind(self).call(*args)
182
- if defined? @sauce_tunnel
183
- @sauce_tunnel.disconnect
184
- end
191
+ @sauce_tunnel.disconnect if defined? @sauce_tunnel
192
+ @server.stop if defined? @server
185
193
  return result
186
194
  end
187
195
  end
@@ -206,11 +214,13 @@ begin
206
214
  @sauce_tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
207
215
  @sauce_tunnel.wait_until_ready
208
216
  end
217
+
218
+ @server = Sauce::Utilities::RailsServer.new
219
+ @server.start
209
220
  end
210
221
  result = run_without_tunnel.bind(self).call(*args)
211
- if defined? @sauce_tunnel
212
- @sauce_tunnel.disconnect
213
- end
222
+ @sauce_tunnel.disconnect if defined? @sauce_tunnel
223
+ @server.stop if defined? @server
214
224
  return result
215
225
  end
216
226
  end
@@ -17,17 +17,13 @@ if defined?(Spec::Rake::SpecTask)
17
17
  namespace :selenium do
18
18
  desc "Run the Selenium acceptance tests in spec/selenium using Sauce OnDemand"
19
19
  task :sauce => spec_prereq do
20
- with_rails_server do
21
- Rake::Task["spec:selenium:runtests"].invoke
22
- end
20
+ Rake::Task["spec:selenium:runtests"].invoke
23
21
  end
24
22
 
25
23
  desc "Run the Selenium acceptance tests in spec/selenium using a local Selenium server"
26
24
  task :local => spec_prereq do
27
- with_rails_server do
28
- with_selenium_rc do
29
- Rake::Task["spec:selenium:runtests"].invoke
30
- end
25
+ with_selenium_rc do
26
+ Rake::Task["spec:selenium:runtests"].invoke
31
27
  end
32
28
  end
33
29
 
@@ -55,17 +51,13 @@ if defined?(RSpec::Core::RakeTask)
55
51
  namespace :selenium do
56
52
  desc "Run the Selenium acceptance tests in spec/selenium using Sauce OnDemand"
57
53
  task :sauce => spec_prereq do
58
- with_rails_server do
59
- Rake::Task["spec:selenium:runtests"].invoke
60
- end
54
+ Rake::Task["spec:selenium:runtests"].invoke
61
55
  end
62
56
 
63
57
  desc "Run the Selenium acceptance tests in spec/selenium using a local Selenium server"
64
58
  task :local => spec_prereq do
65
- with_rails_server do
66
- with_selenium_rc do
67
- Rake::Task["spec:selenium:runtests"].invoke
68
- end
59
+ with_selenium_rc do
60
+ Rake::Task["spec:selenium:runtests"].invoke
69
61
  end
70
62
  end
71
63
 
@@ -84,17 +76,13 @@ namespace :test do
84
76
  namespace :selenium do
85
77
  desc "Run the Selenium acceptance tests in test/selenium using Sauce OnDemand"
86
78
  task :sauce do
87
- with_rails_server do
88
- Rake::Task["test:selenium:runtests"].invoke
89
- end
79
+ Rake::Task["test:selenium:runtests"].invoke
90
80
  end
91
81
 
92
82
  desc "Run the Selenium acceptance tests in spec/selenium using a local Selenium server"
93
83
  task :local do
94
- with_rails_server do
95
- with_selenium_rc do
96
- Rake::Task["test:selenium:runtests"].invoke
97
- end
84
+ with_selenium_rc do
85
+ Rake::Task["test:selenium:runtests"].invoke
98
86
  end
99
87
  end
100
88
 
@@ -47,24 +47,31 @@ module Sauce
47
47
  end
48
48
  end
49
49
 
50
- def with_rails_server
51
- STDERR.puts "Starting Rails server on port 3001..."
52
- if File.exists?('script/server')
53
- server = IO.popen("ruby script/server -e test --port 3001 --daemon")
54
- elsif File.exists?('script/rails')
55
- server = IO.popen("script/rails server -p 3001 -e test")
50
+ class RailsServer
51
+ include Sauce::Utilities
52
+ def start
53
+ STDERR.puts "Starting Rails server on port 3001..."
54
+ if File.exists?('script/server')
55
+ @server = ChildProcess.build("ruby", "script/server", "-e", "test", "--port", "3001")
56
+ elsif File.exists?('script/rails')
57
+ @server = ChildProcess.build("bundle", "exec", "rails", "server", "-e", "test", "--port", "3001")
58
+ end
59
+ @server.io.inherit!
60
+ @server.start
61
+
62
+ wait_for_server_on_port(3001)
63
+
64
+ at_exit do
65
+ @server.stop
66
+ end
67
+ STDERR.puts "Rails server running!"
56
68
  end
57
69
 
58
- wait_for_server_on_port(3001)
59
- STDERR.puts "Rails server running!"
60
- begin
61
- yield
62
- ensure
70
+ def stop
63
71
  begin
64
- pid = IO.read(File.join('tmp', 'pids', 'server.pid')).to_i
65
- Process.kill("INT", pid)
72
+ @server.stop
66
73
  rescue
67
- STDERR.puts "Rails server could not be killed. Is the pid in #{File.join('tmp', 'pids', 'server.pid')}?"
74
+ STDERR.puts "Rails server could not be killed. Did it fail to start?"
68
75
  end
69
76
  end
70
77
  end
data/sauce.gemspec CHANGED
@@ -1,15 +1,12 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
3
  Gem::Specification.new do |s|
7
4
  s.name = %q{sauce}
8
- s.version = "0.14.2"
5
+ s.version = "0.15.0.alpha.1"
9
6
 
10
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
8
  s.authors = ["Sean Grove", "Eric Allen", "Steven Hazel"]
12
- s.date = %q{2011-01-24}
9
+ s.date = %q{2011-01-26}
13
10
  s.default_executable = %q{sauce}
14
11
  s.description = %q{A Ruby interface to Sauce Labs' services. Start/stop tunnels, retrieve Selenium logs, access video replays, etc.}
15
12
  s.email = %q{help@saucelabs.com}
@@ -23,7 +20,6 @@ Gem::Specification.new do |s|
23
20
  "LICENSE",
24
21
  "README.markdown",
25
22
  "Rakefile",
26
- "VERSION",
27
23
  "bin/sauce",
28
24
  "examples/helper.rb",
29
25
  "examples/other_spec.rb",
@@ -32,8 +28,8 @@ Gem::Specification.new do |s|
32
28
  "examples/test_saucelabs2.rb",
33
29
  "generators/sauce/sauce_generator.rb",
34
30
  "generators/sauce/templates/sauce.rake",
35
- "lib/generators/sauce_generator.rb",
36
- "lib/generators/templates/sauce.rake",
31
+ "lib/generators/sauce/install/install_generator.rb",
32
+ "lib/generators/sauce/install/templates/sauce.rake",
37
33
  "lib/sauce.rb",
38
34
  "lib/sauce/client.rb",
39
35
  "lib/sauce/config.rb",
@@ -56,8 +52,6 @@ Gem::Specification.new do |s|
56
52
  "support/simplejson/ordered_dict.py",
57
53
  "support/simplejson/scanner.py",
58
54
  "support/simplejson/tool.py",
59
- "test/api/test_jobs.rb",
60
- "test/api/test_tunnels.rb",
61
55
  "test/helper.rb",
62
56
  "test/test_config.rb",
63
57
  "test/test_connect.rb",
@@ -73,10 +67,7 @@ Gem::Specification.new do |s|
73
67
  "examples/saucelabs_spec.rb",
74
68
  "examples/test_saucelabs.rb",
75
69
  "examples/test_saucelabs2.rb",
76
- "test/api/test_jobs.rb",
77
- "test/api/test_tunnels.rb",
78
70
  "test/helper.rb",
79
- "test/integrations/test_rails2.rb",
80
71
  "test/test_config.rb",
81
72
  "test/test_connect.rb",
82
73
  "test/test_selenium.rb"
@@ -86,8 +77,6 @@ Gem::Specification.new do |s|
86
77
  s.specification_version = 3
87
78
 
88
79
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
89
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
90
- s.add_development_dependency(%q<jeweler>, [">= 1.4.0"])
91
80
  s.add_runtime_dependency(%q<rest-client>, [">= 0"])
92
81
  s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
93
82
  s.add_runtime_dependency(%q<net-ssh-gateway>, [">= 0"])
@@ -97,8 +86,6 @@ Gem::Specification.new do |s|
97
86
  s.add_runtime_dependency(%q<cmdparse>, [">= 2.0.2"])
98
87
  s.add_runtime_dependency(%q<highline>, [">= 1.5.0"])
99
88
  else
100
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
101
- s.add_dependency(%q<jeweler>, [">= 1.4.0"])
102
89
  s.add_dependency(%q<rest-client>, [">= 0"])
103
90
  s.add_dependency(%q<net-ssh>, [">= 0"])
104
91
  s.add_dependency(%q<net-ssh-gateway>, [">= 0"])
@@ -109,8 +96,6 @@ Gem::Specification.new do |s|
109
96
  s.add_dependency(%q<highline>, [">= 1.5.0"])
110
97
  end
111
98
  else
112
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
113
- s.add_dependency(%q<jeweler>, [">= 1.4.0"])
114
99
  s.add_dependency(%q<rest-client>, [">= 0"])
115
100
  s.add_dependency(%q<net-ssh>, [">= 0"])
116
101
  s.add_dependency(%q<net-ssh-gateway>, [">= 0"])
data/test/helper.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
- require 'shoulda'
4
3
  require 'net/telnet'
4
+ require 'fileutils'
5
5
 
6
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
8
  require 'sauce'
9
9
 
10
+ include Sauce::Utilities
11
+
10
12
  Sauce.config do |config|
11
13
  config.browsers = [
12
14
  ["Windows 2003", "firefox", "3.6."],
@@ -17,3 +19,17 @@ Sauce.config do |config|
17
19
  #config.application_host = "localhost"
18
20
  #config.application_port = "4444"
19
21
  end
22
+
23
+ def ensure_rvm_installed
24
+ rvm_executable = File.expand_path("~/.rvm/bin/rvm")
25
+ if File.exist? rvm_executable
26
+ unless defined?(RVM)
27
+ rvm_lib_path = File.expand_path("~/.rvm/lib")
28
+ $LOAD_PATH.unshift(rvm_lib_path) unless $LOAD_PATH.include?(rvm_lib_path)
29
+ require 'rvm'
30
+ end
31
+ else
32
+ raise "You do not have RVM installed. It is required for the integration tests.\n" +
33
+ "Please install it from http://rvm.beginrescueend.com/"
34
+ end
35
+ end
data/test/test_config.rb CHANGED
@@ -1,75 +1,74 @@
1
- require 'helper'
1
+ require File.expand_path("../helper", __FILE__)
2
2
 
3
3
  class TestConfig < Test::Unit::TestCase
4
- context "A new Config" do
5
- should "Generate a reasonable browser string from the environment" do
6
- preserved_env = {}
7
- Sauce::Config::ENVIRONMENT_VARIABLES.each do |key|
8
- preserved_env[key] = ENV[key] if ENV[key]
9
- end
10
- begin
11
-
12
- ENV['SAUCE_USERNAME'] = "test_user"
13
- ENV['SAUCE_ACCESS_KEY'] = "test_access"
14
- ENV['SAUCE_OS'] = "Linux"
15
- ENV['SAUCE_BROWSER'] = "firefox"
16
- ENV['SAUCE_BROWSER_VERSION'] = "3."
17
-
18
- config = Sauce::Config.new
19
- assert_equal "{\"name\":\"Unnamed Ruby job\",\"access-key\":\"test_access\",\"os\":\"Linux\",\"username\":\"test_user\",\"browser-version\":\"3.\",\"browser\":\"firefox\"}", config.to_browser_string
20
- ensure
21
- Sauce::Config::ENVIRONMENT_VARIABLES.each do |key|
22
- ENV[key] = preserved_env[key] if preserved_env[key]
23
- end
24
- end
4
+ def test_generates_reasonable_browser_string_from_envrionment
5
+ preserved_env = {}
6
+ Sauce::Config::ENVIRONMENT_VARIABLES.each do |key|
7
+ preserved_env[key] = ENV[key] if ENV[key]
25
8
  end
9
+ begin
26
10
 
27
- should "Generate a browser string from parameters" do
28
- config = Sauce::Config.new(:username => "test_user", :access_key => "test_access",
29
- :os => "Linux", :browser => "firefox", :browser_version => "3.")
30
- assert_equal "{\"name\":\"Unnamed Ruby job\",\"access-key\":\"test_access\",\"os\":\"Linux\",\"username\":\"test_user\",\"browser-version\":\"3.\",\"browser\":\"firefox\"}", config.to_browser_string
31
- end
11
+ ENV['SAUCE_USERNAME'] = "test_user"
12
+ ENV['SAUCE_ACCESS_KEY'] = "test_access"
13
+ ENV['SAUCE_OS'] = "Linux"
14
+ ENV['SAUCE_BROWSER'] = "firefox"
15
+ ENV['SAUCE_BROWSER_VERSION'] = "3."
32
16
 
33
- should "Respond to convenience accessors" do
34
17
  config = Sauce::Config.new
35
- assert_equal "saucelabs.com", config.host
18
+ assert_equal "{\"name\":\"Unnamed Ruby job\",\"access-key\":\"test_access\",\"os\":\"Linux\",\"username\":\"test_user\",\"browser-version\":\"3.\",\"browser\":\"firefox\"}", config.to_browser_string
19
+ ensure
20
+ Sauce::Config::ENVIRONMENT_VARIABLES.each do |key|
21
+ ENV[key] = preserved_env[key]
22
+ end
36
23
  end
24
+ end
37
25
 
38
- should "gracefully degrade the browsers field" do
39
- Sauce.config {|c|}
40
- config = Sauce::Config.new
41
- config.os = "A"
42
- config.browser = "B"
43
- config.browser_version = "C"
26
+ def test_generates_browser_string_from_parameters
27
+ config = Sauce::Config.new(:username => "test_user", :access_key => "test_access",
28
+ :os => "Linux", :browser => "firefox", :browser_version => "3.")
29
+ assert_equal "{\"name\":\"Unnamed Ruby job\",\"access-key\":\"test_access\",\"os\":\"Linux\",\"username\":\"test_user\",\"browser-version\":\"3.\",\"browser\":\"firefox\"}", config.to_browser_string
30
+ end
44
31
 
45
- assert_equal [["A", "B", "C"]], config.browsers
46
- end
32
+ def test_convenience_accessors
33
+ config = Sauce::Config.new
34
+ assert_equal "saucelabs.com", config.host
35
+ end
47
36
 
48
- should "Let you set and query boolean flags" do
49
- config = Sauce::Config.new
50
- config.foo = true
51
- assert config.foo?
52
- end
37
+ def test_gracefully_degrades_browsers_field
38
+ Sauce.config {|c|}
39
+ config = Sauce::Config.new
40
+ config.os = "A"
41
+ config.browser = "B"
42
+ config.browser_version = "C"
43
+
44
+ assert_equal [["A", "B", "C"]], config.browsers
53
45
  end
54
46
 
55
- context "The Sauce.config method" do
56
- should "Allow you to set a default OS" do
57
- Sauce.config {|c| c.os = "TEST_OS" }
47
+ def test_boolean_flags
48
+ config = Sauce::Config.new
49
+ config.foo = true
50
+ assert config.foo?
51
+ end
58
52
 
53
+ def test_sauce_config_default_os
54
+ Sauce.config {|c| c.os = "TEST_OS" }
55
+ begin
59
56
  config = Sauce::Config.new
60
57
  assert_equal "TEST_OS", config.os
61
- end
62
-
63
- should "Be callable twice" do
64
- Sauce.config {|c| c.os = "A"}
65
- assert_equal "A", Sauce::Config.new.os
58
+ ensure
66
59
  Sauce.config {|c|}
67
- assert_not_equal "A", Sauce::Config.new.os
68
60
  end
61
+ end
69
62
 
70
- should "not retain config after being called again" do
71
- Sauce.config {|c|}
72
- assert_not_equal [["Windows 2003", "firefox", "3.6."]], Sauce::Config.new.browsers
73
- end
63
+ def test_can_call_sauce_config_twice
64
+ Sauce.config {|c| c.os = "A"}
65
+ assert_equal "A", Sauce::Config.new.os
66
+ Sauce.config {|c|}
67
+ assert_not_equal "A", Sauce::Config.new.os
68
+ end
69
+
70
+ def test_clears_config
71
+ Sauce.config {|c|}
72
+ assert_not_equal [["Windows 2003", "firefox", "3.6."]], Sauce::Config.new.browsers
74
73
  end
75
74
  end
data/test/test_connect.rb CHANGED
@@ -1,25 +1,22 @@
1
- require 'helper'
1
+ require File.expand_path("../helper", __FILE__)
2
2
 
3
3
  class TestConnect < Test::Unit::TestCase
4
- context "Sauce Connect" do
5
- should "be running when ready" do
6
- connect = Sauce::Connect.new(:host => "saucelabs.com", :port => 80)
7
- assert_equal "uninitialized", connect.status
8
- connect.wait_until_ready
9
- assert_equal "running", connect.status
10
- connect.status.should == "running"
11
- connect.disconnect
12
- end
13
-
14
- should "set error flag if things don't go well" do
15
- connect = Sauce::Connect.new(:host => "saucelabs.com", :port => 80, :username => 'fail')
16
- start = Time.now
17
- while Time.now-start < 20 && !connect.error
18
- sleep 1
19
- end
4
+ def test_running_when_ready
5
+ connect = Sauce::Connect.new(:host => "saucelabs.com", :port => 80)
6
+ assert_equal "uninitialized", connect.status
7
+ connect.wait_until_ready
8
+ assert_equal "running", connect.status
9
+ connect.disconnect
10
+ end
20
11
 
21
- assert connect.error
22
- connect.disconnect
12
+ def test_error_flag
13
+ connect = Sauce::Connect.new(:host => "saucelabs.com", :port => 80, :username => 'fail')
14
+ start = Time.now
15
+ while Time.now-start < 20 && !connect.error
16
+ sleep 1
23
17
  end
18
+
19
+ assert connect.error
20
+ connect.disconnect
24
21
  end
25
22
  end
@@ -1,15 +1,11 @@
1
- require 'helper'
1
+ require File.expand_path("../helper", __FILE__)
2
2
 
3
3
  class TestSelenium < Test::Unit::TestCase
4
- context "The Sauce Selenium driver" do
5
- should "Connect successfully using credentials from the environment" do
6
- assert ENV['SAUCE_USERNAME'], "You haven't configured a Sauce OnDemand username. Please set $SAUCE_USERNAME"
7
- assert ENV['SAUCE_ACCESS_KEY'], "You haven't configured a Sauce OnDemand access key. Please set $SAUCE_ACCESS_KEY"
8
- selenium = Sauce::Selenium.new(:job_name => "Sauce gem test suite: test_selenium.rb",
9
- :browser_url => "http://www.google.com/")
10
- selenium.start
11
- selenium.open "/"
12
- selenium.stop
13
- end
4
+ def test_successful_connection_from_environment
5
+ selenium = Sauce::Selenium.new(:job_name => "Sauce gem test suite: test_selenium.rb",
6
+ :browser_url => "http://www.google.com/")
7
+ selenium.start
8
+ selenium.open "/"
9
+ selenium.stop
14
10
  end
15
11
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauce
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
5
- prerelease:
4
+ hash: -3702664274
5
+ prerelease: 7
6
6
  segments:
7
7
  - 0
8
- - 14
9
- - 2
10
- version: 0.14.2
8
+ - 15
9
+ - 0
10
+ - alpha
11
+ - 1
12
+ version: 0.15.0.alpha.1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Sean Grove
@@ -17,43 +19,13 @@ autorequire:
17
19
  bindir: bin
18
20
  cert_chain: []
19
21
 
20
- date: 2011-01-24 00:00:00 -08:00
22
+ date: 2011-01-26 00:00:00 -08:00
21
23
  default_executable: sauce
22
24
  dependencies:
23
- - !ruby/object:Gem::Dependency
24
- name: thoughtbot-shoulda
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- hash: 3
32
- segments:
33
- - 0
34
- version: "0"
35
- type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: jeweler
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 1
48
- - 4
49
- - 0
50
- version: 1.4.0
51
- type: :development
52
- version_requirements: *id002
53
25
  - !ruby/object:Gem::Dependency
54
26
  name: rest-client
55
27
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
28
+ requirement: &id001 !ruby/object:Gem::Requirement
57
29
  none: false
58
30
  requirements:
59
31
  - - ">="
@@ -63,11 +35,11 @@ dependencies:
63
35
  - 0
64
36
  version: "0"
65
37
  type: :runtime
66
- version_requirements: *id003
38
+ version_requirements: *id001
67
39
  - !ruby/object:Gem::Dependency
68
40
  name: net-ssh
69
41
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
42
+ requirement: &id002 !ruby/object:Gem::Requirement
71
43
  none: false
72
44
  requirements:
73
45
  - - ">="
@@ -77,11 +49,11 @@ dependencies:
77
49
  - 0
78
50
  version: "0"
79
51
  type: :runtime
80
- version_requirements: *id004
52
+ version_requirements: *id002
81
53
  - !ruby/object:Gem::Dependency
82
54
  name: net-ssh-gateway
83
55
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
56
+ requirement: &id003 !ruby/object:Gem::Requirement
85
57
  none: false
86
58
  requirements:
87
59
  - - ">="
@@ -91,11 +63,11 @@ dependencies:
91
63
  - 0
92
64
  version: "0"
93
65
  type: :runtime
94
- version_requirements: *id005
66
+ version_requirements: *id003
95
67
  - !ruby/object:Gem::Dependency
96
68
  name: selenium-webdriver
97
69
  prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
99
71
  none: false
100
72
  requirements:
101
73
  - - ">="
@@ -107,11 +79,11 @@ dependencies:
107
79
  - 2
108
80
  version: 0.1.2
109
81
  type: :runtime
110
- version_requirements: *id006
82
+ version_requirements: *id004
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: childprocess
113
85
  prerelease: false
114
- requirement: &id007 !ruby/object:Gem::Requirement
86
+ requirement: &id005 !ruby/object:Gem::Requirement
115
87
  none: false
116
88
  requirements:
117
89
  - - ">="
@@ -123,11 +95,11 @@ dependencies:
123
95
  - 6
124
96
  version: 0.1.6
125
97
  type: :runtime
126
- version_requirements: *id007
98
+ version_requirements: *id005
127
99
  - !ruby/object:Gem::Dependency
128
100
  name: json
129
101
  prerelease: false
130
- requirement: &id008 !ruby/object:Gem::Requirement
102
+ requirement: &id006 !ruby/object:Gem::Requirement
131
103
  none: false
132
104
  requirements:
133
105
  - - ">="
@@ -139,11 +111,11 @@ dependencies:
139
111
  - 0
140
112
  version: 1.2.0
141
113
  type: :runtime
142
- version_requirements: *id008
114
+ version_requirements: *id006
143
115
  - !ruby/object:Gem::Dependency
144
116
  name: cmdparse
145
117
  prerelease: false
146
- requirement: &id009 !ruby/object:Gem::Requirement
118
+ requirement: &id007 !ruby/object:Gem::Requirement
147
119
  none: false
148
120
  requirements:
149
121
  - - ">="
@@ -155,11 +127,11 @@ dependencies:
155
127
  - 2
156
128
  version: 2.0.2
157
129
  type: :runtime
158
- version_requirements: *id009
130
+ version_requirements: *id007
159
131
  - !ruby/object:Gem::Dependency
160
132
  name: highline
161
133
  prerelease: false
162
- requirement: &id010 !ruby/object:Gem::Requirement
134
+ requirement: &id008 !ruby/object:Gem::Requirement
163
135
  none: false
164
136
  requirements:
165
137
  - - ">="
@@ -171,7 +143,7 @@ dependencies:
171
143
  - 0
172
144
  version: 1.5.0
173
145
  type: :runtime
174
- version_requirements: *id010
146
+ version_requirements: *id008
175
147
  description: A Ruby interface to Sauce Labs' services. Start/stop tunnels, retrieve Selenium logs, access video replays, etc.
176
148
  email: help@saucelabs.com
177
149
  executables:
@@ -186,7 +158,6 @@ files:
186
158
  - LICENSE
187
159
  - README.markdown
188
160
  - Rakefile
189
- - VERSION
190
161
  - bin/sauce
191
162
  - examples/helper.rb
192
163
  - examples/other_spec.rb
@@ -195,8 +166,8 @@ files:
195
166
  - examples/test_saucelabs2.rb
196
167
  - generators/sauce/sauce_generator.rb
197
168
  - generators/sauce/templates/sauce.rake
198
- - lib/generators/sauce_generator.rb
199
- - lib/generators/templates/sauce.rake
169
+ - lib/generators/sauce/install/install_generator.rb
170
+ - lib/generators/sauce/install/templates/sauce.rake
200
171
  - lib/sauce.rb
201
172
  - lib/sauce/client.rb
202
173
  - lib/sauce/config.rb
@@ -219,13 +190,10 @@ files:
219
190
  - support/simplejson/ordered_dict.py
220
191
  - support/simplejson/scanner.py
221
192
  - support/simplejson/tool.py
222
- - test/api/test_jobs.rb
223
- - test/api/test_tunnels.rb
224
193
  - test/helper.rb
225
194
  - test/test_config.rb
226
195
  - test/test_connect.rb
227
196
  - test/test_selenium.rb
228
- - test/integrations/test_rails2.rb
229
197
  has_rdoc: true
230
198
  homepage: http://github.com/saucelabs/sauce
231
199
  licenses: []
@@ -266,10 +234,7 @@ test_files:
266
234
  - examples/saucelabs_spec.rb
267
235
  - examples/test_saucelabs.rb
268
236
  - examples/test_saucelabs2.rb
269
- - test/api/test_jobs.rb
270
- - test/api/test_tunnels.rb
271
237
  - test/helper.rb
272
- - test/integrations/test_rails2.rb
273
238
  - test/test_config.rb
274
239
  - test/test_connect.rb
275
240
  - test/test_selenium.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.14.2
@@ -1,46 +0,0 @@
1
- class SauceGenerator < Rails::Generators::Base
2
- source_root File.expand_path("../templates", __FILE__)
3
-
4
- argument :username, :type => nil
5
- argument :api_key, :type => nil
6
-
7
- def copy_rake_tasks
8
- copy_file "sauce.rake", "lib/tasks/sauce.rake"
9
- end
10
-
11
- def configure_credentials
12
- system("sauce config #{username} #{api_key}")
13
- end
14
-
15
- def setup_spec
16
- if File.directory? 'spec'
17
- empty_directory "spec/selenium"
18
- append_file "spec/spec_helper.rb", generate_config
19
- end
20
- end
21
-
22
- def setup_test
23
- if File.directory? 'test'
24
- empty_directory "test/selenium"
25
- append_file "test/test_helper.rb", generate_config
26
- end
27
- end
28
-
29
- private
30
-
31
- def generate_config
32
- @random_id ||= rand(100000)
33
- return <<-CONFIG
34
- require 'sauce'
35
-
36
- Sauce.config do |conf|
37
- conf.browser_url = "http://#{@random_id}.test/"
38
- conf.browsers = [
39
- ["Windows 2003", "firefox", "3."]
40
- ]
41
- conf.application_host = "127.0.0.1"
42
- conf.application_port = "3001"
43
- end
44
- CONFIG
45
- end
46
- end
@@ -1,145 +0,0 @@
1
- require 'helper'
2
- require 'json'
3
- require 'yaml'
4
-
5
- class TestSauce < Test::Unit::TestCase
6
- context "A V1 jobs instance" do
7
- setup do
8
- # Create this file and put in your details to run the tests
9
- account = YAML.load_file "account.yml"
10
- @username = account["username"]
11
- @access_key = account["access_key"]
12
- @ip = account["ip"]
13
- @client = Sauce::Client.new(:username => @username,
14
- :access_key => @access_key,
15
- :protocol => account["protocol"],
16
- :host => account["host"],
17
- :port => account["port"],
18
- :api_path => account["api_path"],
19
- :api_version => account["api_version"])
20
-
21
- #@example_data = YAML.load_file('example_data.yml')
22
- end
23
-
24
- =begin
25
- should "initialize with passed variables" do
26
- client = Sauce::Client.new(:username => "test_user",
27
- :access_key => "abc123")
28
-
29
- job = client.jobs.new(JSON.parse(@example_data["example_job"]))
30
-
31
- assert_equal "501aca56282545a9a21ad2fc592b03fa", job.id
32
- assert_equal "joe", job.owner
33
- assert_equal "complete", job.status
34
- assert_equal "job-example-fixture", job.name
35
-
36
- assert_equal "firefox", job.browser
37
- assert_equal "3.5.", job.browser_version
38
- assert_equal "Windows 2003", job.os
39
-
40
- assert_equal 1253856281, job.creation_time
41
- assert_equal 1253856366, job.start_time
42
- assert_equal 1253856465, job.end_time
43
-
44
- assert_equal "http://saucelabs.com/video/8b6bf8d360cc338cc7cf7f6e093264d0/video.flv", job.video_url
45
- assert_equal "http://saucelabs.com/video/8b6bf8d360cc338cc7cf7f6e093264d0/selenium-server.log", job.log_url
46
-
47
- assert_equal false, job.public
48
- assert_equal ["test", "example", "python_is_fun"], job.tags
49
- end
50
- =end
51
-
52
- # Note: Relies on server-side data fixture
53
- should "retrieve and parse a job via the api" do
54
- job = @client.jobs.find("gem-test-job")
55
-
56
- assert_equal "gem-test-job", job.id
57
- assert_equal "sah", job.owner
58
- assert_equal "complete", job.status
59
- assert_equal "job-example-fixture", job.name
60
-
61
- assert_equal "firefox", job.browser
62
- assert_equal "3.5.", job.browser_version
63
- assert_equal "Windows 2003", job.os
64
-
65
- assert_equal 1266030817, job.creation_time
66
- assert_equal 1266030833, job.start_time
67
- assert_equal 1266030871, job.end_time
68
-
69
- assert_equal "http://saucelabs.com/jobs/gem-test-job/video.flv", job.video_url
70
- assert_equal "http://saucelabs.com/jobs/gem-test-job/selenium-server.log", job.log_url
71
-
72
- assert_equal false, job.public
73
- assert_equal ['test', 'equal', 'multilingualism_is_fun'], job.tags
74
- end
75
-
76
- should "update writable properties" do
77
- job = @client.jobs.find("gem-test-job")
78
-
79
- # Make sure it's in the expected condition before changing
80
- assert_equal false, job.public
81
- assert_equal ["test", "example", "multilingualism_is_fun"], job.tags
82
- assert_equal "job-example-fixture", job.name
83
-
84
- job.public = true
85
- job.tags = ["changed", "updated", "ruby_is_also_fun"]
86
- job.name = "changed-job-name", job.name
87
- job.save
88
-
89
- # Fresh copy of the same job
90
- job2 = @client.jobs.find("gem-test-job")
91
-
92
- assert_equal true, job2.public
93
- assert_equal ["changed", "updated", "ruby_is_also_fun"], job2.tags
94
- assert_equal "changed-job-name", job2.name
95
-
96
- # Return the job to its original state and check it out
97
- job.public = false
98
- job.tags = ["test", "example", "multilingualism_is_fun"]
99
- job.name = "job-example-fixture", job.name
100
- job.save
101
-
102
- # Check to see if the change took
103
- job2.refresh!
104
- assert_equal job.public, job2.public
105
- assert_equal job.tags, job2.tags
106
- assert_equal job.name, job2.name
107
- end
108
-
109
- should "not update read-only properties" do
110
- job = @client.jobs.find("gem-test-job")
111
-
112
- # Make sure it's in the expected condition before changing
113
- assert_equal "complete", job.status
114
- assert_equal "sah", job.owner
115
- assert_equal "Windows 2003", job.os
116
-
117
- job.status = "groggy"
118
- job.owner = "sjobs"
119
- job.os = "darwin" # In a perfect world...
120
- assert_equal "groggy", job.status
121
- assert_equal "sjobs", job.owner
122
- assert_equal "darwin", job.os
123
- job.save
124
-
125
- # Changes should go away when refreshed
126
- job.refresh!
127
- assert_equal "complete", job.status
128
- assert_equal "sah", job.owner
129
- assert_equal "Windows 2003", job.os
130
- end
131
-
132
- should "list the 100 most recent jobs" do
133
- jobs = @client.jobs.all
134
-
135
- assert_equal 2, jobs.count
136
- end
137
-
138
- should "show the full job information on index if requested" do
139
- flunk "TODO: implement this"
140
- end
141
-
142
- def teardown
143
- end
144
- end
145
- end
@@ -1,108 +0,0 @@
1
- require 'helper'
2
- require 'yaml'
3
-
4
- class TestSauce < Test::Unit::TestCase
5
- context "A V1 tunnel instance" do
6
- setup do
7
- # Create this file and put in your details to run the tests
8
- account = YAML.load_file "account.yml"
9
- @username = account["username"]
10
- @access_key = account["access_key"]
11
- @ip = account["ip"]
12
- @client = Sauce::Client.new(:username => @username,
13
- :access_key => @access_key,
14
- :ip => @ip
15
- )
16
-
17
- #STDOUT.puts @client.api_url
18
- @client.tunnels.destroy_all
19
- end
20
-
21
- should "initialize with passed variables" do
22
- client = Sauce::Client.new(:username => "test_user",
23
- :access_key => "abc123")
24
- assert_equal "http://test_user:abc123@saucelabs.com:80/rest/v1/test_user/", client.api_url
25
- end
26
-
27
- should "create a tunnel with the current user" do
28
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.110"])
29
- tunnel.refresh!
30
- assert_not_nil tunnel
31
- assert_equal @username, tunnel.owner
32
- end
33
-
34
- should "list current tunnels" do
35
- @client.tunnels.create('DomainNames' => ["192.168.0.111"])
36
- @client.tunnels.create('DomainNames' => ["192.168.0.112"])
37
- @client.tunnels.create('DomainNames' => ["192.168.0.113"])
38
-
39
- tunnels = @client.tunnels.all
40
- assert_equal 3, tunnels.select{|t| t.status != "halting"}.count
41
- end
42
-
43
- should "destroy a tunnel" do
44
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.114"])
45
- tunnel.destroy
46
- assert_equal "halting", tunnel.status
47
- end
48
-
49
- should "destroy all tunnels" do
50
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.115"])
51
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.116"])
52
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.117"])
53
-
54
- @client.tunnels.destroy_all
55
-
56
- @client.tunnels.all.each do |tunnel|
57
- # This could be failing because the tunnels are already dead. Our servers too fast?
58
- tunnel.refresh!
59
- assert_equal "halting", tunnel.status
60
- end
61
- end
62
-
63
- should "say hello on port 1025 if healthy" do
64
- tunnel = @client.tunnels.create('DomainNames' => [@ip])
65
-
66
- max_retries = 30
67
- retries = 0
68
- until tunnel.status == "running" or retries >= max_retries
69
- sleep 5
70
- retries += 1
71
- tunnel.refresh!
72
- end
73
-
74
- assert_equal true, tunnel.says_hello?
75
-
76
- tunnel.destroy # cleanup
77
- end
78
-
79
- should "have a host if finished booting" do
80
- tunnel = @client.tunnels.create('DomainNames' => [@ip])
81
-
82
- max_retries = 30
83
- retries = 0
84
- until tunnel.status == "running" or retries >= max_retries
85
- sleep 5
86
- retries += 1
87
- tunnel.refresh!
88
- end
89
-
90
- tunnel.refresh!
91
-
92
- assert_not_nil tunnel.host
93
-
94
- tunnel.destroy # cleanup
95
- end
96
-
97
- should "not attempt to telnet if status is not running" do
98
- tunnel = @client.tunnels.create('DomainNames' => [@ip])
99
-
100
- tunnel.status = "booting"
101
- assert_equal false, tunnel.says_hello?
102
- end
103
-
104
- def teardown
105
- @client.tunnels.destroy_all
106
- end
107
- end
108
- end
@@ -1,20 +0,0 @@
1
- require 'helper'
2
- require 'tmpdir'
3
- require 'fileutils'
4
-
5
- class TestRails2Integration < Test::Unit::TestCase
6
- def setup
7
- @dir = File.join(Dir.tmpdir, "sauce_gem_test_#{rand(100000)}")
8
- Dir.mkdir(@dir)
9
- Dir.chdir(@dir)
10
- puts @dir
11
- end
12
-
13
- def test_ruby18
14
-
15
- end
16
-
17
- def teardown
18
- FileUtils.remove_dir(@dir)
19
- end
20
- end