Module: Qlive::QunitAssets
- Included in:
- Suite
- Defined in:
- lib/qlive/qunit_assets.rb
Instance Method Summary collapse
- #glob_script_tags(src_base_path, url_prefix) ⇒ 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, url_prefix) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/qlive/qunit_assets.rb', line 65 def (src_base_path, url_prefix) sources = Dir.glob("#{src_base_path}#{src_base_path.end_with?('/') ? '' : '/'}**/*.js").sort.flatten sources.map do |src| src = src.to_s href = "#{url_prefix}#{src.sub(src_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_support_assets | qunit_framework | qunit_disable_autostart | qunit_javascript_test_sources | qunit_finalize ) end |
#qunit_disable_autostart ⇒ Object
53 54 55 56 57 |
# File 'lib/qlive/qunit_assets.rb', line 53 def qunit_disable_autostart [ '<script>QUnit.config.autostart = false;</script>' ] end |
#qunit_finalize ⇒ Object
59 60 61 62 63 |
# File 'lib/qlive/qunit_assets.rb', line 59 def qunit_finalize [ '<script>QUnit.done = function(failed, passed, total, runtime) { window.qunitComplete = true; };</script>' ] 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
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/qlive/qunit_assets.rb', line 39 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 id="display-proxified-tests"></div>', '</div>' ] end |
#qunit_javascript_test_sources ⇒ Object
33 34 35 36 37 |
# File 'lib/qlive/qunit_assets.rb', line 33 def qunit_javascript_test_sources test_path = File.('..', self.[:path]) url_prefix = "#{Qlive.setup[:url_prefix] || ''}/#{suite_name}" (test_path, url_prefix) end |
#qunit_support_assets ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/qlive/qunit_assets.rb', line 23 def qunit_support_assets support_relpath = Qlive.setup[:js_support_relpath] path = "#{Qlive.setup[:base_path]}#{support_relpath}" if (File.exist?(path)) (path, "#{Qlive.setup[:url_prefix] || ''}#{support_relpath}") else [] end end |