postspec 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac68d61de369fe3aced2e4b6a2dfebc1e9d293c879854f3e094755357bde7a63
4
- data.tar.gz: d0bb3d0e90935bd47d080aee31572a3a04b91937de6d4879ce2e3150754d3a0c
3
+ metadata.gz: d9e60d04517c544252ab66c95f0b5d19a5e8fa303673d0252ac4e47f3303d719
4
+ data.tar.gz: 69555a09052ceebd4046dda3e7dda73446c1272dcbc59f3d2cc6080b99e9cc6e
5
5
  SHA512:
6
- metadata.gz: f42c180b14d7574c8f85223a1b50d7169b05a2a459cf44ba739e7d1cea4f320d17b983800e20acb995ea6dd21220490f97e36e732bba72371689e964c0b8e067
7
- data.tar.gz: 21226245ef6d07cd076585b550ac2f5d820d82372430415934b63ad97f83a7f010e45243190b6172bc75831dd5c8b2ed836ed15feaec96a7e9230bb9a71249cc
6
+ metadata.gz: d79159dd929c7402275367e5c3e03229576e88813f72ac4319213b96683dc8c3195cd6c97fe05ddafed5c12234f177d9208c0eec578a9ab875b03e9c5a3ed1e7
7
+ data.tar.gz: 51e5c7f1368122938d304c8c26e7bfd5b87e733622c404285b60a70df267210875199dcd5f65121357aba19ca85e2969574be0f370c486e90b6efd9ed9c68f7c
@@ -47,14 +47,17 @@ module Postspec
47
47
  when :create; create_seed_triggers(uids)
48
48
  when :drop; drop_seed_triggers
49
49
  else
50
- raise ArgumentError
50
+ raise ArgumentError, state.inspect
51
51
  end
52
52
  end
53
53
 
54
54
  def drop_seed_triggers
55
+ p "DROP"
55
56
  postspec.tables.map { |uid|
57
+ p "BING"
56
58
  [SEED_BUD_TRIGGER_NAME, SEED_BT_TRIGGER_NAME].map { |trigger|
57
59
  trigger_uid = "#{uid}.#{trigger}()"
60
+ p trigger_uid
58
61
  postspec.meta.exist?(trigger_uid) ? "drop trigger #{trigger} on #{uid}" : nil
59
62
  }.compact
60
63
  }.flatten
@@ -65,7 +68,7 @@ module Postspec
65
68
  # the common postspec.readonly_failure() function that raises a Postgres
66
69
  # exception
67
70
  def create_seed_triggers(uids)
68
- constrain uids, String => [Integer, NilClass]
71
+ constrain uids, { String => [Integer, NilClass] }
69
72
  result = []
70
73
  uids.map { |uid, id|
71
74
  bud_trigger = "#{uid}.#{SEED_BUD_TRIGGER_NAME}()"
@@ -74,14 +77,18 @@ module Postspec
74
77
  before update or delete on #{uid}
75
78
  for each row
76
79
  when (old.id <= #{id})
77
- execute function postspec.readonly_failure('#{uid}')
80
+ execute function postspec_readonly_failure('#{uid}')
78
81
  EOS1
79
82
  bt_sql = <<~EOS2
80
- create trigger postspec_readonly_trigger_bt
83
+ create trigger postspec_readonly_bt_trg
81
84
  before truncate on #{uid}
82
- execute function postspec.readonly_failure('#{uid}')
85
+ execute function postspec_readonly_failure('#{uid}')
83
86
  EOS2
84
- [bud_sql, bt_sql, "insert into postspec.seeds (table_uid, record_id) values ('#{uid}', #{id})"]
87
+ [
88
+ bud_sql.chomp,
89
+ bt_sql.chomp,
90
+ "insert into postspec.seeds (table_uid, record_id) values ('#{uid}', #{id})"
91
+ ]
85
92
  }.flatten
86
93
  end
87
94
 
@@ -1,3 +1,3 @@
1
1
  module Postspec
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -32,30 +32,27 @@ RSpec.configure do |config|
32
32
  end
33
33
 
34
34
  config.around(:example) do |example|
35
- # puts "postspec_helper around example"
36
35
  if postspec.failed?
37
36
  example.skip
38
37
  else
39
38
  postspec.conn.push_transaction
40
39
  begin
41
- # puts ">> TRYING"
42
40
  result = example.run
43
- # puts ">> RESULT: #{result.inspect} (#{result.class})"
44
- # puts ">> EXAMPLE: #{example.exception.inspect} (#{example.exception.class})"
45
- # puts ">> EXECUTION_RESULT: #{example.execution_result}"
46
- if result.is_a?(PG::Error)
47
- postspec.fail!
48
- postspec.conn.cancel_transaction
49
- elsif result.is_a?(Exception)
50
- postspec.fail!
51
- postspec.conn.pop_transaction(commit: postspec.failed?)
41
+
42
+ case example.execution_result.exception
43
+ when PG::Error
44
+ # Collapse whole transaction stack
45
+ postspec.fail!
46
+ postspec.conn.cancel_transaction
47
+ when Exception
48
+ # Pops only last transaction
49
+ postspec.fail!
50
+ postspec.conn.pop_transaction(commit: postspec.failed?)
52
51
  else
53
- postspec.conn.pop_transaction(commit: postspec.failed?)
52
+ # Success - pop last transaction
53
+ postspec.conn.pop_transaction(commit: postspec.failed?, fail: false)
54
54
  end
55
- rescue
56
- puts ">> OTHER EXCEPTIONS"
57
- puts ">> OTHER EXCEPTIONS"
58
- puts ">> OTHER EXCEPTIONS"
55
+ rescue => ex # Happens when rspec itself fails
59
56
  postspec.conn.cancel_transaction
60
57
  postspec.fail!
61
58
  raise
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-18 00:00:00.000000000 Z
11
+ date: 2024-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubygems_version: 3.3.18
233
+ rubygems_version: 3.3.7
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: postspec gem