gorp 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- data/gorp.gemspec +3 -3
- data/lib/gorp/commands.rb +7 -0
- data/lib/gorp/edit.rb +6 -2
- data/lib/gorp/net.rb +5 -3
- data/lib/gorp/rails.rb +37 -18
- data/lib/gorp/test.rb +4 -9
- data/lib/version.rb +1 -1
- metadata +79 -49
data/gorp.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{gorp}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.24.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sam Ruby"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-04-28}
|
10
10
|
s.description = %q{ Enables the creation of scenarios that involve creating a rails project,
|
11
11
|
starting and stoppping of servers, generating projects, editing files,
|
12
12
|
issuing http requests, running of commands, etc. Output is captured as
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gorp", "--main", "README"]
|
23
23
|
s.require_paths = ["lib"]
|
24
24
|
s.rubyforge_project = %q{gorp}
|
25
|
-
s.rubygems_version = %q{1.3.
|
25
|
+
s.rubygems_version = %q{1.3.6}
|
26
26
|
s.summary = %q{Rails scenario testing support library}
|
27
27
|
|
28
28
|
if s.respond_to? :specification_version then
|
data/lib/gorp/commands.rb
CHANGED
@@ -120,6 +120,12 @@ module Gorp
|
|
120
120
|
open('tmp/irbin','w') {|fh| fh.write(script.gsub('\n',"\n")+"\n")}
|
121
121
|
cmd "IRBRC=tmp/irbrc ruby #{console_cmd} < tmp/irbin"
|
122
122
|
FileUtils.rm_rf 'tmp/irbin'
|
123
|
+
elsif RUBY_PLATFORM =~ /w32/
|
124
|
+
open('tmp/irbin','w') {|fh| fh.write(script.gsub('\n',"\r\n")+"\r\n")}
|
125
|
+
save, ENV['IRBRC']=ENV['IRBRC'], 'tmp/irbin'
|
126
|
+
cmd "cmd /c ruby #{console_cmd} < tmp/irbin"
|
127
|
+
ENV['IRBRC']=save
|
128
|
+
FileUtils.rm_rf 'tmp/irbin'
|
123
129
|
else
|
124
130
|
cmd "echo #{script.inspect} | IRBRC=tmp/irbrc ruby #{console_cmd}"
|
125
131
|
end
|
@@ -152,6 +158,7 @@ module Gorp
|
|
152
158
|
|
153
159
|
if RUBY_PLATFORM =~ /w32/
|
154
160
|
args.gsub! '/', '\\' unless args =~ /http:/
|
161
|
+
args.sub! /^cmd \\c/, 'cmd /c'
|
155
162
|
args.sub! /^cp -v/, 'xcopy /i /f /y'
|
156
163
|
args.sub! /^ls -p/, 'dir/w'
|
157
164
|
args.sub! /^ls/, 'dir'
|
data/lib/gorp/edit.rb
CHANGED
@@ -92,7 +92,8 @@ module Gorp
|
|
92
92
|
self.sub!(re) do |lines|
|
93
93
|
lines.extend Gorp::StringEditingFunctions
|
94
94
|
lines.instance_exec(lines, &block) if block_given?
|
95
|
-
lines.mark(options.last[:mark]) if options.last.respond_to? :[]
|
95
|
+
lines.mark(options.last[:mark]) if options.last.respond_to? :[]=
|
96
|
+
lines.highlight if options.last == :highlight
|
96
97
|
lines
|
97
98
|
end
|
98
99
|
end
|
@@ -113,6 +114,9 @@ module Gorp
|
|
113
114
|
if option == :highlight
|
114
115
|
replacement.extend Gorp::StringEditingFunctions
|
115
116
|
replacement.highlight if option == :highlight
|
117
|
+
elsif option.respond_to? :keys
|
118
|
+
replacement.extend Gorp::StringEditingFunctions
|
119
|
+
replacement.mark(option[:mark])
|
116
120
|
end
|
117
121
|
|
118
122
|
if replacement =~ /\\[1-9]/
|
@@ -158,7 +162,7 @@ def edit filename, tag=nil, &block
|
|
158
162
|
tag = nil
|
159
163
|
|
160
164
|
ensure
|
161
|
-
log :edit, filename
|
165
|
+
log :edit, filename.gsub('/',FILE_SEPARATOR)
|
162
166
|
|
163
167
|
include = tag.nil?
|
164
168
|
highlight = false
|
data/lib/gorp/net.rb
CHANGED
@@ -75,8 +75,8 @@ def snap response, form=nil
|
|
75
75
|
$x.div '', :style => "clear: both"
|
76
76
|
end
|
77
77
|
|
78
|
-
def get path
|
79
|
-
post path, nil
|
78
|
+
def get path, options={}
|
79
|
+
post path, nil, options
|
80
80
|
end
|
81
81
|
|
82
82
|
def post path, form, options={}
|
@@ -90,7 +90,7 @@ def post path, form, options={}
|
|
90
90
|
end
|
91
91
|
|
92
92
|
Net::HTTP.start(host, port) do |http|
|
93
|
-
accept = 'text/html'
|
93
|
+
accept = options[:accept] || 'text/html'
|
94
94
|
accept = 'application/atom+xml' if path =~ /\.atom$/
|
95
95
|
accept = 'application/json' if path =~ /\.json$/
|
96
96
|
accept = 'application/xml' if path =~ /\.xml$/
|
@@ -176,4 +176,6 @@ def post path, form, options={}
|
|
176
176
|
$COOKIE=response.response['set-cookie'] if response.response['set-cookie']
|
177
177
|
end
|
178
178
|
end
|
179
|
+
rescue Timeout::Error
|
180
|
+
Gorp::Commands.stop_server(false, 9)
|
179
181
|
end
|
data/lib/gorp/rails.rb
CHANGED
@@ -3,6 +3,21 @@ require 'builder'
|
|
3
3
|
require 'stringio'
|
4
4
|
require 'time'
|
5
5
|
|
6
|
+
module Gorp
|
7
|
+
# determine which version of rails is running
|
8
|
+
def self.which_rails rails
|
9
|
+
railties = File.join(rails, 'railties', 'bin', 'rails')
|
10
|
+
rails = railties if File.exists?(railties)
|
11
|
+
bin = File.join(rails, 'bin', 'rails')
|
12
|
+
rails = bin if File.exists?(bin)
|
13
|
+
if File.exists?(rails)
|
14
|
+
firstline = open(rails) {|file| file.readlines.first}
|
15
|
+
rails = 'ruby ' + rails unless firstline =~ /^#!/
|
16
|
+
end
|
17
|
+
rails
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
6
21
|
# verify that port is available for testing
|
7
22
|
if (Net::HTTP.get_response('localhost','/',$PORT).code == '200' rescue false)
|
8
23
|
STDERR.puts "local server already running on port #{$PORT}"
|
@@ -46,7 +61,7 @@ end
|
|
46
61
|
if $rails =~ /^rails( |$)/
|
47
62
|
`#{$rails} -v 2>#{DEV_NULL}`
|
48
63
|
else
|
49
|
-
|
64
|
+
`#{Gorp.which_rails($rails)} -v 2>#{DEV_NULL}`
|
50
65
|
end
|
51
66
|
|
52
67
|
if $?.success?
|
@@ -77,17 +92,6 @@ $bundle = true if ARGV.include?('--bundle')
|
|
77
92
|
$bundle = false if ARGV.include?('--vendor')
|
78
93
|
|
79
94
|
module Gorp
|
80
|
-
# determine which version of rails is running
|
81
|
-
def self.which_rails rails
|
82
|
-
railties = File.join(rails, 'railties', 'bin', 'rails')
|
83
|
-
rails = railties if File.exists?(railties)
|
84
|
-
if File.exists?(rails)
|
85
|
-
firstline = open(rails) {|file| file.readlines.first}
|
86
|
-
rails = 'ruby ' + rails unless firstline =~ /^#!/
|
87
|
-
end
|
88
|
-
rails
|
89
|
-
end
|
90
|
-
|
91
95
|
module Commands
|
92
96
|
# run rails as a command
|
93
97
|
def rails name, app=nil
|
@@ -150,7 +154,7 @@ module Gorp
|
|
150
154
|
end
|
151
155
|
|
152
156
|
# stop a server if it is currently running
|
153
|
-
def self.stop_server(restart=false)
|
157
|
+
def self.stop_server(restart=false, signal="INT")
|
154
158
|
if !restart and $cleanup
|
155
159
|
$cleanup.call
|
156
160
|
$cleanup = nil
|
@@ -159,12 +163,21 @@ module Gorp
|
|
159
163
|
if $server
|
160
164
|
if $server.respond_to?(:process_id)
|
161
165
|
# Windows
|
162
|
-
|
166
|
+
signal = 1 if signal == "INT"
|
167
|
+
Process.kill signal, $server.process_id
|
163
168
|
Process.waitpid($server.process_id) rescue nil
|
164
169
|
else
|
165
170
|
# UNIX
|
166
|
-
|
167
|
-
Process.
|
171
|
+
require 'timeout'
|
172
|
+
Process.kill signal, $server
|
173
|
+
begin
|
174
|
+
Timeout::timeout(15) do
|
175
|
+
Process.wait $server
|
176
|
+
end
|
177
|
+
rescue Timeout::Error
|
178
|
+
Process.kill 9, $server
|
179
|
+
Process.wait $server
|
180
|
+
end
|
168
181
|
end
|
169
182
|
end
|
170
183
|
ensure
|
@@ -192,8 +205,14 @@ module Gorp
|
|
192
205
|
$server = fork
|
193
206
|
else
|
194
207
|
require 'win32/process'
|
195
|
-
|
196
|
-
|
208
|
+
begin
|
209
|
+
save = STDOUT.dup
|
210
|
+
STDOUT.reopen(File.open('NUL','w+'))
|
211
|
+
$server = Process.create(:app_name => rails_server, :inherit => true)
|
212
|
+
# :startup_info => {:stdout => File.open('server.log','w+')})
|
213
|
+
ensure
|
214
|
+
STDOUT.reopen save
|
215
|
+
end
|
197
216
|
end
|
198
217
|
|
199
218
|
if $server
|
data/lib/gorp/test.rb
CHANGED
@@ -102,14 +102,6 @@ class Gorp::TestCase < Test::Unit::TestCase
|
|
102
102
|
next unless key =~ /^\d/
|
103
103
|
@@sections[key] = "<a class=\"toc\" id=\"section-#{key}\">#{value}"
|
104
104
|
end
|
105
|
-
|
106
|
-
# report version
|
107
|
-
body =~ /rails .*?-v<\/pre>\s+.*?>(.*)<\/pre>/
|
108
|
-
@@version = $1
|
109
|
-
@@version += ' (git)' if body =~ /"stdin">ln -s.*vendor.rails</
|
110
|
-
@@version += ' (edge)' if body =~ /"stdin">rails:freeze:edge</
|
111
|
-
@@version += ' (bundle)' if body =~ /"stdin">gem bundle</
|
112
|
-
STDERR.puts @@version
|
113
105
|
end
|
114
106
|
|
115
107
|
def self.output filename
|
@@ -192,8 +184,11 @@ class HTMLRunner < Test::Unit::UI::Console::TestRunner
|
|
192
184
|
}
|
193
185
|
|
194
186
|
if fault.respond_to? :location
|
187
|
+
location = fault.location
|
188
|
+
location.shift while location.first.to_s. =~ /testing.assertions.selector/
|
189
|
+
location.pop while location.last.to_s. =~ /gorp.lib.gorp.test/
|
195
190
|
x.pre fault.message.sub(".\n<false> is not true",'') +
|
196
|
-
"\n\nTraceback:\n " +
|
191
|
+
"\n\nTraceback:\n " + location.join("\n "),
|
197
192
|
:class=>'traceback'
|
198
193
|
else
|
199
194
|
if fault.message =~ /RuntimeError: Ticket (\w+):(\d+): (.*)/
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 24
|
8
|
+
- 0
|
9
|
+
version: 0.24.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Sam Ruby
|
@@ -9,119 +14,141 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-28 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: builder
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
33
|
name: bundler
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
33
41
|
version: "0"
|
34
|
-
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
35
44
|
- !ruby/object:Gem::Dependency
|
36
45
|
name: erubis
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
48
|
requirements:
|
41
49
|
- - ">="
|
42
50
|
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
43
53
|
version: "0"
|
44
|
-
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
45
56
|
- !ruby/object:Gem::Dependency
|
46
57
|
name: i18n
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
prerelease: false
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
60
|
requirements:
|
51
61
|
- - ">="
|
52
62
|
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
53
65
|
version: "0"
|
54
|
-
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id004
|
55
68
|
- !ruby/object:Gem::Dependency
|
56
69
|
name: rack
|
57
|
-
|
58
|
-
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
60
72
|
requirements:
|
61
73
|
- - ">="
|
62
74
|
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
63
77
|
version: "0"
|
64
|
-
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id005
|
65
80
|
- !ruby/object:Gem::Dependency
|
66
81
|
name: rack-mount
|
67
|
-
|
68
|
-
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
70
84
|
requirements:
|
71
85
|
- - ">="
|
72
86
|
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 0
|
73
89
|
version: "0"
|
74
|
-
|
90
|
+
type: :runtime
|
91
|
+
version_requirements: *id006
|
75
92
|
- !ruby/object:Gem::Dependency
|
76
93
|
name: rack-test
|
77
|
-
|
78
|
-
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
80
96
|
requirements:
|
81
97
|
- - ">="
|
82
98
|
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 0
|
83
101
|
version: "0"
|
84
|
-
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id007
|
85
104
|
- !ruby/object:Gem::Dependency
|
86
105
|
name: rake
|
87
|
-
|
88
|
-
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
90
108
|
requirements:
|
91
109
|
- - ">="
|
92
110
|
- !ruby/object:Gem::Version
|
111
|
+
segments:
|
112
|
+
- 0
|
93
113
|
version: "0"
|
94
|
-
|
114
|
+
type: :runtime
|
115
|
+
version_requirements: *id008
|
95
116
|
- !ruby/object:Gem::Dependency
|
96
117
|
name: thor
|
97
|
-
|
98
|
-
|
99
|
-
version_requirements: !ruby/object:Gem::Requirement
|
118
|
+
prerelease: false
|
119
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
100
120
|
requirements:
|
101
121
|
- - ">="
|
102
122
|
- !ruby/object:Gem::Version
|
123
|
+
segments:
|
124
|
+
- 0
|
103
125
|
version: "0"
|
104
|
-
|
126
|
+
type: :runtime
|
127
|
+
version_requirements: *id009
|
105
128
|
- !ruby/object:Gem::Dependency
|
106
129
|
name: sqlite3-ruby
|
107
|
-
|
108
|
-
|
109
|
-
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
prerelease: false
|
131
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
110
132
|
requirements:
|
111
133
|
- - ">="
|
112
134
|
- !ruby/object:Gem::Version
|
135
|
+
segments:
|
136
|
+
- 0
|
113
137
|
version: "0"
|
114
|
-
|
138
|
+
type: :runtime
|
139
|
+
version_requirements: *id010
|
115
140
|
- !ruby/object:Gem::Dependency
|
116
141
|
name: tzinfo
|
117
|
-
|
118
|
-
|
119
|
-
version_requirements: !ruby/object:Gem::Requirement
|
142
|
+
prerelease: false
|
143
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
120
144
|
requirements:
|
121
145
|
- - ">="
|
122
146
|
- !ruby/object:Gem::Version
|
147
|
+
segments:
|
148
|
+
- 0
|
123
149
|
version: "0"
|
124
|
-
|
150
|
+
type: :runtime
|
151
|
+
version_requirements: *id011
|
125
152
|
description: " Enables the creation of scenarios that involve creating a rails project,\n starting and stoppping of servers, generating projects, editing files,\n issuing http requests, running of commands, etc. Output is captured as\n a single HTML file that can be viewed locally or uploaded.\n\n Additionally, there is support for verification, in the form of defining\n assertions based on selections (typically CSS) against the generated HTML.\n"
|
126
153
|
email: rubys@intertwingly.net
|
127
154
|
executables: []
|
@@ -177,18 +204,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
204
|
requirements:
|
178
205
|
- - ">="
|
179
206
|
- !ruby/object:Gem::Version
|
207
|
+
segments:
|
208
|
+
- 0
|
180
209
|
version: "0"
|
181
|
-
version:
|
182
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
211
|
requirements:
|
184
212
|
- - ">="
|
185
213
|
- !ruby/object:Gem::Version
|
214
|
+
segments:
|
215
|
+
- 1
|
216
|
+
- 2
|
186
217
|
version: "1.2"
|
187
|
-
version:
|
188
218
|
requirements: []
|
189
219
|
|
190
220
|
rubyforge_project: gorp
|
191
|
-
rubygems_version: 1.3.
|
221
|
+
rubygems_version: 1.3.6
|
192
222
|
signing_key:
|
193
223
|
specification_version: 3
|
194
224
|
summary: Rails scenario testing support library
|