Uncomment default RSpec config

Public
Uncomment default RSpec Rails config
Icons/chart bar
Used 58 times
Created by
F Fajarullah

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/XnJspa"
Template Source

Review the code before running this template on your machine.

def edit_file(path)
  File.write(path, yield(File.read(path)))
end

edit_file("./spec/spec_helper.rb") do |content|
  # delete block comment wrapper
  content["=begin"] = ""
  content["=end"] = ""
  # commenting the unnecessary config
  content.sub!(/(?=config.profile_examples = 10)/, "# ")
  content.sub!(/(?=config.order = :random)/, "# ")
  content.sub!(/(?=Kernel.srand config.seed)/, "# ")
  content
end
Comments

Sign up or Login to leave a comment.