Module: Qlive::QunitAssets
- Included in:
- Suite
- Defined in:
- lib/qlive/qunit_assets.rb
Instance Method Summary collapse
- #glob_script_tags(src_base_path) ⇒ Object
-
#prepare_assets ⇒ Object
default is to serve assets for qlive-rails.
- #qunit_disable_autostart ⇒ Object
- #qunit_finalize ⇒ Object
- #qunit_framework ⇒ Object
- #qunit_html_structure ⇒ Object
- #qunit_javascript_test_sources ⇒ Object
- #qunit_support_assets ⇒ Object
Instance Method Details
#glob_script_tags(src_base_path) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/qlive/qunit_assets.rb', line 66 def (src_base_path) return [] unless File.exist?(src_base_path) sources = Dir.glob("#{src_base_path}#{trailing_slash(src_base_path)}**/*.js").sort.flatten sources.map do |src| src = src.to_s href = "#{url_prefix}#{src.sub(base_path, '')}" "<script type='text/javascript' src='#{href}'></script>" end end |
#prepare_assets ⇒ Object
default is to serve assets for qlive-rails. Override if your qunit assets are elsewhere.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/qlive/qunit_assets.rb', line 5 def prepare_assets before_body_close.concat( qunit_html_structure | qunit_framework | qunit_disable_autostart | qunit_support_assets | qunit_javascript_test_sources | qunit_finalize ) end |
#qunit_disable_autostart ⇒ Object
44 45 46 47 48 |
# File 'lib/qlive/qunit_assets.rb', line 44 def qunit_disable_autostart [ '<script>QUnit.config.autostart = false;</script>' ] end |
#qunit_finalize ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/qlive/qunit_assets.rb', line 50 def qunit_finalize js=" <script>\n window.endQlive = function() {\n if (!$('#qlive-complete').length) {\n $('body').append('<div id=\"qlive-complete\"></div>');\n }\n };\n QUnit.done = function(failed, passed, total, runtime) {\n window.endQlive();\n };\n </script>\n" [ js ] end |
#qunit_framework ⇒ Object
16 17 18 19 20 21 |
# File 'lib/qlive/qunit_assets.rb', line 16 def qunit_framework [ '<link rel="stylesheet" href="/qlive/qunit-1.9.0/qunit.css" type="text/css" media="screen" />', '<script type="text/javascript" src="/qlive/qunit-1.9.0/qunit.js"></script>' ] end |
#qunit_html_structure ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/qlive/qunit_assets.rb', line 31 def qunit_html_structure [ '<div class="qlive-structure">', "<h1 id='qunit-header'>Qlive Suite: #{suite_name}</h1>", '<h2 id="qunit-banner"></h2>', '<div id="qunit-testrunner-toolbar"></div>', '<h2 id="qunit-userAgent"></h2>', '<ol id="qunit-tests"></ol>', '<div id="qunit-fixture">test markup, will be hidden</div>', '</div>' ] end |
#qunit_javascript_test_sources ⇒ Object
27 28 29 |
# File 'lib/qlive/qunit_assets.rb', line 27 def qunit_javascript_test_sources (File.('..', self.registration.path)) end |
#qunit_support_assets ⇒ Object
23 24 25 |
# File 'lib/qlive/qunit_assets.rb', line 23 def qunit_support_assets ("#{sans_slash(base_path)}#{Qlive.setup[:js_support_relpath]}") end |