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

[help] How can I fail CI early if any examples are focused? #1747

Closed
mikegee opened this issue Oct 23, 2014 · 5 comments
Closed

[help] How can I fail CI early if any examples are focused? #1747

mikegee opened this issue Oct 23, 2014 · 5 comments

Comments

@mikegee
Copy link

mikegee commented Oct 23, 2014

My spec_helper has the standard:

RSpec.configure do |config|
  config.filter_run focus: true
  config.run_all_when_everything_filtered = true
end

That's great for while I'm working on something, but I want my CI build to fail if I accidentally commit a focused spec.

(also asked here: https://stackoverflow.com/questions/26536694/examine-rspec-examples-without-running-them)

@myronmarston
Copy link
Member

RSpec.configure do |config|
  if ENV['CI']
    config.before(:example, :focus) { raise "Should not commit focused specs" }
  else
    config.filter_run focus: true
    config.run_all_when_everything_filtered = true
  end
end

Most CI services (such as travis) set a CI environment variable, or you could set it yourself in your CI build script.

@mikegee
Copy link
Author

mikegee commented Oct 24, 2014

Thanks!

@myronmarston
Copy link
Member

Actually, I wonder if our generated spec_helper.rb should do that automatically.

What do others think?

/cc @rspec/rspec

@waterlink
Copy link
Contributor

Looks useful. And of course with appropriate comment before this if block
(stating about travis CI env variable and not recommending committing
:focus-ed specs).

Best Regards,
Alexey Fedorov,
Sr Ruby Developer, Clojure Developer,
+49 15757 486 476

2014-10-24 2:27 GMT+02:00 Myron Marston notifications@github.com:

Actually, I wonder if our generated spec_helper.rb should do that
automatically.

What do others think?

/cc @rspec/rspec https://github.com/orgs/rspec/teams/rspec


Reply to this email directly or view it on GitHub
#1747 (comment).

@cupakromer
Copy link
Member

@myronmarston I'm not for making this automatic. I feel like it's a bit too specific. Also, there are times I am working on a feature branch and I do not want CI to run the full suite yet, but I do want it to run my focus specs for the entire build matrix.

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

No branches or pull requests

4 participants