Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: explain dir and tag name conflict; #535

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/guides/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ it "is slow", tags: "slow" do
true.should be(true)
end

# can be ran using --tag="fast"
it "is fast", tags: "fast" do
true.should be(true)
end
Expand All @@ -146,6 +147,9 @@ Tagging an example group (`describe` or `context`) extends to all of the contain

Multiple tags can be specified by giving an [`Enumerable`](https://crystal-lang.org/api/latest/Enumerable.html), such as [`Array`](https://crystal-lang.org/api/latest/Array.html) or [`Set`](https://crystal-lang.org/api/latest/Set.html).

Be sure to use `--tag="my-tag"` syntax when there is a directory name that matches your tag name in your project or else they will be parsed as directories instead of tag filters. For example, if you have some tests that run in a Terraform environment and you have put all of your terraform scripts in `terraform/example.tf` and have also tagged some tests as `tags: "terraform"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think "Terraform" has enough relevance here to be used without any introduction

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review.

I often find concrete examples useful in docs when dealing with corner cases, but i can definitely clean it up when I'm back from vacation.

Unless it is decided this behavior is actually a crystal bug we should fix.

you should pass `--tag="terraform"` to use that tag.

## Running specs

The Crystal compiler has a `spec` command with tools to constrain which examples get run and tailor the output. All specs of a project are compiled and executed through the command `crystal spec`.
Expand Down Expand Up @@ -183,10 +187,10 @@ crystal spec spec/my/test/file_spec.cr
crystal spec spec/my/test/file_spec.cr:14

# Run all specs tagged with "fast"
crystal spec --tag 'fast'
crystal spec --tag='fast'

# Run all specs not tagged with "slow"
crystal spec --tag '~slow'
crystal spec --tag='~slow'
```

## Spec helper
Expand Down