Skip to content

Instantly share code, notes, and snippets.

@apeckham
Created May 30, 2010 19:00
Show Gist options
  • Save apeckham/419231 to your computer and use it in GitHub Desktop.
Save apeckham/419231 to your computer and use it in GitHub Desktop.
rake task to create jasmine fixtures from HTML files
namespace :jasmine do
task :fixtures do
blobs = {}
Dir.glob("spec/javascripts/fixtures/*.html").each do |file|
blobs[File.basename(file, ".html")] = File.read(file)
end
File.open("spec/javascripts/helpers/fixtures.js", "w") do |file|
file << <<END
var Fixtures = {
load: function(name) {
$("jasmine_content").update(Fixtures.data[name]);
},
reset: function() {
$("jasmine_content").update();
},
data: #{blobs.to_json}
};
END
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment