blob: d698aba8eecb7b95d6993f114378292343a5e3ad (
plain)
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
|
$:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'rspec'
require 'simplecov'
SimpleCov.start
require 'pgxn_utils'
$counter = 0
LIB_PATH = File.expand_path('../../lib', __FILE__)
BIN_PATH = File.expand_path('../../bin/pgxn-utils', __FILE__)
DESTINATION_ROOT = File.expand_path('../pgxn_utils', __FILE__)
FileUtils.rm_rf(DESTINATION_ROOT)
RSpec.configure do |config|
# capture method from https://github.com/wycats/thor/blob/master/spec/spec_helper.rb#L36-47
def capture(stream)
begin
stream = stream.to_s
eval "$#{stream} = StringIO.new"
yield
result = eval("$#{stream}").string
ensure
eval("$#{stream} = #{stream.upcase}")
end
result
end
end
def next_extension
$counter += 1
"extension.#{$counter}"
end
def skeleton(extension_name, args=[])
capture(:stdout) { PgxnUtils::CLI.start([ "skeleton", extension_name ] + args) }
end
def change(extension_name, args=nil)
#run_pgxn_utils(:skeleton, "#{extension_name} #{args}")
end
def run_pgxn_utils(task, args)
#system "#{BIN_PATH} #{task.to_s} #{args}"
end
|