Module: PGSpecHelper::TrackChanges

Included in:
PGSpecHelper
Defined in:
lib/pg_spec_helper/track_changes.rb

Defined Under Namespace

Classes: UntrackableMethodNameError

Constant Summary collapse

TRACKED_METHOD_CALLS =

this is a list of methods that have their useage tracked, this is used to determine what actions need to be taken when calling reset! between tests

[
  :create_schema,
  :delete_all_schemas,
  :create_table,
  :delete_tables,
  :create_column,
  :create_foreign_key,
  :create_index,
  :create_primary_key,
  :create_unique_constraint,
  :create_validation,
  :create_function,
  :create_trigger,
  :create_enum
]

Instance Method Summary collapse

Instance Method Details

#has_changes?(method_name = nil) ⇒ Boolean

returns true if any changes have been made to the database structure optionally pass in a method name to check if that specific method was used

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
# File 'lib/pg_spec_helper/track_changes.rb', line 29

def has_changes? method_name = nil
  if method_name.nil?
    methods_used.keys.count > 0
  else
    assert_trackable_method_name! method_name
    methods_used[method_name] || false
  end
end