sauce 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,15 +7,16 @@ begin
7
7
  gem.name = "sauce"
8
8
  gem.summary = "Ruby access to Sauce Labs' features"
9
9
  gem.description = "A ruby interface to Sauce Labs' services. Start/stop tunnels, retrieve Selenium logs, access video replays, etc."
10
- gem.email = "sean@saucelabs.com"
11
- gem.homepage = "http://github.com/sgrove/sauce"
12
- gem.authors = ["Sean Grove"]
10
+ gem.email = "help@saucelabs.com"
11
+ gem.homepage = "http://github.com/saucelabs/sauce"
12
+ gem.authors = ["Sean Grove", "Eric Allen"]
13
13
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
14
  gem.add_runtime_dependency "rest-client", ">= 0"
15
15
  gem.add_runtime_dependency "net-ssh", ">= 0"
16
16
  gem.add_runtime_dependency "net-ssh-gateway", ">= 0"
17
17
  gem.add_runtime_dependency "selenium-client", ">= 1.2.18"
18
18
  gem.add_runtime_dependency "json", ">= 1.4.6"
19
+ gem.add_runtime_dependency "cmdparse", ">= 2.0.2"
19
20
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
21
  end
21
22
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 0.7.0
data/bin/sauce ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'cmdparse'
5
+ require 'yaml'
6
+
7
+ sauce_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(sauce_dir) unless $LOAD_PATH.include?(sauce_dir)
9
+ require 'lib/sauce'
10
+
11
+ cmd = CmdParse::CommandParser.new(true, true)
12
+ cmd.program_name = "sauce "
13
+ cmd.program_version = [0, 1, 0]
14
+
15
+ cmd.add_command(CmdParse::HelpCommand.new)
16
+
17
+ # configure
18
+ configure = CmdParse::Command.new('configure', false)
19
+ configure.short_desc = "Configure Sauce OnDemand credentials"
20
+ configure.set_execution_block do |args|
21
+ if args.length < 2:
22
+ puts "Usage: sauce configure USERNAME ACCESS_KEY"
23
+ exit 1
24
+ end
25
+ username = args[0]
26
+ access_key = args[1]
27
+ out = File.new(File.join(File.dirname(File.expand_path(File.dirname(__FILE__))), "ondemand.yml"), 'w')
28
+ out.write(YAML.dump({"username" => username, "access_key" => access_key}))
29
+ out.close()
30
+ end
31
+ cmd.add_command(configure)
32
+
33
+ #create
34
+ create = CmdParse::Command.new('create', false)
35
+ create.short_desc = "Create a new Sauce OnDemand account"
36
+ create.set_execution_block do |args|
37
+ puts "Let's create a new account!"
38
+ print "Username: "
39
+ username = $stdin.gets.chomp
40
+ print "password: "
41
+ password = $stdin.gets.chomp
42
+ print "password confirmation: "
43
+ password_confirmation = $stdin.gets.chomp
44
+ print "email: "
45
+ email = $stdin.gets.chomp
46
+ print "Full name: "
47
+ name = $stdin.gets.chomp
48
+
49
+ # TODO: Add error handling, of course
50
+ result = RestClient.post "http://saucelabs.com/rest/v1/users",
51
+ {
52
+ :username => username,
53
+ :password => password,
54
+ :password_confirmation => password_confirmation,
55
+ :email => email,
56
+ :token => "c8eb3e2645005bcbbce7e2c208c6b7a71555d908",
57
+ :name => name
58
+ }.to_json,
59
+ :content_type => :json, :accept => :json
60
+
61
+ puts result.inspect
62
+ end
63
+
64
+ cmd.add_command(create)
65
+
66
+ cmd.parse
data/lib/sauce/config.rb CHANGED
@@ -2,6 +2,15 @@ require 'json'
2
2
  require 'yaml'
3
3
 
4
4
  module Sauce
5
+ def self.config
6
+ @cfg = Sauce::Config.new(false)
7
+ yield @cfg
8
+ end
9
+
10
+ def self.get_config
11
+ @cfg
12
+ end
13
+
5
14
  class Config
6
15
  attr_reader :opts
7
16
  DEFAULT_OPTIONS = {
@@ -15,13 +24,23 @@ module Sauce
15
24
  }
16
25
 
17
26
  def initialize(opts={})
18
- @opts = DEFAULT_OPTIONS.merge(load_options_from_yaml)
19
- @opts.merge! load_options_from_environment
20
- @opts.merge! opts
27
+ @opts = {}
28
+ if opts != false
29
+ @opts.merge! DEFAULT_OPTIONS
30
+ @opts.merge! load_options_from_yaml
31
+ @opts.merge! load_options_from_environment
32
+ @opts.merge! Sauce.get_config.opts rescue {}
33
+ @opts.merge! opts
34
+ end
21
35
  end
22
36
 
23
37
  def method_missing(meth, *args)
24
- return @opts[meth]
38
+ if meth.to_s =~ /(.*)=$/
39
+ @opts[$1.to_sym] = args[0]
40
+ return args[0]
41
+ else
42
+ return @opts[meth]
43
+ end
25
44
  end
26
45
 
27
46
  def to_browser_string
@@ -35,6 +54,11 @@ module Sauce
35
54
  return browser_options.to_json
36
55
  end
37
56
 
57
+ def browsers
58
+ return @opts[:browsers] if @opts.include? :browsers
59
+ return [[os, browser, browser_version]]
60
+ end
61
+
38
62
  private
39
63
 
40
64
  def load_options_from_environment
@@ -61,6 +85,7 @@ module Sauce
61
85
  paths = [
62
86
  "ondemand.yml",
63
87
  File.join("config", "ondemand.yml"),
88
+ File.join(File.dirname(File.dirname(File.expand_path(File.dirname(__FILE__)))), "ondemand.yml"),
64
89
  File.join(ENV['HOME'], ".ondemand.yml")
65
90
  ]
66
91
 
@@ -5,10 +5,6 @@ begin
5
5
  class SeleniumExampleGroup < Spec::Example::ExampleGroup
6
6
  attr_reader :selenium
7
7
 
8
- before(:all) do
9
- @selenium = Sauce::Selenium.new
10
- end
11
-
12
8
  before(:each) do
13
9
  @selenium.start
14
10
  end
@@ -17,6 +13,14 @@ begin
17
13
  @selenium.stop
18
14
  end
19
15
 
16
+ def execute(*args)
17
+ config = Sauce::Config.new
18
+ config.browsers.each do |os, browser, version|
19
+ @selenium = Sauce::Selenium.new({:os => os, :browser => browser, :browser_version => version})
20
+ super(*args)
21
+ end
22
+ end
23
+
20
24
  alias_method :page, :selenium
21
25
  alias_method :s, :selenium
22
26
 
data/lib/sauce.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'sauce/tunnel'
2
3
  require 'sauce/job'
3
4
  require 'sauce/client'
data/test/helper.rb CHANGED
@@ -7,5 +7,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
8
  require 'sauce'
9
9
 
10
- class Test::Unit::TestCase
10
+ Sauce.config do |config|
11
+ config.browsers = [['Windows 2003', 'firefox', '3.6.']]
12
+ config.root_url = "http://saucelabs.com"
11
13
  end
@@ -1,6 +1,14 @@
1
1
  require 'helper'
2
2
 
3
- describe "saucelabs.com", :type => :selenium do
3
+ # This should go in a test helper
4
+ Sauce.config do |config|
5
+ config.browsers = [
6
+ ["Windows 2003", "firefox", "3.6."],
7
+ ["Windows 2003", "safariproxy", "5."]
8
+ ]
9
+ end
10
+
11
+ describe "The Sauce website", :type => :selenium do
4
12
  it "works" do
5
13
  page.open "/"
6
14
  page.is_text_present("Sauce Labs").should be_true
data/test/test_config.rb CHANGED
@@ -23,5 +23,36 @@ class TestConfig < Test::Unit::TestCase
23
23
  config = Sauce::Config.new
24
24
  assert_equal "saucelabs.com", config.host
25
25
  end
26
+
27
+ should "gracefully degrade the browsers field" do
28
+ Sauce.config {|c|}
29
+ config = Sauce::Config.new
30
+ config.os = "A"
31
+ config.browser = "B"
32
+ config.browser_version = "C"
33
+
34
+ assert_equal [["A", "B", "C"]], config.browsers
35
+ end
36
+ end
37
+
38
+ context "The Sauce.config method" do
39
+ should "Allow you to set a default OS" do
40
+ Sauce.config {|c| c.os = "TEST_OS" }
41
+
42
+ config = Sauce::Config.new
43
+ assert_equal "TEST_OS", config.os
44
+ end
45
+
46
+ should "Be callable twice" do
47
+ Sauce.config {|c| c.os = "A"}
48
+ assert_equal "A", Sauce::Config.new.os
49
+ Sauce.config {|c|}
50
+ assert_not_equal "A", Sauce::Config.new.os
51
+ end
52
+
53
+ should "not retain config after being called again" do
54
+ Sauce.config {|c|}
55
+ assert_not_equal [["Windows 2003", "firefox", "3.6."]], Sauce::Config.new.browsers
56
+ end
26
57
  end
27
58
  end
metadata CHANGED
@@ -1,22 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauce
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 3
10
- version: 0.6.3
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Grove
14
+ - Eric Allen
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-22 00:00:00 -07:00
19
- default_executable:
19
+ date: 2010-10-25 00:00:00 -07:00
20
+ default_executable: sauce
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: thoughtbot-shoulda
@@ -106,10 +107,26 @@ dependencies:
106
107
  version: 1.4.6
107
108
  type: :runtime
108
109
  version_requirements: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ name: cmdparse
112
+ prerelease: false
113
+ requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 11
119
+ segments:
120
+ - 2
121
+ - 0
122
+ - 2
123
+ version: 2.0.2
124
+ type: :runtime
125
+ version_requirements: *id007
109
126
  description: A ruby interface to Sauce Labs' services. Start/stop tunnels, retrieve Selenium logs, access video replays, etc.
110
- email: sean@saucelabs.com
111
- executables: []
112
-
127
+ email: help@saucelabs.com
128
+ executables:
129
+ - sauce
113
130
  extensions: []
114
131
 
115
132
  extra_rdoc_files:
@@ -122,6 +139,7 @@ files:
122
139
  - README.markdown
123
140
  - Rakefile
124
141
  - VERSION
142
+ - bin/sauce
125
143
  - lib/sauce.rb
126
144
  - lib/sauce/client.rb
127
145
  - lib/sauce/config.rb
@@ -138,7 +156,7 @@ files:
138
156
  - test/test_selenium.rb
139
157
  - test/test_tunnels.rb
140
158
  has_rdoc: true
141
- homepage: http://github.com/sgrove/sauce
159
+ homepage: http://github.com/saucelabs/sauce
142
160
  licenses: []
143
161
 
144
162
  post_install_message: