-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update packs to read from configuration of automatic_namespaces gem (#…
…214) * add failing test for automatic namespaces * add comment * initial implementation * make test pass * bump version * readme updates
- Loading branch information
1 parent
98349c9
commit 4b8fcb3
Showing
12 changed files
with
223 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use assert_cmd::prelude::*; | ||
use predicates::prelude::*; | ||
use std::{error::Error, process::Command}; | ||
mod common; | ||
|
||
#[test] | ||
fn test_automatic_namespaces_with_zeitwerk_parser() -> Result<(), Box<dyn Error>> | ||
{ | ||
Command::cargo_bin("packs")? | ||
.arg("--project-root") | ||
.arg("tests/fixtures/app_with_automatic_namespaces") | ||
.arg("--debug") | ||
.arg("list-definitions") | ||
.assert() | ||
.success() | ||
.stdout(predicate::str::contains( | ||
"\"::FooRecord\" is defined at \"packs/foo/app/models/foo_record.rb\"" | ||
)) | ||
.stdout(predicate::str::contains( | ||
"\"::Foo::Creator\" is defined at \"packs/foo/app/services/creator.rb\"" | ||
)); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_automatic_namespaces_with_experimental_parser( | ||
) -> Result<(), Box<dyn Error>> { | ||
Command::cargo_bin("packs")? | ||
.arg("--project-root") | ||
.arg("tests/fixtures/app_with_automatic_namespaces") | ||
.arg("--debug") | ||
// Experimental parser works without issues | ||
.arg("--experimental-parser") | ||
.arg("list-definitions") | ||
.assert() | ||
.success() | ||
.stdout(predicate::str::contains( | ||
"\"::FooRecord\" is defined at \"packs/foo/app/models/foo_record.rb\"" | ||
)) | ||
.stdout(predicate::str::contains( | ||
"\"::Foo::Creator\" is defined at \"packs/foo/app/services/creator.rb\"" | ||
)); | ||
Ok(()) | ||
} |
1 change: 1 addition & 0 deletions
1
tests/fixtures/app_with_automatic_namespaces/node_modules/file.rb
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions
6
tests/fixtures/app_with_automatic_namespaces/packs/foo/app/models/foo_record.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class FooRecord | ||
sig { returns(String) } | ||
def self.other_method | ||
"other_method" | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
tests/fixtures/app_with_automatic_namespaces/packs/foo/app/services/creator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Foo | ||
class Creator | ||
sig { returns(String) } | ||
def self.build_foo | ||
"foo" | ||
end | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/app_with_automatic_namespaces/packs/foo/package.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enforce_dependencies: true | ||
enforce_privacy: true | ||
metadata: | ||
automatic_pack_namespace: true | ||
automatic_pack_namespace_exclusions: | ||
- app/models # Exclude models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# See: Setting up the configuration file | ||
# https://github.com/Shopify/packwerk/blob/main/USAGE.md#setting-up-the-configuration-file | ||
|
||
# List of patterns for folder paths to include | ||
# include: | ||
# - "**/*.{rb,rake,erb}" | ||
|
||
# List of patterns for folder paths to exclude | ||
exclude: | ||
- "{rubydir_stub,gemdir_stub}/**/*" | ||
|
||
# Patterns to find package configuration files | ||
# package_paths: "**/" | ||
|
||
# List of custom associations, if any | ||
# custom_associations: | ||
# - "cache_belongs_to" | ||
|
||
# Whether or not you want the cache enabled (disabled by default) | ||
cache: false | ||
# Where you want the cache to be stored (default below) | ||
# cache_directory: 'tmp/cache/packwerk' |