Skip to content

Allow to specify a custom automatic mapping directory -> type#1541

Closed
jalkoby wants to merge 1 commit intorspec:masterfrom
jalkoby:allow_specify_custom_automatic_types
Closed

Allow to specify a custom automatic mapping directory -> type#1541
jalkoby wants to merge 1 commit intorspec:masterfrom
jalkoby:allow_specify_custom_automatic_types

Conversation

@jalkoby
Copy link
Copy Markdown

@jalkoby jalkoby commented Jan 28, 2016

Hi everyone!
I've faced a strange (for me) behaviour of infer_spec_type_from_file_location!. I supposed that it will grep the first sub folder in spec, convert into singular and set that value into type. But after didn't get it in my project and looked into the source code, I found a static set of supported type. Well, it's fine solution too, but it would be useful to extend this set. So my pool request allows to do next:

  config.infer_spec_type_from_file_location!(sidekiq: :workers, export: :exports)
  # or a shorter version
  config.infer_spec_type_from_file_location!([:worker, :export]) # => spec/workers -> :worker, spec/exports -> :export

@yujinakayama
Copy link
Copy Markdown
Member

You can use RSpec::Configuration#define_derived_metadata for the purpose.

@jalkoby
Copy link
Copy Markdown
Author

jalkoby commented Jan 30, 2016

Well, it solves my problem, but lacks the usability. It would be good for the documentation to mention which types are supported by config.infer_spec_type_from_file_location! and add more information about "define_derived_metadata"( + supported options), because for now it's more like a hack in the internals of RSpec

@jalkoby jalkoby closed this Jan 30, 2016
@myronmarston
Copy link
Copy Markdown
Member

Well, it solves my problem, but lacks the usability.

It's not as terse, but define_derived_metadata is much more flexible -- it provides a way to automatically set any metadata, not just spec type.

It would be good for the documentation to mention which types are supported by config.infer_spec_type_from_file_location! and add more information about "define_derived_metadata"( + supported options),

You're right. Want to open a PR improving our documentation?

@JonRowe
Copy link
Copy Markdown
Member

JonRowe commented Jan 31, 2016

It's worth mentioning that config.infer_spec_type_from_file_location! is to support "legacy" spec suites from pre RSpec 3, we recommend people tag their specs manually for clarity...

@jalkoby
Copy link
Copy Markdown
Author

jalkoby commented Jan 31, 2016

@myronmarston worth to do it, as it's a frequent thing in my testing process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants