rdaneel 0.1.2 → 0.1.3
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/VERSION +1 -1
- data/lib/rdaneel.rb +1 -1
- data/spec/no_redirects_neither_robots_spec.rb +25 -66
- data/spec/redirects_without_robots_spec.rb +44 -44
- data/spec/spec_helper.rb +53 -38
- data/spec/streamed_content_spec.rb +51 -0
- data/spec/using_cache_spec.rb +12 -10
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/rdaneel.rb
CHANGED
@@ -91,7 +91,7 @@ class RDaneel
|
|
91
91
|
end
|
92
92
|
else
|
93
93
|
robots_url = robots_txt_url(current_uri)
|
94
|
-
robots = EM::HttpRequest.new(robots_url).get
|
94
|
+
robots = EM::HttpRequest.new(robots_url).get(:redirects => 2) # get the robots.txt following redirects
|
95
95
|
robots.callback {
|
96
96
|
robots_file = robots.response
|
97
97
|
robots_cache[robots_url.to_s] = robots_file if robots_cache
|
@@ -2,76 +2,38 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "RDaneel when there are no redirects" do
|
4
4
|
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
burrito.mount( :path => '/', :status => 200,
|
8
|
-
:body => 'Hello World!', :block => should_be_hit_once )
|
9
|
-
burrito.mount( :path => '/robots.txt', :status => 404,
|
10
|
-
:block => should_be_hit_once )
|
11
|
-
end
|
12
|
-
|
13
|
-
after(:each) do
|
14
|
-
burrito.unmount('/')
|
15
|
-
burrito.unmount('/robots.txt')
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should get the content is the url not end with /" do
|
19
|
-
|
20
|
-
EM.run do
|
21
|
-
r = RDaneel.new("http://127.0.0.1:8080")
|
22
|
-
r.callback do
|
23
|
-
r.http_client.response_header.status.should == 200
|
24
|
-
r.http_client.response.should == "Hello World!"
|
25
|
-
r.redirects.should be_empty
|
26
|
-
EM.stop
|
27
|
-
end
|
28
|
-
r.errback do
|
29
|
-
fail
|
30
|
-
EM.stop
|
31
|
-
end
|
32
|
-
r.get
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
|
5
|
+
let(:port) {8083}
|
39
6
|
|
40
7
|
describe "when a successfull status different than 200 is issued for robots.txt" do
|
41
|
-
|
42
8
|
it "should get the content ignoring the redirect"
|
43
|
-
|
44
9
|
end
|
45
10
|
|
46
11
|
describe "when a redirect other than 301 and 302 is issued for robots.txt" do
|
47
|
-
|
48
12
|
it "should get the content ignoring the redirect"
|
49
|
-
|
50
13
|
end
|
51
14
|
|
52
15
|
(301..302).each do |status|
|
53
16
|
|
54
17
|
describe "when robots.txt has been moved (http code #{status})" do
|
55
18
|
before(:each) do
|
56
|
-
|
19
|
+
server_setup(port+status) do |server|
|
20
|
+
mount(server, :path => '/hello_world', :status => 200,
|
57
21
|
:body => 'Hello World!', :block => should_be_hit_once )
|
58
|
-
|
59
|
-
:location =>
|
22
|
+
mount(server, :path => '/robots.txt', :status => status,
|
23
|
+
:location => "http://127.0.0.1:#{port+status}/golems.txt",
|
24
|
+
:block => should_be_hit_once )
|
25
|
+
mount(server, :path => '/golems.txt', :status => 200,
|
60
26
|
:block => should_be_hit_once )
|
61
|
-
|
62
|
-
:block => should_not_be_hit )
|
27
|
+
end
|
63
28
|
end
|
64
29
|
|
65
30
|
after(:each) do
|
66
|
-
|
67
|
-
burrito.unmount('/robots.txt')
|
68
|
-
burrito.unmount('/golems.txt')
|
31
|
+
server_shutdown
|
69
32
|
end
|
70
33
|
|
71
|
-
it "should get the
|
72
|
-
|
34
|
+
it "should get the redirected robots.txt and the content" do
|
73
35
|
EM.run do
|
74
|
-
r = RDaneel.new("http://127.0.0.1
|
36
|
+
r = RDaneel.new("http://127.0.0.1:#{port+status}/hello_world")
|
75
37
|
r.callback do
|
76
38
|
r.http_client.response_header.status.should == 200
|
77
39
|
r.http_client.response.should == "Hello World!"
|
@@ -84,7 +46,6 @@ describe "RDaneel when there are no redirects" do
|
|
84
46
|
end
|
85
47
|
r.get
|
86
48
|
end
|
87
|
-
|
88
49
|
end
|
89
50
|
|
90
51
|
end
|
@@ -95,21 +56,21 @@ describe "RDaneel when there are no redirects" do
|
|
95
56
|
|
96
57
|
describe "when there is a CLIENT error #{status} associated to robots.txt" do
|
97
58
|
before(:each) do
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
59
|
+
server_setup(port+status) do |server|
|
60
|
+
mount(server, :path => '/hello_world', :status => 200,
|
61
|
+
:body => 'Hello World!', :block => should_be_hit_once )
|
62
|
+
mount(server, :path => '/robots.txt', :status => status,
|
63
|
+
:block => should_be_hit_once )
|
64
|
+
end
|
102
65
|
end
|
103
66
|
|
104
67
|
after(:each) do
|
105
|
-
|
106
|
-
burrito.unmount('/robots.txt')
|
68
|
+
server_shutdown
|
107
69
|
end
|
108
70
|
|
109
71
|
it "should get the content" do
|
110
|
-
|
111
72
|
EM.run do
|
112
|
-
r = RDaneel.new("http://127.0.0.1
|
73
|
+
r = RDaneel.new("http://127.0.0.1:#{port+status}/hello_world")
|
113
74
|
r.callback do
|
114
75
|
r.http_client.response_header.status.should == 200
|
115
76
|
r.http_client.response.should == "Hello World!"
|
@@ -122,7 +83,6 @@ describe "RDaneel when there are no redirects" do
|
|
122
83
|
end
|
123
84
|
r.get
|
124
85
|
end
|
125
|
-
|
126
86
|
end
|
127
87
|
|
128
88
|
end
|
@@ -133,21 +93,21 @@ describe "RDaneel when there are no redirects" do
|
|
133
93
|
|
134
94
|
describe "when there is a SERVER error #{status} associated to robots.txt" do
|
135
95
|
before(:each) do
|
136
|
-
|
96
|
+
server_setup(port+status) do |server|
|
97
|
+
mount(server, :path => '/hello_world', :status => 200,
|
137
98
|
:body => 'Hello World!', :block => should_be_hit_once )
|
138
|
-
|
99
|
+
mount(server, :path => '/robots.txt', :status => status,
|
139
100
|
:block => should_be_hit_once )
|
101
|
+
end
|
140
102
|
end
|
141
103
|
|
142
104
|
after (:each) do
|
143
|
-
|
144
|
-
burrito.unmount('/robots.txt')
|
105
|
+
server_shutdown
|
145
106
|
end
|
146
107
|
|
147
108
|
it "should get the content" do
|
148
|
-
|
149
109
|
EM.run do
|
150
|
-
r = RDaneel.new("http://127.0.0.1
|
110
|
+
r = RDaneel.new("http://127.0.0.1:#{port+status}/hello_world")
|
151
111
|
r.callback do
|
152
112
|
r.http_client.response_header.status.should == 200
|
153
113
|
r.http_client.response.should == "Hello World!"
|
@@ -160,7 +120,6 @@ describe "RDaneel when there are no redirects" do
|
|
160
120
|
end
|
161
121
|
r.get
|
162
122
|
end
|
163
|
-
|
164
123
|
end
|
165
124
|
|
166
125
|
end
|
@@ -2,29 +2,31 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "RDaneel when there are redirects" do
|
4
4
|
|
5
|
+
let(:port) {8081}
|
6
|
+
|
5
7
|
describe "when there is no robots.txt in the host (ONLY one host)" do
|
6
8
|
|
7
9
|
describe "when no redirection limit has been set" do
|
8
10
|
before(:each) do
|
9
|
-
|
11
|
+
server_setup(port) do |server|
|
12
|
+
mount(server, :path => '/robots.txt', :status => 404,
|
10
13
|
:block => should_be_hit_once )
|
11
|
-
|
12
|
-
:location =>
|
14
|
+
mount(server, :path => '/redirect_me', :status => 301,
|
15
|
+
:location => "http://127.0.0.1:#{port}/hello_world",
|
13
16
|
:block => should_be_hit_once )
|
14
|
-
|
17
|
+
mount(server, :path => '/hello_world', :status => 200,
|
15
18
|
:body => 'Hello World!',
|
16
19
|
:block => should_not_be_hit )
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
after(:each) do
|
20
|
-
|
21
|
-
burrito.unmount('/redirect_me')
|
22
|
-
burrito.unmount('/hello_world')
|
24
|
+
server_shutdown
|
23
25
|
end
|
24
26
|
|
25
27
|
it "should not follow redirects" do
|
26
28
|
EM.run do
|
27
|
-
r = RDaneel.new("http://127.0.0.1
|
29
|
+
r = RDaneel.new("http://127.0.0.1:#{port}/redirect_me")
|
28
30
|
r.callback do
|
29
31
|
fail
|
30
32
|
EM.stop
|
@@ -45,35 +47,34 @@ describe "RDaneel when there are redirects" do
|
|
45
47
|
|
46
48
|
describe "when there are less redirects than the maximum specified" do
|
47
49
|
before(:each) do
|
48
|
-
|
50
|
+
server_setup(port) do |server|
|
51
|
+
mount(server, :path => '/robots.txt', :status => 404,
|
49
52
|
:block => should_be_hit(3) )
|
50
|
-
|
51
|
-
:location =>
|
53
|
+
mount(server, :path => '/redirect_me', :status => 301,
|
54
|
+
:location => "http://127.0.0.1:#{port}/redirect_me_again",
|
52
55
|
:block => should_be_hit_once )
|
53
|
-
|
54
|
-
:location =>
|
56
|
+
mount(server, :path => '/redirect_me_again', :status => 301,
|
57
|
+
:location => "http://127.0.0.1:#{port}/hello_world",
|
55
58
|
:block => should_be_hit_once )
|
56
|
-
|
59
|
+
mount(server, :path => '/hello_world', :status => 200,
|
57
60
|
:body => 'Hello World!',
|
58
61
|
:block => should_be_hit_once )
|
62
|
+
end
|
59
63
|
end
|
60
64
|
|
61
65
|
after(:each) do
|
62
|
-
|
63
|
-
burrito.unmount('/redirect_me')
|
64
|
-
burrito.unmount('/redirect_me_again')
|
65
|
-
burrito.unmount('/hello_world')
|
66
|
+
server_shutdown
|
66
67
|
end
|
67
68
|
|
68
69
|
it "should get the content following all the redirects" do
|
69
70
|
EM.run do
|
70
|
-
r = RDaneel.new("http://127.0.0.1
|
71
|
+
r = RDaneel.new("http://127.0.0.1:#{port}/redirect_me")
|
71
72
|
r.callback do
|
72
73
|
r.http_client.response_header.status.should == 200
|
73
74
|
r.http_client.response.should == "Hello World!"
|
74
|
-
r.redirects.should == [ "http://127.0.0.1
|
75
|
-
"http://127.0.0.1
|
76
|
-
r.uri.to_s.should == "http://127.0.0.1
|
75
|
+
r.redirects.should == [ "http://127.0.0.1:#{port}/redirect_me",
|
76
|
+
"http://127.0.0.1:#{port}/redirect_me_again"]
|
77
|
+
r.uri.to_s.should == "http://127.0.0.1:#{port}/hello_world"
|
77
78
|
EM.stop
|
78
79
|
end
|
79
80
|
r.errback do
|
@@ -89,30 +90,30 @@ describe "RDaneel when there are redirects" do
|
|
89
90
|
|
90
91
|
describe "when there are as many redirects as the maximum" do
|
91
92
|
before(:each) do
|
92
|
-
|
93
|
+
server_setup(port) do |server|
|
94
|
+
mount(server, :path => '/robots.txt', :status => 404,
|
93
95
|
:block => should_be_hit_twice )
|
94
|
-
|
95
|
-
:location =>
|
96
|
+
mount(server, :path => '/redirect_me', :status => 301,
|
97
|
+
:location => "http://127.0.0.1:#{port}/hello_world",
|
96
98
|
:block => should_be_hit_once )
|
97
|
-
|
99
|
+
mount(server, :path => '/hello_world', :status => 200,
|
98
100
|
:body => 'Hello World!',
|
99
101
|
:block => should_be_hit_once )
|
102
|
+
end
|
100
103
|
end
|
101
104
|
|
102
105
|
after(:each) do
|
103
|
-
|
104
|
-
burrito.unmount('/redirect_me')
|
105
|
-
burrito.unmount('/hello_world')
|
106
|
+
server_shutdown
|
106
107
|
end
|
107
108
|
|
108
109
|
it "should get the content following all the redirects" do
|
109
110
|
EM.run do
|
110
|
-
r = RDaneel.new("http://127.0.0.1
|
111
|
+
r = RDaneel.new("http://127.0.0.1:#{port}/redirect_me")
|
111
112
|
r.callback do
|
112
113
|
r.http_client.response_header.status.should == 200
|
113
114
|
r.http_client.response.should == "Hello World!"
|
114
|
-
r.redirects.should == [
|
115
|
-
r.uri.to_s.should == "http://127.0.0.1
|
115
|
+
r.redirects.should == ["http://127.0.0.1:#{port}/redirect_me"]
|
116
|
+
r.uri.to_s.should == "http://127.0.0.1:#{port}/hello_world"
|
116
117
|
EM.stop
|
117
118
|
end
|
118
119
|
r.errback do
|
@@ -128,35 +129,34 @@ describe "RDaneel when there are redirects" do
|
|
128
129
|
|
129
130
|
describe "when the number of redirects exceed the maximum specified" do
|
130
131
|
before(:each) do
|
131
|
-
|
132
|
+
server_setup(port) do |server|
|
133
|
+
mount(server, :path => '/robots.txt', :status => 404,
|
132
134
|
:block => should_be_hit_twice )
|
133
|
-
|
134
|
-
:location =>
|
135
|
+
mount(server, :path => '/redirect_me', :status => 301,
|
136
|
+
:location => "http://127.0.0.1:#{port}/redirect_me_again",
|
135
137
|
:block => should_be_hit_once )
|
136
|
-
|
137
|
-
:location =>
|
138
|
+
mount(server, :path => '/redirect_me_again', :status => 301,
|
139
|
+
:location => "http://127.0.0.1:#{port}/hello_world",
|
138
140
|
:block => should_be_hit_once )
|
139
|
-
|
141
|
+
mount(server, :path => '/hello_world', :status => 200,
|
140
142
|
:body => 'Hello World!',
|
141
143
|
:block => should_not_be_hit )
|
144
|
+
end
|
142
145
|
end
|
143
146
|
|
144
147
|
after(:each) do
|
145
|
-
|
146
|
-
burrito.unmount('/redirect_me')
|
147
|
-
burrito.unmount('/redirect_me_again')
|
148
|
-
burrito.unmount('/hello_world')
|
148
|
+
server_shutdown
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should stop following redirects once the maximum specified is reached" do
|
152
152
|
EM.run do
|
153
|
-
r = RDaneel.new("http://127.0.0.1
|
153
|
+
r = RDaneel.new("http://127.0.0.1:#{port}/redirect_me")
|
154
154
|
r.callback do
|
155
155
|
fail
|
156
156
|
EM.stop
|
157
157
|
end
|
158
158
|
r.errback do
|
159
|
-
r.redirects.should == [
|
159
|
+
r.redirects.should == ["http://127.0.0.1:#{port}/redirect_me"]
|
160
160
|
r.error.should == "Exceeded maximum number of redirects"
|
161
161
|
EM.stop
|
162
162
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,57 +5,66 @@ require 'rdaneel'
|
|
5
5
|
require 'spec'
|
6
6
|
require 'webrick'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
# keep webrick quiet
|
9
|
+
class ::WEBrick::HTTPServer
|
10
|
+
def access_log(config, req, res)
|
11
|
+
# nop
|
11
12
|
end
|
12
|
-
|
13
|
-
|
13
|
+
end
|
14
|
+
class ::WEBrick::BasicLog
|
15
|
+
def log(level, data)
|
16
|
+
# nop
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
|
-
def
|
18
|
-
|
20
|
+
def locked_file
|
21
|
+
File.join(File.dirname(__FILE__),"server_lock-#{@__port}")
|
19
22
|
end
|
20
23
|
|
21
|
-
|
24
|
+
def server_setup(port=8080, &blk)
|
25
|
+
@__port = port
|
26
|
+
if @server.nil? and !File.exist?(locked_file)
|
27
|
+
File.open(locked_file,'w') {|f| f << 'locked' }
|
28
|
+
@server = WEBrick::HTTPServer.new :Port => port
|
29
|
+
blk.call(@server) if blk
|
30
|
+
queue = Queue.new # synchronize the thread startup to the main thread
|
31
|
+
@test_thread = Thread.new { queue << 1; @server.start }
|
22
32
|
|
23
|
-
|
24
|
-
|
25
|
-
webrick_logger = WEBrick::Log.new(webrick_log_file, WEBrick::Log::DEBUG)
|
26
|
-
access_log_stream = webrick_logger
|
27
|
-
access_log = [[ access_log_stream, WEBrick::AccessLog::COMBINED_LOG_FORMAT ]]
|
28
|
-
default_opts = {:Port => 8080, :Logger => webrick_logger, :AccessLog => access_log }
|
29
|
-
@server = WEBrick::HTTPServer.new( default_opts.merge(options) )
|
30
|
-
@server_thread = Thread.new {
|
31
|
-
blk.call(@server) if blk
|
32
|
-
@server.start
|
33
|
-
}
|
34
|
-
@server
|
35
|
-
sleep 0.5
|
36
|
-
end
|
33
|
+
# wait for the queue
|
34
|
+
value = queue.pop
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
lambda { |req, resp|
|
43
|
-
resp.status = opts[:status]
|
44
|
-
resp.body = opts[:body] unless opts[:body].nil?
|
45
|
-
resp['Location'] = opts[:location] unless opts[:location].nil?
|
46
|
-
opts[:block].call unless opts[:block].nil?
|
47
|
-
} )
|
48
|
-
end
|
36
|
+
if !value
|
37
|
+
STDERR.puts "Failed to startup test server!"
|
38
|
+
exit(1)
|
39
|
+
end
|
49
40
|
|
50
|
-
|
51
|
-
|
52
|
-
@server_thread.join
|
41
|
+
trap("INT"){server_shutdown}
|
42
|
+
at_exit{server_shutdown}
|
53
43
|
end
|
44
|
+
end
|
54
45
|
|
55
|
-
|
56
|
-
|
46
|
+
def server_shutdown
|
47
|
+
begin
|
48
|
+
if File.exist?(locked_file)
|
49
|
+
File.unlink locked_file
|
50
|
+
@server.shutdown unless @server.nil?
|
51
|
+
@server = nil
|
52
|
+
end
|
53
|
+
rescue Object => e
|
54
|
+
puts "Error #{__FILE__}:#{__LINE__}\n#{e.message}"
|
57
55
|
end
|
56
|
+
end
|
58
57
|
|
58
|
+
def mount(server, opts)
|
59
|
+
raise ":path is required" if opts[:path].nil?
|
60
|
+
raise ":status is required" if opts[:status].nil?
|
61
|
+
server.mount_proc( opts[:path],
|
62
|
+
lambda { |req, resp|
|
63
|
+
resp.status = opts[:status]
|
64
|
+
resp.body = opts[:body] unless opts[:body].nil?
|
65
|
+
resp['Location'] = opts[:location] unless opts[:location].nil?
|
66
|
+
opts[:block].call unless opts[:block].nil?
|
67
|
+
} )
|
59
68
|
end
|
60
69
|
|
61
70
|
def should_not_be_hit
|
@@ -76,3 +85,9 @@ def should_be_hit( times = 1 )
|
|
76
85
|
return l
|
77
86
|
end
|
78
87
|
|
88
|
+
Spec::Runner.configure do |config|
|
89
|
+
config.before :suite do
|
90
|
+
puts "\e[4mThese specs could take a while, please be patience\e[0m"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "RDaneel when the content is chunked (digg.com)" do
|
4
|
+
|
5
|
+
# digg.com uses chunked encoding
|
6
|
+
# http://www.digg.com is redirected to http://digg.com
|
7
|
+
|
8
|
+
describe "when the url is not redirected" do
|
9
|
+
|
10
|
+
it "should get the content" do
|
11
|
+
EM.run do
|
12
|
+
r = RDaneel.new("http://digg.com")
|
13
|
+
r.callback do
|
14
|
+
r.http_client.response_header.status.should == 200
|
15
|
+
r.http_client.response.should_not be_empty
|
16
|
+
r.redirects.should be_empty
|
17
|
+
EM.stop
|
18
|
+
end
|
19
|
+
r.errback do
|
20
|
+
fail
|
21
|
+
EM.stop
|
22
|
+
end
|
23
|
+
r.get
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "when the url is redirected" do
|
30
|
+
it "should get the content" do
|
31
|
+
EM.run do
|
32
|
+
r = RDaneel.new("http://bit.ly:80/aquXKU")
|
33
|
+
r.callback do
|
34
|
+
r.http_client.response_header.status.should == 200
|
35
|
+
r.http_client.response.should_not be_empty
|
36
|
+
r.redirects.should == ['http://bit.ly:80/aquXKU']
|
37
|
+
r.uri.to_s.should == "http://www.relevancesells.com:80/2010/03/12/the-1st-7-seconds-rule-for-an-elevator-pitch/"
|
38
|
+
EM.stop
|
39
|
+
end
|
40
|
+
r.errback do
|
41
|
+
puts "Error: #{r.error}"
|
42
|
+
fail
|
43
|
+
EM.stop
|
44
|
+
end
|
45
|
+
r.get(:redirects => 3)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
data/spec/using_cache_spec.rb
CHANGED
@@ -2,34 +2,36 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "RDaneel when there is a cache" do
|
4
4
|
|
5
|
+
let(:port) {8082}
|
6
|
+
|
5
7
|
describe "when there is no robots.txt in the host" do
|
6
8
|
|
7
9
|
before(:each) do
|
8
10
|
RDaneel.robots_cache = {}
|
9
|
-
|
11
|
+
server_setup(port) do |server|
|
12
|
+
mount(server, :path => '/robots.txt', :status => 404,
|
10
13
|
:block => should_be_hit_once )
|
11
|
-
|
12
|
-
:location =>
|
14
|
+
mount(server, :path => '/redirect_me', :status => 301,
|
15
|
+
:location => "http://127.0.0.1:#{port}/hello_world",
|
13
16
|
:block => should_be_hit_once )
|
14
|
-
|
17
|
+
mount(server, :path => '/hello_world', :status => 200,
|
15
18
|
:body => 'Hello World!',
|
16
19
|
:block => should_be_hit_once )
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
after(:each) do
|
20
|
-
|
21
|
-
burrito.unmount('/redirect_me')
|
22
|
-
burrito.unmount('/hello_world')
|
24
|
+
server_shutdown
|
23
25
|
end
|
24
26
|
|
25
27
|
it "should try to get the robots.txt just once" do
|
26
28
|
EM.run do
|
27
|
-
r = RDaneel.new("http://127.0.0.1
|
29
|
+
r = RDaneel.new("http://127.0.0.1:#{port}/redirect_me")
|
28
30
|
r.callback do
|
29
31
|
r.http_client.response_header.status.should == 200
|
30
32
|
r.http_client.response.should == "Hello World!"
|
31
|
-
r.redirects.should == [ "http://127.0.0.1
|
32
|
-
r.uri.to_s.should == "http://127.0.0.1
|
33
|
+
r.redirects.should == [ "http://127.0.0.1:#{port}/redirect_me"]
|
34
|
+
r.uri.to_s.should == "http://127.0.0.1:#{port}/hello_world"
|
33
35
|
EM.stop
|
34
36
|
end
|
35
37
|
r.errback do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Edgar Gonzalez
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-08-13 00:00:00 -04:30
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- spec/redirects_without_robots_spec.rb
|
84
84
|
- spec/spec.opts
|
85
85
|
- spec/spec_helper.rb
|
86
|
+
- spec/streamed_content_spec.rb
|
86
87
|
- spec/using_cache_spec.rb
|
87
88
|
has_rdoc: true
|
88
89
|
homepage: http://github.com/hasmanydevelopers/RDaneel
|
@@ -119,3 +120,4 @@ test_files:
|
|
119
120
|
- spec/no_redirects_neither_robots_spec.rb
|
120
121
|
- spec/spec_helper.rb
|
121
122
|
- spec/redirects_without_robots_spec.rb
|
123
|
+
- spec/streamed_content_spec.rb
|