opened
xmik
username_0
I added a new command line option: `--fail-no-examples`. It defaults to false, so default behavior is not changed. But, if this option is set and there are no RSpec examples to be run, exit status will be 1 (so far it was always 0).

### Motivation
We use RSpec rake task on CI. Having updated RSpec from 3.3.0 to 3.5.0, there was some change in that rake task code. Without changing anything, the rake task resulted in running 0 examples and exit status was 0. Jobs were passed on CI, but I'd prefer if they were not.
Add --fail-no-examples option: fail if no RSpec examples
issue
created
myronmarston
username_1
Was there a regression in our rake task?  If so, it'd be good for us to know about it so we can fix it.

Anyhow, if we're going to add this, I think it would be better to add it to `RSpec::Core::Configuration` (so it can be set via `RSpec.configure`) rather than adding it as a CLI option.  We intentionally limit what config options are exposed via the CLI.  If we exposed everything, `rspec --help` would be an overwhelming wall of text.  We just want options that are the main ones users commonly want to run differently in a one-off manner.  This sounds like an option that you'd want to permanently set for your CI environment, not something for a one-off run.  If we added it to `RSpec.configure`, you could set it in your CI environment like so:

``` ruby
# spec/spec_helper.rb
RSpec.configure do |c|
  if ENV['CI']
    c.fail_if_no_examples = true
  end
end
```

```
# .rspec
--require spec_helper
```

(The latter is necessary to ensure `spec_helper.rb` is always loaded. Simply requiring it from spec files won't help if no spec files are loaded!)

Thoughts?
comment
created
xmik
username_0
Yes, you are right, I want to set this option permanently and setting it by `RSpec::Core::Configuration` is enough. I'm going to rebase this PR so that there is no CLI option, only `RSpec::Core::Configuration` one.

As it comes for rake task potential regression, I opened an issue: https://github.com/rspec/rspec-core/issues/2303 .
comment
created
xmik
username_0
I've just rebased this PR. The option is named: `fail_if_no_examples` (as @username_1 wrote in usage example) and added better tests, but let me know if not enough. I tried to test exit status in unit tests, but it always resulted in ruby errors (my fault), so I left exit status tested only in integration tests (cucumber).

And thanks for that comment on `.rspec` file, I understood that later.
comment
created
xmik
username_0
I updated the PR with your remarks.
comment
created
myronmarston
username_1
@username_0 this is looking really close and is very well done!
comment
created
xmik
username_0
Thanks @username_1 and @username_2 for all the remarks. I incorporated them. It's nice to see that you care for RSpec and keep the code clean. Let me know if you want me to squash commits or correct something else.
comment
created
myronmarston
username_1
Please do squash it, then I'll gladly merge it :).
comment
created
xmik
username_0
` s/if there are 0 examples/if there are no examples/` incorporated and commits squashed.
comment
created
JonRowe
username_2
Thanks @username_0
comment