Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rake task for upgrading Jasmine specs from 1.3 to 2.0.
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
@shakerlxxv

This comment has been minimized.

Copy link

shakerlxxv commented Feb 28, 2014

Excellent! I didn't actually use it as a rake task, but just the collected summary of api changes was great. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.