Created
February 14, 2014 15:05
-
-
Save ilyazub/9002586 to your computer and use it in GitHub Desktop.
Rake task for upgrading Jasmine specs from 1.3 to 2.0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Upgrade Jasmine specs to 2.0 syntax" | |
namespace :jasmine do | |
task :upgrade_specs do | |
Dir.glob('spec/javascripts/units/**/*_spec.js.coffee') do |filename| | |
specs = File.read(filename) | |
specs = specs.gsub('.andReturn', '.and.returnValue') | |
specs = specs.gsub('.andCallFake', '.and.callFake') | |
specs = specs.gsub('.andCallThrough', '.and.callThrough') | |
specs = specs.gsub('.mostRecentCall', '.calls.mostRecent()') | |
specs = specs.gsub('.callCount', '.calls.count()') | |
specs = specs.gsub('.calls.length', '.calls.count()') | |
specs = specs.gsub('.Clock.useMock()', '.clock().install()') | |
specs = specs.gsub('.Clock', '.clock()') | |
specs = specs.gsub('.clock().uninstallMock()', '.clock().uninstall()') | |
File.open(filename, 'w') { |io| io.puts(specs) } | |
puts "#{filename} upgraded" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent! I didn't actually use it as a rake task, but just the collected summary of api changes was great. Thank you!