Module: ApplicationFixtureHelper

Defined in:
lib/package_protections/rspec/application_fixture_helper.rb

Instance Method Summary collapse

Instance Method Details

#delete_app_file(path) ⇒ Object



41
42
43
# File 'lib/package_protections/rspec/application_fixture_helper.rb', line 41

def delete_app_file(path)
  File.delete(path)
end

#write_file(path, content = '') ⇒ Object



7
8
9
10
11
12
# File 'lib/package_protections/rspec/application_fixture_helper.rb', line 7

def write_file(path, content = '')
  pathname = Pathname.new(path)
  FileUtils.mkdir_p(pathname.dirname)
  pathname.write(content)
  path
end

#write_package_yml(pack_name, dependencies: [], enforce_dependencies: true, enforce_privacy: true, protections: {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/package_protections/rspec/application_fixture_helper.rb', line 14

def write_package_yml(
  pack_name,
  dependencies: [],
  enforce_dependencies: true,
  enforce_privacy: true,
  protections: {}
)
  defaults = {
    'prevent_this_package_from_violating_its_stated_dependencies' => 'fail_on_new',
    'prevent_other_packages_from_using_this_packages_internals' => 'fail_on_new',
    'prevent_this_package_from_exposing_an_untyped_api' => 'fail_on_new',
    'prevent_this_package_from_creating_other_namespaces' => 'fail_on_new',
    'prevent_this_package_from_exposing_instance_method_public_apis' => 'fail_never'
  }
  protections_with_defaults = defaults.merge(protections)
   = { 'protections' => protections_with_defaults }
  package = ParsePackwerk::Package.new(
    name: pack_name,
    dependencies: dependencies,
    enforce_dependencies: enforce_dependencies,
    enforce_privacy: enforce_privacy,
    metadata: 
  )

  ParsePackwerk.write_package_yml!(package)
end