lindo 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/lindo.rb +19 -10
- data/lindo.gemspec +2 -2
- data/test/lindo/browser_test.rb +1 -1
- data/test/lindo_test.rb +6 -4
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/lib/lindo.rb
CHANGED
@@ -2,9 +2,6 @@ require 'test/unit'
|
|
2
2
|
require 'lindo/browser'
|
3
3
|
|
4
4
|
module Lindo
|
5
|
-
TMP = File.join(RAILS_ROOT, "tmp", "lindo")
|
6
|
-
RESPONSE_TXT = File.join(TMP, "response.txt")
|
7
|
-
RESPONSE_HTML = File.join(TMP, "response.html")
|
8
5
|
ASSETS = %w(images stylesheets javascripts)
|
9
6
|
|
10
7
|
def vr(format=:web)
|
@@ -12,23 +9,23 @@ module Lindo
|
|
12
9
|
copy_assets
|
13
10
|
if format.is_a?(Symbol)
|
14
11
|
case format
|
15
|
-
when :web then open_from_file(@response.body,
|
16
|
-
when :html then open_from_file(@response.body,
|
12
|
+
when :web then open_from_file(@response.body, response_html)
|
13
|
+
when :html then open_from_file(@response.body, response_txt)
|
17
14
|
end
|
18
15
|
else
|
19
|
-
open_from_file(format,
|
16
|
+
open_from_file(format, response_html)
|
20
17
|
end
|
21
18
|
end
|
22
19
|
|
23
20
|
def create_tmp_dir
|
24
|
-
FileUtils.rm_r(
|
25
|
-
FileUtils.mkdir_p(
|
21
|
+
FileUtils.rm_r(tmp_dir) if File.exists?(tmp_dir)
|
22
|
+
FileUtils.mkdir_p(tmp_dir)
|
26
23
|
end
|
27
24
|
|
28
25
|
def copy_assets
|
29
26
|
ASSETS.each do |e|
|
30
|
-
dir = File.join(
|
31
|
-
FileUtils.cp_r(dir,
|
27
|
+
dir = File.join(::Rails.root, "public", e)
|
28
|
+
FileUtils.cp_r(dir, tmp_dir) if File.exists?(dir)
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
@@ -41,6 +38,18 @@ module Lindo
|
|
41
38
|
def scrub(data)
|
42
39
|
ASSETS.each { |e| data.gsub!("=\"/#{e}/", "=\"#{e}/") }
|
43
40
|
end
|
41
|
+
|
42
|
+
def tmp_dir
|
43
|
+
File.join(::Rails.root, "tmp", "lindo")
|
44
|
+
end
|
45
|
+
|
46
|
+
def response_txt
|
47
|
+
File.join(tmp_dir, "response.txt")
|
48
|
+
end
|
49
|
+
|
50
|
+
def response_html
|
51
|
+
File.join(tmp_dir, "response.html")
|
52
|
+
end
|
44
53
|
end
|
45
54
|
|
46
55
|
Test::Unit::TestCase.send(:include, Lindo)
|
data/lindo.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{lindo}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Adeptware"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-07-14}
|
13
13
|
s.description = %q{Enables rendering of the body of an HTTP response from inside a functional test.}
|
14
14
|
s.email = %q{contact@adeptware.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/lindo/browser_test.rb
CHANGED
data/test/lindo_test.rb
CHANGED
@@ -2,6 +2,8 @@ require 'test/unit'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'rubygems'
|
4
4
|
require 'mocha'
|
5
|
+
|
6
|
+
class Rails; def self.root; '.'; end; end
|
5
7
|
require 'lindo'
|
6
8
|
|
7
9
|
class LindoTest < Test::Unit::TestCase
|
@@ -22,25 +24,25 @@ class LindoTest < Test::Unit::TestCase
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def test_vr
|
25
|
-
File.expects(:open).with(
|
27
|
+
File.expects(:open).with("./tmp/lindo/response.html", File::CREAT|File::TRUNC|File::WRONLY)
|
26
28
|
Browser.expects(:open).with("./tmp/lindo/response.html")
|
27
29
|
vr
|
28
30
|
end
|
29
31
|
|
30
32
|
def test_vr_in_web
|
31
|
-
File.expects(:open).with(
|
33
|
+
File.expects(:open).with("./tmp/lindo/response.html", File::CREAT|File::TRUNC|File::WRONLY)
|
32
34
|
Browser.expects(:open).with("./tmp/lindo/response.html")
|
33
35
|
vr(:web)
|
34
36
|
end
|
35
37
|
|
36
38
|
def test_vr_in_html
|
37
|
-
File.expects(:open).with(
|
39
|
+
File.expects(:open).with("./tmp/lindo/response.txt", File::CREAT|File::TRUNC|File::WRONLY)
|
38
40
|
Browser.expects(:open).with("./tmp/lindo/response.txt")
|
39
41
|
vr(:html)
|
40
42
|
end
|
41
43
|
|
42
44
|
def test_vr_with_raw_html
|
43
|
-
File.expects(:open).with(
|
45
|
+
File.expects(:open).with("./tmp/lindo/response.html", File::CREAT|File::TRUNC|File::WRONLY)
|
44
46
|
Browser.expects(:open).with("./tmp/lindo/response.html")
|
45
47
|
vr("<html></html>")
|
46
48
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lindo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
- 7
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adeptware
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-07-14 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|