pg_spec_helper 1.2.0 → 1.4.0

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: 49e5716d13c3a2fb075f01e431d9a0eff5993fbb1b1063ea8079a8c98e6bfbfe
4
- data.tar.gz: 02bc59e4925df21164c3d4bfeced975a44c5a651c65f3a51c2eb48985909e8c6
3
+ metadata.gz: 68e7d2fca3250ae565d38d0709b1eb73d212b5e6af6c642702e6345123a55e3a
4
+ data.tar.gz: 9d2340c8d9f285e97ffce51942c359843067c663f0383e0e4a9f752382b91eff
5
5
  SHA512:
6
- metadata.gz: 192264003c26963902a5aab06a29d3e420d9b4b28d59985a7a469ea7c3dd6e45ba01a9d9faa93d060475178e7efaf2afedba2a24eadbd64e0b89627b97dbd0a2
7
- data.tar.gz: 7bd2b7754f23ede028474b19d0d3ab2854c5f7a8a7f18426dc606fceb70ab1a42c969c8657aa23ce40d08c3a75fa66879d6fd5d1efdca462909e9383f4da4c7b
6
+ metadata.gz: d124e944257073e9a37a1c39ef1a50ba64a86adc4f436312af1b69554a6b8ebdf36d0fedb375e89a9a521fc7e23f2c08f23bf80b15cdbe7c90c27e04542fc656
7
+ data.tar.gz: 3cb9e58e2bd59553f94cee19af7f991f14174e8ee51fc8160eb923ebe467e54543a03b9d0895a6f09dd58489763af2b0299dbee3c6e04e8063af28502c17f2f1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.0](https://github.com/craigulliott/pg_spec_helper/compare/v1.3.0...v1.4.0) (2023-07-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * made `refresh_all_materialized_views` available as a public method ([dd88ea0](https://github.com/craigulliott/pg_spec_helper/commit/dd88ea0877ba75f5c78ce5083421dd20090be6cb))
9
+
10
+ ## [1.3.0](https://github.com/craigulliott/pg_spec_helper/compare/v1.2.0...v1.3.0) (2023-07-10)
11
+
12
+
13
+ ### Features
14
+
15
+ * Dont delete the public schema, just remove all the tables instead. This is useful if you have materialized views in the public schema ([9f69160](https://github.com/craigulliott/pg_spec_helper/commit/9f691602bc851fbeea0d01a0f8e9a7555f154e35))
16
+
3
17
  ## [1.2.0](https://github.com/craigulliott/pg_spec_helper/compare/v1.1.0...v1.2.0) (2023-07-10)
4
18
 
5
19
 
data/README.md CHANGED
@@ -28,7 +28,7 @@ This gem is concerned with the **structure** of your database, not the data/reco
28
28
  * Resets your database after each spec, but only if the spec made changes
29
29
  * Ignores `information_schema` and any schemas or tables with names beginning with `pg_`
30
30
  * Configurable to ignore other schemas (such as `postgis`)
31
- * Automatically resets and recreates the `public` schema
31
+ * Deletes tables from within the `public` schema, but does not delete the actual schema during cleanup.
32
32
  * Can track and refresh materialized views
33
33
  * Easily access the `PG::Connection` object via `pg_spec_helper.connection` to execute your own SQL
34
34
 
@@ -52,11 +52,9 @@ And run bundle install
52
52
 
53
53
  Note, this gem depends on the postgres gem `pg`, which depends on the `libpq` package. On Apple Silicon you can run the following commands before installation to prepare your system.
54
54
 
55
- ```
56
55
  # required for pg gem on apple silicon
57
56
  $ brew install libpq
58
57
  $ export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
59
- ```
60
58
 
61
59
  ## Getting Started
62
60
 
@@ -30,6 +30,17 @@ class PGSpecHelper
30
30
  }
31
31
  end
32
32
 
33
+ # refresh all materialized views that have been tracked
34
+ def refresh_all_materialized_views
35
+ @materialized_views&.each do |schema_name, views|
36
+ views.each do |materialized_view_name, view|
37
+ if materialized_view_exists? schema_name, materialized_view_name
38
+ refresh_materialized_view schema_name, materialized_view_name
39
+ end
40
+ end
41
+ end
42
+ end
43
+
33
44
  private
34
45
 
35
46
  # given a trackable method name, refreshes any materialized
@@ -64,17 +75,6 @@ class PGSpecHelper
64
75
  SQL
65
76
  end
66
77
 
67
- # refresh all materialized views that have been tracked
68
- def refresh_all_materialized_views
69
- @materialized_views&.each do |schema_name, views|
70
- views.each do |materialized_view_name, view|
71
- if materialized_view_exists? schema_name, materialized_view_name
72
- refresh_materialized_view schema_name, materialized_view_name
73
- end
74
- end
75
- end
76
- end
77
-
78
78
  # whenever schema changes are made from within the test suite we need to
79
79
  # rebuild the materialized views that hold a cached representation of the
80
80
  # database structure
@@ -26,8 +26,8 @@ class PGSpecHelper
26
26
 
27
27
  # delete all schemas in the database
28
28
  def delete_all_schemas
29
- # delete all schemas
30
- get_schema_names.each do |schema_name|
29
+ # delete all schemas except public
30
+ get_schema_names.reject { |schema_name| schema_name == :public }.each do |schema_name|
31
31
  connection.exec(<<-SQL)
32
32
  -- temporarily set the client_min_messages to WARNING to
33
33
  -- suppress the NOTICE messages about cascading deletes
@@ -36,8 +36,8 @@ class PGSpecHelper
36
36
  SET client_min_messages TO NOTICE;
37
37
  SQL
38
38
  end
39
- # recreate the default `public` schema
40
- create_schema :public
39
+ # delete all the tables from within the public schema
40
+ delete_tables :public
41
41
  end
42
42
 
43
43
  def schema_exists? schema_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PGSpecHelper
4
- VERSION = "1.2.0"
4
+ VERSION = "1.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_spec_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott