gorp 0.13.0 → 0.14.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.
- data/gorp.gemspec +2 -2
- data/lib/gorp.rb +10 -5
- data/lib/gorp/test.rb +16 -12
- data/lib/version.rb +1 -1
- metadata +2 -2
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.14.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{2009-12-
|
9
|
+
s.date = %q{2009-12-23}
|
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
|
data/lib/gorp.rb
CHANGED
@@ -52,6 +52,9 @@ class String
|
|
52
52
|
def unindent(n)
|
53
53
|
gsub Regexp.new("^#{' '*n}"), ''
|
54
54
|
end
|
55
|
+
def indent(n)
|
56
|
+
gsub /^/, ' '*n
|
57
|
+
end
|
55
58
|
end
|
56
59
|
|
57
60
|
def read name
|
@@ -352,7 +355,7 @@ rescue LoadError
|
|
352
355
|
Comment = REXML::Comment
|
353
356
|
end
|
354
357
|
|
355
|
-
def snap response, form=
|
358
|
+
def snap response, form=nil
|
356
359
|
if response.content_type == 'text/plain' or response.content_type =~ /xml/
|
357
360
|
$x.div :class => 'body' do
|
358
361
|
response.body.split("\n").each do |line|
|
@@ -381,12 +384,12 @@ def snap response, form={}
|
|
381
384
|
body.children.first.add_previous_sibling(sheet)
|
382
385
|
end
|
383
386
|
|
384
|
-
if
|
387
|
+
if form
|
385
388
|
body.search('//input[@name]').each do |input|
|
386
389
|
input['value'] ||= form[input['name']].to_s
|
387
390
|
end
|
388
391
|
body.search('//textarea[@name]').each do |textarea|
|
389
|
-
textarea.text
|
392
|
+
textarea.text = form[textarea['name']].to_s if textarea.text.to_s.empty?
|
390
393
|
end
|
391
394
|
end
|
392
395
|
|
@@ -423,7 +426,7 @@ def snap response, form={}
|
|
423
426
|
end
|
424
427
|
|
425
428
|
def get path
|
426
|
-
post path,
|
429
|
+
post path, nil
|
427
430
|
end
|
428
431
|
|
429
432
|
def post path, form, options={}
|
@@ -442,7 +445,7 @@ def post path, form, options={}
|
|
442
445
|
snap response, form unless options[:snapget] == false
|
443
446
|
$COOKIE = response.response['set-cookie'] if response.response['set-cookie']
|
444
447
|
|
445
|
-
if
|
448
|
+
if form
|
446
449
|
body = xhtmlparse(response.body).at('//body')
|
447
450
|
body = xhtmlparse(response.body).root unless body
|
448
451
|
xforms = body.search('//form')
|
@@ -551,12 +554,14 @@ def rails name, app=nil
|
|
551
554
|
open(script,'w') {|file| file.write code}
|
552
555
|
end
|
553
556
|
|
557
|
+
cmd "mkdir #{name}" unless File.exist?(name)
|
554
558
|
Dir.chdir(name)
|
555
559
|
FileUtils.rm_rf 'public/.htaccess'
|
556
560
|
|
557
561
|
cmd 'rake rails:freeze:edge' if ARGV.include? 'edge'
|
558
562
|
|
559
563
|
if $rails != 'rails' and File.directory?($rails)
|
564
|
+
cmd "mkdir vendor" unless File.exist?('vendor')
|
560
565
|
cmd "ln -s #{$rails} vendor/rails"
|
561
566
|
end
|
562
567
|
end
|
data/lib/gorp/test.rb
CHANGED
@@ -14,21 +14,19 @@ end
|
|
14
14
|
class Book::TestCase < ActiveSupport::TestCase
|
15
15
|
# just enough infrastructure to get 'assert_select' to work
|
16
16
|
$:.unshift "#{$WORK}/depot/vendor/rails/actionpack/lib"
|
17
|
+
require 'action_controller'
|
17
18
|
begin
|
18
|
-
#
|
19
|
-
require 'action_controller'
|
19
|
+
# Rails (2.3.3 ish)
|
20
20
|
require 'action_controller/assertions/selector_assertions'
|
21
21
|
include ActionController::Assertions::SelectorAssertions
|
22
|
-
require 'action_controller/vendor/html-scanner/html/tokenizer'
|
23
|
-
require 'action_controller/vendor/html-scanner/html/document'
|
24
22
|
rescue LoadError
|
25
|
-
#
|
26
|
-
require 'action_controller'
|
23
|
+
# Rails (3.0 ish)
|
27
24
|
require 'action_dispatch/testing/assertions'
|
28
|
-
|
25
|
+
require 'action_dispatch/testing/assertions/selector'
|
29
26
|
include ActionDispatch::Assertions::SelectorAssertions
|
30
27
|
end
|
31
|
-
|
28
|
+
require 'action_controller/vendor/html-scanner/html/tokenizer'
|
29
|
+
require 'action_controller/vendor/html-scanner/html/document'
|
32
30
|
|
33
31
|
# micro DSL allowing the definition of optional tests
|
34
32
|
def self.section number, title, &tests
|
@@ -84,12 +82,18 @@ class Book::TestCase < ActiveSupport::TestCase
|
|
84
82
|
# select an individual section from the HTML
|
85
83
|
def select number
|
86
84
|
raise "Section #{number} not found" unless @@sections.has_key? number.to_s
|
87
|
-
@
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
@raw = @@sections[number.to_s]
|
86
|
+
@selected = HTML::Document.new(@raw).root.children
|
87
|
+
|
88
|
+
@raw =~ /<pre\sclass="stdin">edit\s([\w\/.]+)<\/pre>\s+
|
89
|
+
<pre\sclass="traceback">\s+
|
90
|
+
\#<IndexError:\sregexp\snot\smatched>\s+
|
91
|
+
([\w\/.]+:\d+)/x
|
92
|
+
fail "edit #{$1} failed at #{$2}" if $1
|
91
93
|
end
|
92
94
|
|
95
|
+
attr_reader :raw
|
96
|
+
|
93
97
|
def collect_stdout
|
94
98
|
css_select('.stdout').map do |tag|
|
95
99
|
tag.children.join.gsub('<','<').gsub('>','>')
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-23 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|