sauce 3.0.6 → 3.1.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzZiODQxZGRmYzBlM2RhN2YwZDc5NGI3OTc0NjliYWM2NGUyMjE4Mw==
4
+ NGVlZTUyYjMyZDk4MzQ3N2RjMzVkYWM2MmJkYzE5OTRlZjI5YTkxYQ==
5
5
  data.tar.gz: !binary |-
6
- OGZjOTMxOTJiN2U0MjM2YjIyNjUxNTI5MDEyNjJkOGUzZTY5YjcxNg==
6
+ YjkzOTE0Mjk5YjgzOGM4ODY3YTc2M2U5ZmY4Zjg4NGMwODkwMzg4OA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NGM4M2QwYWYzNTZiZGUyNzA1OTc3MmU2YWEyNjg2MDAwNWJmYzNmNTAwZGJm
10
- MTRiZWNiMzgwYzQ2YzliYWE4NjNkZjM4ODAzMjNhYzBiZWU5MDUzNjcxNmQ5
11
- MTM4ODE3MzBhYTU3YzdmMmJkNWQ2NmU2MzM3MmQ2MDVlMTU0ZWE=
9
+ YzBkNjgwODU5NDJiMTI1OWMwMjUyYjE1N2M1ZjVjODI5N2JjMDExY2FmMDQy
10
+ ZTljMjJiNWYwZDk5NTVhNjdlYzliN2IyYjU2OGRjODE1YWQwZDNmMTA0MDc2
11
+ NWQ4MzM2MjgzMDk5OGQ5YmY0M2Y2ZjI5ZmJmNzUxNThiMWQxNzI=
12
12
  data.tar.gz: !binary |-
13
- YmZlNGNmNWViNTVhN2NlZTUwZDZkNTUxODM2MTUyMzI5MDhkZDI5NWE3OThk
14
- MGU4MjMzNDc3YTZlMGRkYmE5MmMyZDFiNDQ0Nzg3MmZjOThjMDkzOTIzNDRm
15
- ODRkNWFiNGM4OGEyNzA2NGMyZDUxOWVkOTI4NmZkM2JmMTU5MDM=
13
+ NzBjM2I0MDMxN2RkMzk1ZmZkNThkYTg3ODc1ZGE0YjU0ODBkYmNlOGRmOTA3
14
+ M2QwZWNjOWU2YjdiYzIwYTgwY2Q1NDgxOTlmNDk3OWY5NTFiOWY1MDcwZTU4
15
+ ODMzMzVkM2I1NDY1OTk4YmRlOWJhZTQxYjM4YTY3N2UzMjlkODg=
@@ -114,7 +114,6 @@ module Sauce
114
114
  def render(path)
115
115
  browser.save_screenshot path
116
116
  end
117
-
118
117
  end
119
118
  end
120
119
  end
@@ -130,3 +129,23 @@ module Capybara
130
129
  @javascript_driver || :sauce
131
130
  end
132
131
  end
132
+
133
+ begin
134
+ require "rspec/core"
135
+ module Sauce
136
+ module RSpec
137
+ module SeleniumExampleGroup
138
+ ::RSpec.configuration.before(:suite, :sauce => true) do
139
+ ::Capybara.configure do |config|
140
+ host = Sauce::Config.new[:application_host] || "127.0.0.1"
141
+ port = Sauce::Config.new[:application_port]
142
+ config.app_host = "http://#{host}:#{port}"
143
+ config.run_server = false
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
149
+ rescue LoadError => e
150
+ # User is not using RSpec
151
+ end
data/lib/sauce/config.rb CHANGED
@@ -39,6 +39,14 @@ module Sauce
39
39
  ]
40
40
  }
41
41
 
42
+ POTENTIAL_PORTS = [
43
+ 3000, 3001, 3030, 3210, 3333, 4000, 4001, 4040, 4321, 4502, 4503, 5000,
44
+ 5001, 5050, 5555, 5432, 6000, 6001, 6060, 6666, 6543, 7000, 7070, 7774,
45
+ 7777, 8000, 8001, 8003, 8031, 8080, 8081, 8765, 8888, 9000, 9001, 9080,
46
+ 9090, 9876, 9999, 49221, 55001, 80, 443, 888, 2000, 2001, 2020, 2109,
47
+ 2222, 2310
48
+ ]
49
+
42
50
  ENVIRONMENT_VARIABLES = %w{SAUCE_HOST SAUCE_PORT SAUCE_BROWSER_URL SAUCE_USERNAME
43
51
  SAUCE_ACCESS_KEY SAUCE_OS SAUCE_BROWSER SAUCE_BROWSER_VERSION SAUCE_JOB_NAME
44
52
  SAUCE_FIREFOX_PROFILE_URL SAUCE_USER_EXTENSIONS_URL
@@ -60,12 +68,18 @@ module Sauce
60
68
  selenium-version command-timeout prerun prerun-args screen-resolution
61
69
  disable-popup-handler avoid-proxy public}
62
70
 
71
+ def self.get_application_port
72
+ port_index = ENV["TEST_ENV_NUMBER"].to_i
73
+ return POTENTIAL_PORTS[port_index]
74
+ end
75
+
63
76
  def initialize(opts={})
64
77
  @opts = {}
65
78
  @undefaulted_opts = {}
66
79
  if opts != false
67
80
  @opts.merge! DEFAULT_OPTIONS
68
81
  @opts.merge! DEFAULT_BROWSERS
82
+ @opts.merge!({:application_port => Sauce::Config.get_application_port})
69
83
 
70
84
  @undefaulted_opts.merge! load_options_from_yaml
71
85
  @undefaulted_opts.merge! load_options_from_environment
data/lib/sauce/rspec.rb CHANGED
@@ -19,7 +19,7 @@ begin
19
19
  config = Sauce::Config.new
20
20
  if @@need_tunnel
21
21
  if config[:application_host]
22
- Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80)
22
+ Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port])
23
23
  end
24
24
  if config[:start_local_application] &&
25
25
  Sauce::Utilities::RailsServer.is_rails_app?
@@ -105,16 +105,13 @@ begin
105
105
 
106
106
  config = Sauce::Config.new
107
107
  if config[:application_host]
108
- Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80, :quiet => true)
108
+ Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port], :quiet => true)
109
109
  end
110
110
 
111
111
  if config[:start_local_application] &&
112
112
  Sauce::Utilities::RailsServer.is_rails_app?
113
- # Start the app before the tests if this is a parallel run
114
- if ENV["TEST_ENV_NUMBER"].nil?
115
113
  @@server = Sauce::Utilities::RailsServer.new
116
114
  @@server.start
117
- end
118
115
  end
119
116
  end
120
117
 
@@ -128,16 +125,14 @@ begin
128
125
  end
129
126
 
130
127
  if need_tunnel || config[:start_tunnel]
131
- Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80, :quiet => true)
128
+ Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port], :quiet => true)
132
129
  end
133
130
 
134
131
  if config[:start_local_application] &&
135
132
  files_to_run.any? {|file| file =~ /spec\/selenium\//} &&
136
133
  Sauce::Utilities::RailsServer.is_rails_app?
137
- ## Only open the tunnel once.
138
- ## TODO: Why is this here? It's above, also
139
- @@server = Sauce::Utilities::RailsServer.new
140
- @@server.start
134
+ @@server = Sauce::Utilities::RailsServer.new
135
+ @@server.start
141
136
  end
142
137
  end
143
138
  ::RSpec.configuration.after :suite do
@@ -4,6 +4,7 @@ require 'childprocess'
4
4
  require 'net/http'
5
5
  require 'childprocess/process'
6
6
  require 'sauce/parallel'
7
+ require 'sauce/utilities/rails_server'
7
8
 
8
9
  module Sauce
9
10
  module Utilities
@@ -73,56 +74,5 @@ If you are using Capybara and are seeing this message, check the Capybara README
73
74
  end
74
75
  end
75
76
  end
76
-
77
- class RailsServer
78
- include Sauce::Utilities
79
-
80
- def self.is_rails_app?
81
- File.exists?('script/server') || File.exists?('script/rails')
82
- end
83
-
84
- def start
85
- port = 3001
86
-
87
- if ENV["TEST_ENV_NUMBER"]
88
- @test_env = ENV["TEST_ENV_NUMBER"].to_i
89
- port = port + @test_env
90
- end
91
-
92
- STDERR.puts "Starting Rails server on port #{port}..."
93
-
94
- if File.exists?('script/server')
95
- @process_args = ["ruby", "script/server", "-e", "test", "--port", "#{port}"]
96
- #@server = ChildProcess.build("ruby", "script/server", "-e", "test", "--port", "#{port}")
97
- elsif File.exists?('script/rails')
98
- @process_args = ["bundle", "exec", "rails", "server", "-e", "test", "--port", "#{port}"]
99
- #@server = ChildProcess.build("bundle", "exec", "rails", "server", "-e", "test", "--port", "#{port}")
100
- end
101
-
102
- if @test_env
103
- @process_args.push *["--pid", "#{Dir.pwd}/tmp/pids/server-#{@test_env}"]
104
- end
105
-
106
- @server = ChildProcess.build *@process_args
107
- @server.io.inherit!
108
- @server.start
109
-
110
- wait_for_server_on_port(port)
111
-
112
- at_exit do
113
- @server.stop(3, "INT")
114
- end
115
- STDERR.puts "Rails server running!"
116
- end
117
-
118
- def stop
119
- begin
120
- @server.stop(3, "INT")
121
- rescue
122
- STDERR.puts "Rails server could not be killed. Did it fail to start?"
123
- end
124
- end
125
- end
126
-
127
77
  end
128
78
  end
@@ -0,0 +1,81 @@
1
+ module Sauce
2
+ module Utilities
3
+ class RailsServer
4
+ include Sauce::Utilities
5
+
6
+ def self.is_rails_app?
7
+ return !major_version.nil?
8
+ end
9
+
10
+ def self.major_version
11
+ paths = ["script/server", "script/rails", "bin/rails"]
12
+ startup_script = paths.detect {|path| File.exists? path}
13
+
14
+ case startup_script
15
+ when 'script/server'
16
+ return 2
17
+ when 'script/rails'
18
+ return 3
19
+ when 'bin/rails'
20
+ return 4
21
+ else
22
+ return nil
23
+ end
24
+ end
25
+
26
+ def self.process_arguments
27
+ case major_version
28
+ when 2
29
+ ["ruby", "script/server"]
30
+ else
31
+ ["bundle", "exec", "rails", "server"]
32
+ end
33
+ end
34
+
35
+ def self.server_pool
36
+ @@server_pool ||= {}
37
+ end
38
+
39
+ attr_reader :port
40
+
41
+ def start
42
+ @port = Sauce::Config.new[:application_port]
43
+
44
+ if ENV["TEST_ENV_NUMBER"]
45
+ @test_env = ENV["TEST_ENV_NUMBER"].to_i
46
+ end
47
+
48
+ STDERR.puts "Starting Rails server on port #{@port}..."
49
+
50
+ @process_args = RailsServer.process_arguments
51
+ @process_args.push *["-e", "test", "--port", "#{@port}"]
52
+
53
+ if @test_env
54
+ @process_args.push *["--pid", "#{Dir.pwd}/tmp/pids/server-#{@test_env}"]
55
+ end
56
+
57
+ @server = ChildProcess.build *@process_args
58
+ @server.io.inherit!
59
+ @server.start
60
+
61
+ wait_for_server_on_port(@port)
62
+
63
+ at_exit do
64
+ @server.stop(3, "INT")
65
+ RailsServer.server_pool.delete Thread.current.object_id
66
+ end
67
+ STDERR.puts "Rails server running!"
68
+
69
+ RailsServer.server_pool[Thread.current.object_id] = @server
70
+ end
71
+
72
+ def stop
73
+ begin
74
+ @server.stop(3, "INT")
75
+ rescue
76
+ STDERR.puts "Rails server could not be killed. Did it fail to start?"
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
data/lib/sauce/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Sauce
2
- MAJOR_VERSION = '3.0'
3
- PATCH_VERSION = '6'
2
+ MAJOR_VERSION = '3.1'
3
+ PATCH_VERSION = '0'
4
4
 
5
5
  def version
6
6
  "#{MAJOR_VERSION}.#{PATCH_VERSION}"
@@ -289,7 +289,6 @@ describe Sauce::Capybara do
289
289
  end
290
290
  end
291
291
  end
292
-
293
292
  end
294
293
 
295
294
  describe '#install_hooks' do
@@ -0,0 +1,95 @@
1
+ require "spec_helper"
2
+
3
+ describe "Sauce::Utilities::RailsServer" do
4
+ let (:server) {Sauce::Utilities::RailsServer.new}
5
+
6
+ context "With a Rails 4 app" do
7
+ before (:each) do
8
+ File.stub(:exists?).and_return false
9
+ File.stub(:exists?).with("bin/rails").and_return true
10
+ end
11
+
12
+ describe "#is_rails_app?" do
13
+ it "should be true" do
14
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_true
15
+ end
16
+ end
17
+
18
+ describe "#major_version" do
19
+ it "should be 4" do
20
+ Sauce::Utilities::RailsServer.major_version.should eq 4
21
+ end
22
+ end
23
+
24
+ describe "#process_arguments" do
25
+ it "returns bundle exec rails server" do
26
+ expected_args = %w{bundle exec rails server}
27
+ Sauce::Utilities::RailsServer.process_arguments.should eq expected_args
28
+ end
29
+ end
30
+ end
31
+
32
+ context "With a Rails 3 app" do
33
+ before (:each) do
34
+ File.stub(:exists?).and_return false
35
+ File.stub(:exists?).with("script/rails").and_return true
36
+ end
37
+
38
+ describe "#is_rails_app?" do
39
+ it "should be true" do
40
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_true
41
+ end
42
+ end
43
+
44
+ describe "#major_version" do
45
+ it "should be 3" do
46
+ Sauce::Utilities::RailsServer.major_version.should eq 3
47
+ end
48
+ end
49
+
50
+ describe "#process_arguments" do
51
+ it "returns bundle exec rails server" do
52
+ expected_args = %w{bundle exec rails server}
53
+ Sauce::Utilities::RailsServer.process_arguments.should eq expected_args
54
+ end
55
+ end
56
+ end
57
+
58
+ context "Without a Rails app" do
59
+ before (:each) do
60
+ File.stub(:exists?).and_return false
61
+ end
62
+
63
+ describe "#is_rails_app?" do
64
+ it "should be false" do
65
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_false
66
+ end
67
+ end
68
+ end
69
+
70
+ context "With a Rails 4 app" do
71
+ before (:each) do
72
+ File.stub(:exists?).and_return false
73
+ File.stub(:exists?).with("bin/rails").and_return true
74
+ end
75
+
76
+ describe "#is_rails_app?" do
77
+ it "should be true" do
78
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_true
79
+ end
80
+ end
81
+
82
+ describe "#major_version" do
83
+ it "should be 4" do
84
+ Sauce::Utilities::RailsServer.major_version.should eq 4
85
+ end
86
+ end
87
+
88
+ describe "#process_arguments" do
89
+ it "returns bundle exec rails server" do
90
+ expected_args = %w{bundle exec rails server}
91
+ Sauce::Utilities::RailsServer.process_arguments.should eq expected_args
92
+ end
93
+ end
94
+ end
95
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauce
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Lacey
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-07-17 00:00:00.000000000 Z
16
+ date: 2013-07-24 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: capybara
@@ -237,6 +237,7 @@ files:
237
237
  - lib/sauce/rspec.rb
238
238
  - lib/sauce/selenium.rb
239
239
  - lib/sauce/test_unit.rb
240
+ - lib/sauce/utilities/rails_server.rb
240
241
  - lib/sauce/utilities/rake.rb
241
242
  - lib/sauce/utilities.rb
242
243
  - lib/sauce/version.rb
@@ -265,6 +266,7 @@ files:
265
266
  - spec/sauce/jasmine_spec.rb
266
267
  - spec/sauce/parallel/test_broker_spec.rb
267
268
  - spec/sauce/selenium_spec.rb
269
+ - spec/sauce/utilities/rails_server_spec.rb
268
270
  - spec/sauce/utilities/rake_spec.rb
269
271
  - spec/sauce/utilities/utilities_spec.rb
270
272
  - spec/sauce_helper.rb
@@ -317,6 +319,7 @@ test_files:
317
319
  - spec/sauce/jasmine_spec.rb
318
320
  - spec/sauce/parallel/test_broker_spec.rb
319
321
  - spec/sauce/selenium_spec.rb
322
+ - spec/sauce/utilities/rails_server_spec.rb
320
323
  - spec/sauce/utilities/rake_spec.rb
321
324
  - spec/sauce/utilities/utilities_spec.rb
322
325
  - spec/sauce_helper.rb