Skip to content

Instantly share code, notes, and snippets.

@thegeorgeous
Last active August 11, 2019 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thegeorgeous/8ae7479ae13fc44d085e530c800da1a8 to your computer and use it in GitHub Desktop.
Save thegeorgeous/8ae7479ae13fc44d085e530c800da1a8 to your computer and use it in GitHub Desktop.
Find and Replace describe instances with RSpec.describe so that config.expose_dsl_globally can be set to false
file_names = Dir['./spec/**/*.rb'] # Get all the ruby files in spec
file_names.each do |file_name|
next if ['./spec/spec_helper.rb', './spec/rails_helper.rb'].include? file_name
text = File.read(file_name)
next if text.include?('RSpec.describe')
new_contents = text.sub(/describe/, 'RSpec.describe')
File.open(file_name, 'w') { |file| file.puts new_contents }
puts 'Fixed' + file_name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment