Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. file_names = Dir['./spec/**/*.rb'] # Get all the ruby files
  2.  
  3. file_names.each do |file_name|
  4. next if ['./spec/spec_helper.rb', './spec/rails_helper.rb'].include? file_name
  5.  
  6. text = File.read(file_name)
  7. next if text.include?('RSpec.describe')
  8.  
  9. new_contents = text.sub(/describe/, 'RSpec.describe')
  10.  
  11. # To write changes to the file, use:
  12. File.open(file_name, 'w') { |file| file.puts new_contents }
  13. puts 'Fixed' + file_name
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement