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

Enforce spec file names have _spec.rb suffix #108

Open
eliotsykes opened this issue Dec 30, 2015 · 0 comments
Open

Enforce spec file names have _spec.rb suffix #108

eliotsykes opened this issue Dec 30, 2015 · 0 comments

Comments

@eliotsykes
Copy link
Owner

Specs without _spec.rb suffix will not be run by bare bin/rspec (no path)

# spec/support/spec_file_name_enforcer.rb
RSpec.configure do |config|
  config.before(:suite) do

    files_without_spec_suffix = Dir.glob('spec/**/*').select do |filename|
      File.file?(filename) && 
        !filename.match(/_spec\.rb\z/) &&
        !filename.match(%r{\Aspec/(support|factories|mailers/previews)/}) &&
        !filename.match(%r{\Aspec/(spec_helper\.rb|rails_helper\.rb|examples\.txt)\z})
    end

    if files_without_spec_suffix.any?
      raise 'Spec files need _spec.rb suffix: ' + files_without_spec_suffix.join(', ')
    end
  end
end
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

1 participant