dumbo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dumbo +30 -1
- data/lib/dumbo/rake_task.rb +10 -1
- data/lib/dumbo/test/helper.rb +5 -1
- data/lib/dumbo/test/matchers.rb +37 -2
- data/lib/dumbo/test/regression_helper.rb +2 -0
- data/lib/dumbo/version.rb +1 -1
- data/template/Makefile.erb +7 -1
- metadata +2 -4
- data/spec/support/silence_unknown_oid.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903d02a43533f1f95400a32a0b0f0fdc230b032b
|
4
|
+
data.tar.gz: 2bcf26adc162ab1521515902618fc7759d003e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33dbebf49a41de6a31803291e7153d6aa2ef04251ff46ce0b19c78bee24e703b863eee58f89ebf13e879e8dec28e573da870086cc818651c5ea7665dd410c6df
|
7
|
+
data.tar.gz: adb6de0010e5354250c4c59373827a0b5177516cbbe2f55cdb3e0662a0593b649510752fc2f01d963c825323bfe2e65cd6b1933c2e348c2716d6a07a00cf12da
|
data/bin/dumbo
CHANGED
@@ -6,8 +6,32 @@ require 'fileutils'
|
|
6
6
|
require 'pathname'
|
7
7
|
|
8
8
|
module Cli
|
9
|
+
class Generate < Thor
|
10
|
+
desc 'spec <name>', 'Add a new spec file named <name> as spec/<name>_spec.rb'
|
11
|
+
def spec(name)
|
12
|
+
file_name = "spec/#{name}_spec.rb"
|
13
|
+
if File.exist?(file_name)
|
14
|
+
say_status('already exists', file_name, :yellow)
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
File.open("spec/#{name}_spec.rb", 'w') do |f|
|
19
|
+
f.puts <<-EOF.gsub(' ','')
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
describe '#{name}' do
|
23
|
+
before do
|
24
|
+
install_extension
|
25
|
+
end
|
26
|
+
end
|
27
|
+
EOF
|
28
|
+
end
|
29
|
+
say_status('create', file_name)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
9
33
|
class Dumbo < Thor
|
10
|
-
desc 'new name', 'creates a new extension skeleton'
|
34
|
+
desc 'new <name>', 'creates a new extension skeleton'
|
11
35
|
|
12
36
|
def new(name, initial_version = '0.0.1')
|
13
37
|
mkdir("#{name}/sql")
|
@@ -51,6 +75,11 @@ module Cli
|
|
51
75
|
STR
|
52
76
|
end
|
53
77
|
|
78
|
+
desc "g GENERATOR args", "generates files for the given generator"
|
79
|
+
subcommand "g", Generate
|
80
|
+
|
81
|
+
|
82
|
+
|
54
83
|
no_commands do
|
55
84
|
def mkdir(path, silent_skip = false)
|
56
85
|
if File.directory?(path)
|
data/lib/dumbo/rake_task.rb
CHANGED
@@ -24,7 +24,12 @@ module Dumbo
|
|
24
24
|
|
25
25
|
desc 'installs the extension'
|
26
26
|
task :install do
|
27
|
-
|
27
|
+
cmd = if ENV['DUMBO_USE_SUDO']
|
28
|
+
'make clean && make && sudo make install'
|
29
|
+
else
|
30
|
+
'make clean && make && make install'
|
31
|
+
end
|
32
|
+
system(cmd)
|
28
33
|
end
|
29
34
|
|
30
35
|
desc 'concatenates files'
|
@@ -70,6 +75,10 @@ module Dumbo
|
|
70
75
|
desc 'creates regression tests from specs and runs them'
|
71
76
|
task regression: ['all', 'db:test:prepare'] do
|
72
77
|
ENV['DUMBO_REGRESSION'] = 'true'
|
78
|
+
|
79
|
+
FileUtils.mkdir_p('test/sql/')
|
80
|
+
FileUtils.mkdir_p('test/expected/')
|
81
|
+
|
73
82
|
RSpec::Core::RakeTask.new(:spec).run_task(false)
|
74
83
|
|
75
84
|
if $?.success?
|
data/lib/dumbo/test/helper.rb
CHANGED
@@ -40,7 +40,11 @@ module Dumbo
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def query(sql)
|
43
|
-
|
43
|
+
begin
|
44
|
+
ActiveRecord::Base.connection.select_all(sql, 'SQL', [])
|
45
|
+
rescue ActiveRecord::StatementInvalid => e
|
46
|
+
e
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
def create(table_name, values)
|
data/lib/dumbo/test/matchers.rb
CHANGED
@@ -2,7 +2,7 @@ module Dumbo
|
|
2
2
|
module Matchers
|
3
3
|
|
4
4
|
# test a query result against an expectation
|
5
|
-
#
|
5
|
+
# example
|
6
6
|
# query("SELECT COUNT(*) FROM users").should match '3'
|
7
7
|
# query("SELECT id, name FROM users").should match ['1', 'foo'] ,['2', 'bar'] ,['3', 'baz']
|
8
8
|
# query("SELECT id, name FROM users").should match_with_header ['id', 'name'], ['1', 'foo'] ,['2', 'bar'] ,['3', 'baz']
|
@@ -21,8 +21,42 @@ module Dumbo
|
|
21
21
|
QueryMatcher.new(flat_expected(expected), ordered: true )
|
22
22
|
end
|
23
23
|
|
24
|
+
# test a query result against an error
|
25
|
+
# example
|
26
|
+
# query("SELECT 'foo'::date").should throw_error('ERROR: invalid input syntax for type date: "foo"')
|
27
|
+
|
28
|
+
def throw_error(expected)
|
29
|
+
ErrorMatcher.new(expected)
|
30
|
+
end
|
31
|
+
|
24
32
|
def flat_expected(expected)
|
25
|
-
expected
|
33
|
+
expected = expected.map{|e| e.nil? || e.kind_of?(Array) ? e : e.to_s}
|
34
|
+
expected.size == 1 ? expected.first : expected
|
35
|
+
end
|
36
|
+
|
37
|
+
class ErrorMatcher < RSpec::Matchers::BuiltIn::BaseMatcher
|
38
|
+
attr_reader :actual, :expected, :options, :actual_message
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def match(expected, actual)
|
43
|
+
return false unless is_error?
|
44
|
+
@actual_message = @actual.message.split("\n").first.gsub(/^PG::InternalError: */,'')
|
45
|
+
actual_message.gsub(/^ERROR: */,'') == expected.gsub(/^ERROR: */,'')
|
46
|
+
end
|
47
|
+
|
48
|
+
def is_error?
|
49
|
+
actual.kind_of?(ActiveRecord::StatementInvalid)
|
50
|
+
end
|
51
|
+
|
52
|
+
def failure_message_when_not_error
|
53
|
+
"\nexpected error #{expected} but nothing was raised"
|
54
|
+
end
|
55
|
+
|
56
|
+
def failure_message
|
57
|
+
return "\nexpected error #{expected} but nothing was raised" unless is_error?
|
58
|
+
"expected ERROR: #{expected} got #{actual_message}"
|
59
|
+
end
|
26
60
|
end
|
27
61
|
|
28
62
|
class QueryMatcher < RSpec::Matchers::BuiltIn::ContainExactly
|
@@ -34,6 +68,7 @@ module Dumbo
|
|
34
68
|
end
|
35
69
|
|
36
70
|
def matches?(actual)
|
71
|
+
raise actual if actual.kind_of?(Exception)
|
37
72
|
@actual = actual
|
38
73
|
convert_actual
|
39
74
|
convert_expected
|
data/lib/dumbo/version.rb
CHANGED
data/template/Makefile.erb
CHANGED
@@ -3,4 +3,10 @@ EXTENSION = <%=ext_name%>
|
|
3
3
|
PG_CONFIG ?= pg_config
|
4
4
|
DATA = $(wildcard *--*.sql)
|
5
5
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
6
|
-
|
6
|
+
MODULE_big = <%=ext_name%>
|
7
|
+
OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
|
8
|
+
TESTS = $(wildcard test/sql/*.sql)
|
9
|
+
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
|
10
|
+
REGRESS_OPTS = --inputdir=test --load-language=plpgsql
|
11
|
+
include $(PGXS)
|
12
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dumbo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Kniep
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -179,7 +179,6 @@ files:
|
|
179
179
|
- spec/operator_spec.rb
|
180
180
|
- spec/spec_helper.rb
|
181
181
|
- spec/support/extension_helper.rb
|
182
|
-
- spec/support/silence_unknown_oid.rb
|
183
182
|
- spec/type_spec.rb
|
184
183
|
- template/Gemfile
|
185
184
|
- template/Makefile.erb
|
@@ -228,5 +227,4 @@ test_files:
|
|
228
227
|
- spec/operator_spec.rb
|
229
228
|
- spec/spec_helper.rb
|
230
229
|
- spec/support/extension_helper.rb
|
231
|
-
- spec/support/silence_unknown_oid.rb
|
232
230
|
- spec/type_spec.rb
|