forked from aaronpk/webmention.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
53 lines (45 loc) · 1.38 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def init(env=ENV['RACK_ENV']); end
require File.join('.', 'environment.rb')
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = ENV['TEST_PATTERN'] || "test/**/*_spec.rb"
end
task :default => :test
namespace :db do
task :bootstrap do
init
DataMapper.auto_migrate!
Account.create :username => 'pingback'
end
task :migrate do
init
DataMapper.auto_upgrade!
end
end
namespace :test do
def pingback_client
XMLRPC::Client.new "localhost", "/test/xmlrpc", 9019
end
task :sample1 do
source_uri = "http://techslides.com/tumblr-api-example-using-oauth-and-php/?id=" + rand(100).to_s
target_uri = "http://oauth.net/code/"
c = pingback_client
c.call('pingback.ping', source_uri, target_uri)
end
# Generate the JSON response that XRay sends for the test data
task :generate_stubs do
Dir.glob(File.join File.expand_path(File.dirname(__FILE__)), 'test/data/*/*').each {|f|
if File.file? f
host = /data\/([^\/]+)/.match(f)[1]
path = /data\/[^\/]+(\/.+)/.match(f)[1]
url = "http://#{host}#{path}"
if host != "xray.test"
puts url
Dir.mkdir "test/data/xray.test/#{host}" unless File.exists? "test/data/xray.test/#{host}"
result = {:data => XRay.parse(url, nil, IO.read(f))}
IO.write "test/data/xray.test/#{host}#{path}", result.to_json
end
end
}
end
end