Module: Pangea::Testing::SpecSetup

Defined in:
lib/pangea/testing/spec_setup.rb

Overview

Shared RSpec configuration for all Pangea gems. Call Pangea::Testing::SpecSetup.configure! in your spec_helper.rb to get consistent test infrastructure across all provider gems.

Class Method Summary collapse

Class Method Details

.configure!(indifferent: false) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pangea/testing/spec_setup.rb', line 26

def self.configure!(indifferent: false)
  # Patch TerraformSynthesizer for indifferent key access if requested
  if indifferent && defined?(TerraformSynthesizer)
    TerraformSynthesizer.class_eval do
      alias_method :_original_synthesis, :synthesis unless method_defined?(:_original_synthesis)

      define_method(:synthesis) do
        Pangea::Testing::IndifferentHash.deep_convert(_original_synthesis)
      end
    end
  end

  # Load shared examples (type purity, resource patterns)
  require_relative 'type_purity'
  require_relative 'resource_examples'

  RSpec.configure do |config|
    config.example_status_persistence_file_path = '.rspec_status'
    config.disable_monkey_patching!
    config.expect_with :rspec do |c|
      c.syntax = :expect
    end
    config.include Pangea::Testing::SynthesisTestHelpers
    config.before(:suite) { ENV['PANGEA_ENV'] = 'test' }
    config.formatter = :progress
    config.color = true
    config.filter_run_when_matching :focus
    config.run_all_when_everything_filtered = true
    config.order = :random
    Kernel.srand config.seed
    config.warnings = false
  end
end