Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Fix for #1280 #1289

Merged
merged 3 commits into from
Feb 6, 2014
Merged

Fix for #1280 #1289

merged 3 commits into from
Feb 6, 2014

Conversation

myronmarston
Copy link
Member

This is the start of a fix for #1280. So far I've only gotten as far as a test exposing the issue.

The "easy" fix for this is to reorder things so that the files_to_run are resolved before requires are processed. However, that would break the fix @JonRowe put in place in 25d6b3a, which allows pattern to be set in an RSpec.configure block if you use a CLI option to require your spec helper. pattern can affect files_to_run so the change he made makes sense. I'm not sure what the best fix is. A few ideas:

  • Change things so that files_to_run, rather than being assigned at a particular point in time, is lazily computed on first access. If the user sets pattern before accessing files_to_run it would take the pattern into account but otherwise it wouldn't. This might require a large amount of refactoring.
  • Provide a separate predicate method like config.running_one_spec_file? that is set to true if and only if a single file name has been passed at the command line. I think this can be computed apart from the pattern so it could happen earlier.

@JonRowe, what are your thoughts, since you've worked in this area before?

I'm interested in everyone's feedback, though.

/cc @xaviershay @alindeman @soulcutter @samphippen

@JonRowe
Copy link
Member

JonRowe commented Feb 5, 2014

I think I'd prefer they be lazily compiled, to give people the most chance to set things like pattern, but it will lead to some confusing behaviour (e.g. if you check theres only one file before setting pattern)

It's easiest to leverage the same "order then set configs"
logic of `process_options_into` rather than treating
libs and requires as special.
The old way was odd. It created an ordering dependency
(you had to call `parse_options` after instantiating the
object but before doing anything else) and calling it a second
time had the side effect of re-parsing the args, which wasn't
needed or intended.

It's far easier/better to make `options` do the parsing
and memoize the result.
…a `-r`.

This changes it to be lazily rather than eagerly computed.
This is important to allow `pattern` to be set from a `spec_helper`
file loaded via `-r`.
@myronmarston
Copy link
Member Author

I went with the lazy solution. Can you review this, @JonRowe?

And I create a spec file with the following content:
"""
And I create "spec/addition_spec.rb" with the following content:
"""ruby
Copy link
Member

Choose a reason for hiding this comment

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

An aside, is this for relish?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean the """ruby bit? Yes, that's for relish -- it tells it what kind of text it is, so it can apply syntax highlighting.

@JonRowe
Copy link
Member

JonRowe commented Feb 6, 2014

Looks good to me, and surprisingly simple...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants