rspec/rspec-core — pull request #1289 by myronmarston (2014-02-05 08:30:51+00:00)
Title: WIP: Fix for #1280

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 25d6b3a8, 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