rails-carrot 1.0.0 → 1.0.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/Manifest +1 -0
- data/README +4 -6
- data/Rakefile +1 -1
- data/lib/carrot.rb +1 -4
- data/lib/carrot/extend_server.rb +21 -3
- data/lib/carrot/server.rb +1 -0
- data/rails-carrot.gemspec +2 -2
- metadata +3 -3
data/Manifest
CHANGED
data/README
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
You can use carrot with celerity, or another driver.
|
2
2
|
|
3
|
-
1. gem 'carrot'
|
3
|
+
1. gem 'rails-carrot', :require => 'carrot'
|
4
4
|
|
5
5
|
2. add a celerity_helper
|
6
|
+
/spec/celerity_helper.rb
|
6
7
|
|
7
8
|
3. Add some code in celerity_helper
|
8
9
|
require 'database_cleaner'
|
9
|
-
require 'celerity'
|
10
|
+
require 'celerity' # You can change driver
|
10
11
|
require 'carrot'
|
11
12
|
|
12
13
|
ENV["RAILS_ENV"] = 'celerity' # You can change it with your enviroment
|
@@ -28,9 +29,8 @@ Carrot.configure do |config|
|
|
28
29
|
config.run_server = true
|
29
30
|
end
|
30
31
|
Carrot.register_driver(Celerity::Browser.new)
|
31
|
-
Carrot.boot
|
32
32
|
|
33
|
-
c) Local, server with external ruby
|
33
|
+
c) Local, server with external ruby, You should use jruby to run RSpec.
|
34
34
|
|
35
35
|
Carrot.configure do |config|
|
36
36
|
config.run_server = true
|
@@ -41,7 +41,6 @@ Carrot.configure do |config|
|
|
41
41
|
# config.server_debug = true
|
42
42
|
end
|
43
43
|
Carrot.register_driver(Celerity::Browser.new)
|
44
|
-
Carrot.boot
|
45
44
|
|
46
45
|
RSpec.configure do |config|
|
47
46
|
DatabaseCleaner.strategy = :truncation
|
@@ -52,7 +51,6 @@ RSpec.configure do |config|
|
|
52
51
|
end
|
53
52
|
|
54
53
|
config.after :all do
|
55
|
-
Carrot.shutdown # shutdown server
|
56
54
|
DatabaseCleaner.clean
|
57
55
|
end
|
58
56
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('rails-carrot', '1.0.
|
5
|
+
Echoe.new('rails-carrot', '1.0.1') do |p|
|
6
6
|
p.description = "Carrot can make QA test easy with any integration test gem."
|
7
7
|
p.url = "http://github.com/sloanwu/carrot.git"
|
8
8
|
p.author = "Sloan Wu"
|
data/lib/carrot.rb
CHANGED
@@ -31,12 +31,8 @@ module Carrot
|
|
31
31
|
#
|
32
32
|
# === Configurable options
|
33
33
|
#
|
34
|
-
# [asset_root = String] Where static assets are located, used by save_and_open_page
|
35
34
|
# [app_host = String] The default host to use when giving a relative URL to visit
|
36
35
|
# [run_server = Boolean] Whether to start a Rack server for the given Rack app (Default: true)
|
37
|
-
# [default_selector = :css/:xpath] Methods which take a selector use the given type by default (Default: CSS)
|
38
|
-
# [default_wait_time = Integer] The number of seconds to wait for asynchronous processes to finish (Default: 2)
|
39
|
-
# [ignore_hidden_elements = Boolean] Whether to ignore hidden elements on the page (Default: false)
|
40
36
|
#
|
41
37
|
|
42
38
|
def configure
|
@@ -49,6 +45,7 @@ module Carrot
|
|
49
45
|
|
50
46
|
def register_driver(obj)
|
51
47
|
@driver = obj
|
48
|
+
Carrot.boot
|
52
49
|
end
|
53
50
|
|
54
51
|
def boot
|
data/lib/carrot/extend_server.rb
CHANGED
@@ -4,24 +4,42 @@ require 'uri'
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'rack'
|
6
6
|
import java.lang.Runtime
|
7
|
+
import java.lang.Runnable
|
7
8
|
import java.io.InputStreamReader
|
8
9
|
import java.io.BufferedReader
|
9
10
|
|
10
11
|
module Carrot
|
11
12
|
class ExtendServer
|
12
13
|
attr_accessor :server_process, :shutdown_process
|
13
|
-
|
14
|
+
|
15
|
+
class ShutdownHook
|
16
|
+
include Runnable
|
17
|
+
def initialize( &block)
|
18
|
+
super()
|
19
|
+
@block=block
|
20
|
+
end
|
21
|
+
def run
|
22
|
+
@block[]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.at_exit( &block)
|
27
|
+
hook = ShutdownHook.new( &block)
|
28
|
+
Runtime.getRuntime().addShutdownHook(java.lang.Thread.new( hook ))
|
29
|
+
end
|
30
|
+
|
14
31
|
def run()
|
15
32
|
Thread.new do
|
16
33
|
command = ["/bin/bash","-c", "cd #{Carrot.project_path} ; #{Carrot.rails_command}"].to_java(java.lang.String)
|
17
34
|
begin
|
18
|
-
@server_process = Runtime.getRuntime().exec(command)
|
35
|
+
@server_process = Runtime.getRuntime().exec(command)
|
19
36
|
if Carrot.server_debug
|
20
37
|
buf = BufferedReader.new(InputStreamReader.new(@server_process.get_input_stream))
|
21
38
|
while line = buf.readLine()
|
22
39
|
puts line
|
23
40
|
end
|
24
41
|
end
|
42
|
+
ExtendServer.at_exit{ Carrot.shutdown }
|
25
43
|
@server_process.wait_for
|
26
44
|
rescue Exception => e
|
27
45
|
puts e
|
@@ -35,7 +53,7 @@ module Carrot
|
|
35
53
|
Thread.new do
|
36
54
|
command = ["/bin/bash","-c", "cd #{Carrot.project_path} ; kill `cat #{Carrot.project_path}/tmp/pids/server.pid`"].to_java(java.lang.String)
|
37
55
|
begin
|
38
|
-
@shutdown_process = Runtime.getRuntime().exec(command)
|
56
|
+
@shutdown_process = Runtime.getRuntime().exec(command)
|
39
57
|
@shutdown_process.wait_for
|
40
58
|
@shutdown_process.destroy
|
41
59
|
rescue Exception => e
|
data/lib/carrot/server.rb
CHANGED
data/rails-carrot.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rails-carrot}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sloan Wu"]
|
9
|
-
s.date = %q{2010-11-
|
9
|
+
s.date = %q{2010-11-03}
|
10
10
|
s.description = %q{Carrot can make QA test easy with any integration test gem.}
|
11
11
|
s.email = %q{sloanwu@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README", "lib/carrot.rb", "lib/carrot/extend_server.rb", "lib/carrot/rails.rb", "lib/carrot/server.rb", "lib/carrot/util/timeout.rb"]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sloan Wu
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-03 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|