sauce 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  sauce
2
2
  =====
3
3
 
4
- Ruby access to SauceLab's features
4
+ Ruby access to Sauce OnDemand
5
5
 
6
6
  Features
7
7
  --------
@@ -17,8 +17,6 @@ Planned:
17
17
 
18
18
  Install
19
19
  -------
20
- Make sure you're pulling in gems from http://rubygems.org/, and then:
21
-
22
20
  `gem install sauce`
23
21
 
24
22
  Example
data/Rakefile CHANGED
@@ -11,7 +11,10 @@ begin
11
11
  gem.homepage = "http://github.com/sgrove/sauce"
12
12
  gem.authors = ["Sean Grove"]
13
13
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
- gem.add_development_dependency "rest-client", ">= 0"
14
+ gem.add_runtime_dependency "rest-client", ">= 0"
15
+ gem.add_runtime_dependency "net-ssh", ">= 0"
16
+ gem.add_runtime_dependency "net-ssh-gateway", ">= 0"
17
+ gem.add_runtime_dependency "selenium-client", ">= 1.2.18"
15
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
19
  end
17
20
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -1,4 +1,6 @@
1
- require 'tunnel'
2
- require 'job'
3
- require 'rest'
4
-
1
+ require 'sauce/tunnel'
2
+ require 'sauce/job'
3
+ require 'sauce/client'
4
+ require 'sauce/config'
5
+ require 'sauce/selenium'
6
+ require 'sauce/integrations'
File without changes
@@ -0,0 +1,76 @@
1
+ require 'json'
2
+ require 'yaml'
3
+
4
+ module Sauce
5
+ class Config
6
+ attr_reader :opts
7
+ DEFAULT_OPTIONS = {
8
+ :host => "saucelabs.com",
9
+ :port => 4444,
10
+ :browser_url => "http://saucelabs.com",
11
+ :os => "Linux",
12
+ :browser => "firefox",
13
+ :browser_version => "3.",
14
+ :job_name => "Unnamed Ruby job"
15
+ }
16
+
17
+ def initialize(opts={})
18
+ @opts = DEFAULT_OPTIONS.merge(load_options_from_yaml)
19
+ @opts.merge! load_options_from_environment
20
+ @opts.merge! opts
21
+ end
22
+
23
+ def method_missing(meth, *args)
24
+ return @opts[meth]
25
+ end
26
+
27
+ def to_browser_string
28
+ browser_options = {
29
+ 'username' => @opts[:username],
30
+ 'access-key' => @opts[:access_key],
31
+ 'os' => @opts[:os],
32
+ 'browser' => @opts[:browser],
33
+ 'browser-version' => @opts[:browser_version],
34
+ 'name' => @opts[:job_name]}
35
+ return browser_options.to_json
36
+ end
37
+
38
+ private
39
+
40
+ def load_options_from_environment
41
+ opts = {}
42
+ opts[:host] = ENV['SAUCE_HOST']
43
+ opts[:port] = ENV['SAUCE_PORT']
44
+ opts[:browser_url] = ENV['SAUCE_BROWSER_URL']
45
+
46
+ opts[:username] = ENV['SAUCE_USERNAME']
47
+ opts[:access_key] = ENV['SAUCE_ACCESS_KEY']
48
+
49
+ opts[:os] = ENV['SAUCE_OS']
50
+ opts[:browser] = ENV['SAUCE_BROWSER']
51
+ opts[:browser_version] = ENV['SAUCE_BROWSER_VERSION']
52
+ opts[:job_name] = ENV['SAUCE_JOB_NAME']
53
+
54
+ opts[:firefox_profile_url] = ENV['SAUCE_FIREFOX_PROFILE_URL']
55
+ opts[:user_extensions_url] = ENV['SAUCE_USER_EXTENSIONS_URL']
56
+
57
+ return opts.delete_if {|key, value| value.nil?}
58
+ end
59
+
60
+ def load_options_from_yaml
61
+ paths = [
62
+ "ondemand.yml",
63
+ File.join("config", "ondemand.yml"),
64
+ File.join(ENV['HOME'], ".ondemand.yml")
65
+ ]
66
+
67
+ paths.each do |path|
68
+ if File.exists? path
69
+ conf = YAML.load_file(path)
70
+ return conf.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
71
+ end
72
+ end
73
+ return {}
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,18 @@
1
+ module Sauce
2
+ if ENV['SAUCE_ONDEMAND_HEROKU_URL'] and ENV['URL']
3
+
4
+ # Heroku Configuation
5
+ config = JSON.parse RestClient.get(ENV['SAUCE_ONDEMAND_HEROKU_URL']).body
6
+ Sauce::Selenium_browsers = JSON.parse config["SAUCE_ONDEMAND_BROWSERS"]
7
+ Sauce::Selenium_url = "#{config['SAUCE_ONDEMAND_PROTOCOL']}#{ENV['URL']}"
8
+ Sauce::Selenium_host = config["SAUCE_ONDEMAND_SERVER" ]
9
+ Sauce::Selenium_port = config["SAUCE_ONDEMAND_PORT" ]
10
+ else
11
+
12
+ # Local Configuration
13
+ Sauce::Selenium_url = ENV['SELENIUM_URL'] || "http://localhost:3000"
14
+ Sauce::Selenium_host = ENV['SELENIUM_HOST'] || "localhost"
15
+ Sauce::Selenium_port = ENV['SELENIUM_PORT'] || "4444"
16
+ Sauce::Selenium_browsers = ENV['SELENIUM_BROWSER'] || ["*firefox"]
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ begin
2
+ require 'spec'
3
+ module Sauce
4
+ module RSpec
5
+ class SeleniumExampleGroup < Spec::Example::ExampleGroup
6
+ attr_reader :selenium
7
+
8
+ before(:all) do
9
+ @selenium = Sauce::Selenium.new
10
+ end
11
+
12
+ before(:each) do
13
+ @selenium.start
14
+ end
15
+
16
+ after(:each) do
17
+ @selenium.stop
18
+ end
19
+
20
+ alias_method :page, :selenium
21
+ alias_method :s, :selenium
22
+
23
+ Spec::Example::ExampleGroupFactory.register(:selenium, self)
24
+ end
25
+ end
26
+ end
27
+ rescue LoadError
28
+ # User doesn't have RSpec installed
29
+ end
File without changes
@@ -0,0 +1,12 @@
1
+ require "selenium/client"
2
+
3
+ module Sauce
4
+ class Selenium < Selenium::Client::Driver
5
+ def initialize(opts={})
6
+ @config = Sauce::Config.new(opts)
7
+ opts.merge!({:host => @config.host, :port => @config.port,
8
+ :browser => @config.to_browser_string, :url => @config.browser_url})
9
+ super(opts)
10
+ end
11
+ end
12
+ end
File without changes
@@ -0,0 +1,8 @@
1
+ require 'helper'
2
+
3
+ describe "saucelabs.com", :type => :selenium do
4
+ it "works" do
5
+ page.open "/"
6
+ page.is_text_present("Sauce Labs").should be_true
7
+ end
8
+ end
@@ -0,0 +1,27 @@
1
+ require 'helper'
2
+
3
+ class TestConfig < Test::Unit::TestCase
4
+ context "A new Config" do
5
+ should "Generate a reasonable browser string from the environment" do
6
+ ENV['SAUCE_USERNAME'] = "test_user"
7
+ ENV['SAUCE_ACCESS_KEY'] = "test_access"
8
+ ENV['SAUCE_OS'] = "Linux"
9
+ ENV['SAUCE_BROWSER'] = "firefox"
10
+ ENV['SAUCE_BROWSER_VERSION'] = "3."
11
+
12
+ config = Sauce::Config.new
13
+ assert_equal "{\"name\":\"Unnamed Ruby job\",\"access-key\":\"test_access\",\"os\":\"Linux\",\"username\":\"test_user\",\"browser-version\":\"3.\",\"browser\":\"firefox\"}", config.to_browser_string
14
+ end
15
+
16
+ should "Generate a browser string from parameters" do
17
+ config = Sauce::Config.new(:username => "test_user", :access_key => "test_access",
18
+ :os => "Linux", :browser => "firefox", :browser_version => "3.")
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
+ end
21
+
22
+ should "Respond to convenience accessors" do
23
+ config = Sauce::Config.new
24
+ assert_equal "saucelabs.com", config.host
25
+ end
26
+ end
27
+ end
@@ -6,7 +6,7 @@ class TestSauce < Test::Unit::TestCase
6
6
  context "A V1 jobs instance" do
7
7
  setup do
8
8
  # Create this file and put in your details to run the tests
9
- account = YAML.load_file "account2.yml"
9
+ account = YAML.load_file "account.yml"
10
10
  @username = account["username"]
11
11
  @access_key = account["access_key"]
12
12
  @ip = account["ip"]
@@ -58,7 +58,7 @@ class TestSauce < Test::Unit::TestCase
58
58
  assert_equal "complete", job.status
59
59
  assert_equal "job-example-fixture", job.name
60
60
 
61
- assert_equal "Firefox", job.browser
61
+ assert_equal "firefox", job.browser
62
62
  assert_equal "3.5.", job.browser_version
63
63
  assert_equal "Windows 2003", job.os
64
64
 
@@ -70,7 +70,7 @@ class TestSauce < Test::Unit::TestCase
70
70
  assert_equal "http://saucelabs.com/jobs/gem-test-job/selenium-server.log", job.log_url
71
71
 
72
72
  assert_equal false, job.public
73
- assert_equal ['test', 'equal', 'multilingualism is fun'], job.tags
73
+ assert_equal ['test', 'equal', 'multilingualism_is_fun'], job.tags
74
74
  end
75
75
 
76
76
  should "update writable properties" do
@@ -78,12 +78,12 @@ class TestSauce < Test::Unit::TestCase
78
78
 
79
79
  # Make sure it's in the expected condition before changing
80
80
  assert_equal false, job.public
81
- assert_equal ["test", "equal", "multilingualism is fun"], job.tags
81
+ assert_equal ["test", "example", "multilingualism_is_fun"], job.tags
82
82
  assert_equal "job-example-fixture", job.name
83
83
 
84
84
  job.public = true
85
85
  job.tags = ["changed", "updated", "ruby_is_also_fun"]
86
- job.name = "changed-job-name"
86
+ job.name = "changed-job-name", job.name
87
87
  job.save
88
88
 
89
89
  # Fresh copy of the same job
@@ -95,8 +95,8 @@ class TestSauce < Test::Unit::TestCase
95
95
 
96
96
  # Return the job to its original state and check it out
97
97
  job.public = false
98
- job.tags = ["test", "example", "multilingualism is fun"]
99
- job.name = "job-example-fixture"
98
+ job.tags = ["test", "example", "multilingualism_is_fun"]
99
+ job.name = "job-example-fixture", job.name
100
100
  job.save
101
101
 
102
102
  # Check to see if the change took
@@ -135,7 +135,7 @@ class TestSauce < Test::Unit::TestCase
135
135
  assert_equal 2, jobs.count
136
136
  end
137
137
 
138
- should "show job listings with full job information if requested" do
138
+ should "show the full job information on index if requested" do
139
139
  flunk "TODO: implement this"
140
140
  end
141
141
 
@@ -0,0 +1,14 @@
1
+ require 'helper'
2
+
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_USERNAME'], "You haven't configured a Sauce OnDemand access key. Please set $SAUCE_ACCESS_KEY"
8
+ selenium = Sauce::Selenium.new()
9
+ selenium.start
10
+ selenium.open "/"
11
+ selenium.stop
12
+ end
13
+ end
14
+ end
@@ -5,16 +5,14 @@ class TestSauce < Test::Unit::TestCase
5
5
  context "A V1 tunnel instance" do
6
6
  setup do
7
7
  # Create this file and put in your details to run the tests
8
- account = YAML.load_file "account2.yml"
8
+ account = YAML.load_file "account.yml"
9
9
  @username = account["username"]
10
10
  @access_key = account["access_key"]
11
11
  @ip = account["ip"]
12
12
  @client = Sauce::Client.new(:username => @username,
13
13
  :access_key => @access_key,
14
- :ip => @ip,
15
- :protocol => account["protocol"],
16
- :host => account["host"],
17
- :port => account["port"])
14
+ :ip => @ip
15
+ )
18
16
 
19
17
  #STDOUT.puts @client.api_url
20
18
  @client.tunnels.destroy_all
@@ -33,14 +31,6 @@ class TestSauce < Test::Unit::TestCase
33
31
  assert_equal @username, tunnel.owner
34
32
  end
35
33
 
36
- should "error if a tunnel is created without domain names" do
37
- flunk "TODO: Implement this"
38
- tunnel = @client.tunnels.create('DomainNames' => [])
39
- tunnel.refresh!
40
- assert_not_nil tunnel
41
- assert_equal @username, tunnel.owner
42
- end
43
-
44
34
  should "list current tunnels" do
45
35
  @client.tunnels.create('DomainNames' => ["192.168.0.111"])
46
36
  @client.tunnels.create('DomainNames' => ["192.168.0.112"])
@@ -53,7 +43,7 @@ class TestSauce < Test::Unit::TestCase
53
43
  should "destroy a tunnel" do
54
44
  tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.114"])
55
45
  tunnel.destroy
56
- assert ["terminated", "halting"].include?(tunnel.status)
46
+ assert_equal "halting", tunnel.status
57
47
  end
58
48
 
59
49
  should "destroy all tunnels" do
@@ -66,13 +56,12 @@ class TestSauce < Test::Unit::TestCase
66
56
  @client.tunnels.all.each do |tunnel|
67
57
  # This could be failing because the tunnels are already dead. Our servers too fast?
68
58
  tunnel.refresh!
69
- assert ["terminated", "halting"].include? tunnel.status
59
+ assert_equal "halting", tunnel.status
70
60
  end
71
61
  end
72
62
 
73
63
  should "say hello on port 1025 if healthy" do
74
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.118"])
75
-
64
+ tunnel = @client.tunnels.create('DomainNames' => [@ip])
76
65
 
77
66
  max_retries = 30
78
67
  retries = 0
@@ -88,7 +77,7 @@ class TestSauce < Test::Unit::TestCase
88
77
  end
89
78
 
90
79
  should "have a host if finished booting" do
91
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.119"])
80
+ tunnel = @client.tunnels.create('DomainNames' => [@ip])
92
81
 
93
82
  max_retries = 30
94
83
  retries = 0
@@ -106,7 +95,7 @@ class TestSauce < Test::Unit::TestCase
106
95
  end
107
96
 
108
97
  should "not attempt to telnet if status is not running" do
109
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.119"])
98
+ tunnel = @client.tunnels.create('DomainNames' => [@ip])
110
99
 
111
100
  tunnel.status = "booting"
112
101
  assert_equal false, tunnel.says_hello?
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauce
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 7
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 5
8
+ - 6
8
9
  - 0
9
- version: 0.5.0
10
+ version: 0.6.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Sean Grove
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-16 00:00:00 -07:00
18
+ date: 2010-10-22 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: thoughtbot-shoulda
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,14 +36,60 @@ dependencies:
33
36
  name: rest-client
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
42
- type: :development
47
+ type: :runtime
43
48
  version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: net-ssh
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: net-ssh-gateway
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: selenium-client
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 59
86
+ segments:
87
+ - 1
88
+ - 2
89
+ - 18
90
+ version: 1.2.18
91
+ type: :runtime
92
+ version_requirements: *id005
44
93
  description: A ruby interface to Sauce Labs' services. Start/stop tunnels, retrieve Selenium logs, access video replays, etc.
45
94
  email: sean@saucelabs.com
46
95
  executables: []
@@ -57,13 +106,20 @@ files:
57
106
  - README.markdown
58
107
  - Rakefile
59
108
  - VERSION
60
- - lib/gateway_ext.rb
61
- - lib/job.rb
62
- - lib/rest.rb
63
109
  - lib/sauce.rb
64
- - lib/tunnel.rb
110
+ - lib/sauce/client.rb
111
+ - lib/sauce/config.rb
112
+ - lib/sauce/gateway_ext.rb
113
+ - lib/sauce/heroku.rb
114
+ - lib/sauce/integrations.rb
115
+ - lib/sauce/job.rb
116
+ - lib/sauce/selenium.rb
117
+ - lib/sauce/tunnel.rb
65
118
  - test/helper.rb
119
+ - test/saucelabs_spec.rb
120
+ - test/test_config.rb
66
121
  - test/test_jobs.rb
122
+ - test/test_selenium.rb
67
123
  - test/test_tunnels.rb
68
124
  has_rdoc: true
69
125
  homepage: http://github.com/sgrove/sauce
@@ -75,29 +131,34 @@ rdoc_options:
75
131
  require_paths:
76
132
  - lib
77
133
  required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
78
135
  requirements:
79
136
  - - ">="
80
137
  - !ruby/object:Gem::Version
138
+ hash: 3
81
139
  segments:
82
140
  - 0
83
141
  version: "0"
84
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
85
144
  requirements:
86
145
  - - ">="
87
146
  - !ruby/object:Gem::Version
147
+ hash: 3
88
148
  segments:
89
149
  - 0
90
150
  version: "0"
91
151
  requirements: []
92
152
 
93
153
  rubyforge_project:
94
- rubygems_version: 1.3.6
154
+ rubygems_version: 1.3.7
95
155
  signing_key:
96
156
  specification_version: 3
97
157
  summary: Ruby access to Sauce Labs' features
98
158
  test_files:
99
- - test/debug.rb
100
159
  - test/helper.rb
101
- - test/monitor_jobs.rb
160
+ - test/saucelabs_spec.rb
161
+ - test/test_config.rb
102
162
  - test/test_jobs.rb
163
+ - test/test_selenium.rb
103
164
  - test/test_tunnels.rb
@@ -1,11 +0,0 @@
1
- require 'helper'
2
-
3
- c = Sauce::Client.new(:username => "sgrove",
4
- :access_key => "4c592ce3-8f45-4cd6-8e3e-65b9f0b173d0")
5
-
6
- c.destroy_all_tunnels
7
- t = c.create_tunnel('DomainNames' => ["111.111.111.111"])
8
-
9
- puts c.tunnels.inspect
10
-
11
- c.destroy_all_tunnels
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
- require 'yaml'
3
- $: << "../lib/"
4
- require 'sauce'
5
-
6
- account = YAML.load_file("account.yml")
7
-
8
- client = Sauce::Client.new(:username => account["username"],
9
- :access_key => account["access_key"])
10
-
11
- jobs = client.jobs.all
12
-
13
- puts jobs.inspect