Skip to content

Instantly share code, notes, and snippets.

@JohnRiv
Created June 17, 2014 03:29
Show Gist options
  • Save JohnRiv/63bffffeacbf4dde3833 to your computer and use it in GitHub Desktop.
Save JohnRiv/63bffffeacbf4dde3833 to your computer and use it in GitHub Desktop.
Code Coverage with RequireJS in Teaspoon, using this file and suite.boot_partial = "/boot_requirejs_sync"
<%
rails_config = Rails.application.config
require_options = {baseUrl: rails_config.assets.prefix}
require_options.merge!(rails_config.requirejs.user_config) if rails_config.respond_to?(:requirejs)
specs = @suite.spec_assets(false).map{ |s| "#{s.gsub(/\.js.*$/, "")}" }
require_options['shim'] ||= {}
specs.each {|s| require_options['shim'][s] = [@suite.helper] }
%>
<%= javascript_include_tag *@suite.spec_assets %>
<script type="text/javascript">
Teaspoon.onWindowLoad(function () {
// setup the Teaspoon path prefix to load /assets
require.config(<%= require_options.to_json.html_safe %>);
// require specs by striping off the .js file extension
require(<%= specs.to_json.html_safe %>, function() {
Teaspoon.execute();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment