Skip to content

Instantly share code, notes, and snippets.

@jakehawken
Last active June 1, 2016 17:08
Show Gist options
  • Save jakehawken/e428a0a41681e881f917f7504447c6b5 to your computer and use it in GitHub Desktop.
Save jakehawken/e428a0a41681e881f917f7504447c6b5 to your computer and use it in GitHub Desktop.
Ruby script for removing focused tests, describes, and contexts in the Cedar testing framework
desc 'remove focused tests'
task :nof do
testFiles = Dir.glob("YourProjectTests/**/*.mm")
testFiles.each do |file|
newRows = []
File.open(file, 'r').each do |line|
newRows << line.gsub('fit(', 'it(').gsub('fdescribe(', 'describe(').gsub('fcontext(', 'context(')
end
contentOfArray = newRows.join
File.open(file, 'w').write contentOfArray
end
print("All tests, describes, and contexts have been unfocused.\n")
end
@JustinAiken
Copy link

A little more Rubish:

task :nof do
  Dir.glob("YourProjectTests/**/*.mm").each do |file|
    newRows = []
    File.open(file, 'r').each do |line|
      newRows << line.gsub('fit(', 'it(').gsub('fdescribe(', 'describe(').gsub('fcontext(', 'context(')
    end
    File.open(file, 'w').write newRows.join
  end
  puts "All tests, describes, and contexts have been unfocused."
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment