messiah 0.0.1 → 0.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.
- data/README.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/messiah/rack_cgi_app.rb +8 -8
- data/spec/fixtures/www/path_info.php +1 -0
- data/spec/messiah_spec.rb +5 -0
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Messiah enables using Ruby testing tools for integration testing with platforms that support CGI. Notably, PHP.
|
4
4
|
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install messiah
|
8
|
+
|
5
9
|
== Configuration: RSpec
|
6
10
|
|
7
11
|
In the spec_helper.rb file, configure Messiah. Specifically, the app root and the command used to execute your app via CGI. Once the app is configured, include Messiah into RSpec.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/messiah/rack_cgi_app.rb
CHANGED
@@ -5,31 +5,31 @@ class Messiah::RackCGIApp
|
|
5
5
|
headers, status = parse_headers(header_string)
|
6
6
|
[status, headers, [body]]
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def add_to_environment!(env)
|
10
10
|
env['HTTP_HOST'] = Messiah.host
|
11
|
-
env['DOCUMENT_ROOT'] = Messiah.root
|
11
|
+
env['DOCUMENT_ROOT'] = File.expand_path Messiah.root
|
12
12
|
env['SCRIPT_NAME'] = (Messiah.script || env['PATH_INFO']).gsub(/^\//, '')
|
13
13
|
env['SCRIPT_FILENAME'] = env['PATH_TRANSLATED'] = File.join(env['DOCUMENT_ROOT'], env['SCRIPT_NAME'])
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def build_environment_string(env)
|
17
17
|
env.inject([]) do |a, item|
|
18
18
|
a << "#{item.first}=\"#{item.last}\""
|
19
19
|
a
|
20
20
|
end.join(' ')
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def call_cgi(env)
|
24
24
|
env_string = build_environment_string(env)
|
25
25
|
|
26
26
|
stdin, stdout, stderr = Open3.popen3("env #{env_string} #{Messiah.command}")
|
27
27
|
stdin.write env['rack.input'].read if env['REQUEST_METHOD'] == 'POST'
|
28
28
|
stdin.close
|
29
|
-
|
29
|
+
|
30
30
|
stdout.read.split("\n\r", 2)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def parse_headers(header)
|
34
34
|
headers = header.split("\n").inject({}) do |h, line|
|
35
35
|
key, val = line.split(':').map(&:strip)
|
@@ -37,7 +37,7 @@ class Messiah::RackCGIApp
|
|
37
37
|
h
|
38
38
|
end
|
39
39
|
status = headers.delete('Status') || 200
|
40
|
-
|
40
|
+
|
41
41
|
[headers, status]
|
42
42
|
end
|
43
|
-
end
|
43
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<?php echo $_SERVER['PATH_INFO']; ?>
|
data/spec/messiah_spec.rb
CHANGED
@@ -77,5 +77,10 @@ describe "Messiah" do
|
|
77
77
|
body.should contain "[uploaded_file]"
|
78
78
|
end
|
79
79
|
|
80
|
+
it "handles environments that drive every request through one script" do
|
81
|
+
Messiah.script 'path_info.php'
|
82
|
+
visit '/hello/there'
|
83
|
+
body.should contain '/hello/there'
|
84
|
+
end
|
80
85
|
end
|
81
86
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messiah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Cavanaugh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-31 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- spec/fixtures/www/form.php
|
71
71
|
- spec/fixtures/www/get_vars.php
|
72
72
|
- spec/fixtures/www/index.php
|
73
|
+
- spec/fixtures/www/path_info.php
|
73
74
|
- spec/fixtures/www/process.php
|
74
75
|
- spec/fixtures/www/redirector.php
|
75
76
|
- spec/fixtures/www/uploaded.php
|