PageRenderTime 63ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/plugins/asset_packager/test/asset_package_helper_development_test.rb

https://bitbucket.org/tduarte/hite.in
Ruby | 100 lines | 78 code | 22 blank | 0 comment | 0 complexity | f1dfdef55e70465164b68a0f7a55256a MD5 | raw file
  1. $:.unshift(File.dirname(__FILE__) + '/../lib')
  2. ENV['RAILS_ENV'] = "development"
  3. require File.dirname(__FILE__) + '/../../../../config/environment'
  4. require 'test/unit'
  5. require 'rubygems'
  6. require 'mocha'
  7. require 'action_controller/test_process'
  8. ActionController::Base.logger = nil
  9. ActionController::Routing::Routes.reload rescue nil
  10. $asset_packages_yml = YAML.load_file("#{RAILS_ROOT}/vendor/plugins/asset_packager/test/asset_packages.yml")
  11. $asset_base_path = "#{RAILS_ROOT}/vendor/plugins/asset_packager/test/assets"
  12. class AssetPackageHelperDevelopmentTest < Test::Unit::TestCase
  13. include ActionView::Helpers::TagHelper
  14. include ActionView::Helpers::AssetTagHelper
  15. include Synthesis::AssetPackageHelper
  16. def setup
  17. Synthesis::AssetPackage.any_instance.stubs(:log)
  18. @controller = Class.new do
  19. def request
  20. @request ||= ActionController::TestRequest.new
  21. end
  22. end.new
  23. end
  24. def build_js_expected_string(*sources)
  25. sources.map {|s| javascript_include_tag(s) }.join("\n")
  26. end
  27. def build_css_expected_string(*sources)
  28. sources.map {|s| stylesheet_link_tag(s) }.join("\n")
  29. end
  30. def test_js_basic
  31. assert_dom_equal build_js_expected_string("prototype"),
  32. javascript_include_merged("prototype")
  33. end
  34. def test_js_multiple_packages
  35. assert_dom_equal build_js_expected_string("prototype", "foo"),
  36. javascript_include_merged("prototype", "foo")
  37. end
  38. def test_js_unpackaged_file
  39. assert_dom_equal build_js_expected_string("prototype", "foo", "not_part_of_a_package"),
  40. javascript_include_merged("prototype", "foo", "not_part_of_a_package")
  41. end
  42. def test_js_multiple_from_same_package
  43. assert_dom_equal build_js_expected_string("prototype", "effects", "controls", "not_part_of_a_package", "foo"),
  44. javascript_include_merged("prototype", "effects", "controls", "not_part_of_a_package", "foo")
  45. end
  46. def test_js_by_package_name
  47. assert_dom_equal build_js_expected_string("prototype", "effects", "controls", "dragdrop"),
  48. javascript_include_merged(:base)
  49. end
  50. def test_js_multiple_package_names
  51. assert_dom_equal build_js_expected_string("prototype", "effects", "controls", "dragdrop", "foo", "bar", "application"),
  52. javascript_include_merged(:base, :secondary)
  53. end
  54. def test_css_basic
  55. assert_dom_equal build_css_expected_string("screen"),
  56. stylesheet_link_merged("screen")
  57. end
  58. def test_css_multiple_packages
  59. assert_dom_equal build_css_expected_string("screen", "foo", "subdir/bar"),
  60. stylesheet_link_merged("screen", "foo", "subdir/bar")
  61. end
  62. def test_css_unpackaged_file
  63. assert_dom_equal build_css_expected_string("screen", "foo", "not_part_of_a_package", "subdir/bar"),
  64. stylesheet_link_merged("screen", "foo", "not_part_of_a_package", "subdir/bar")
  65. end
  66. def test_css_multiple_from_same_package
  67. assert_dom_equal build_css_expected_string("screen", "header", "not_part_of_a_package", "foo", "bar", "subdir/foo", "subdir/bar"),
  68. stylesheet_link_merged("screen", "header", "not_part_of_a_package", "foo", "bar", "subdir/foo", "subdir/bar")
  69. end
  70. def test_css_by_package_name
  71. assert_dom_equal build_css_expected_string("screen", "header"),
  72. stylesheet_link_merged(:base)
  73. end
  74. def test_css_multiple_package_names
  75. assert_dom_equal build_css_expected_string("screen", "header", "foo", "bar", "subdir/foo", "subdir/bar"),
  76. stylesheet_link_merged(:base, :secondary, "subdir/styles")
  77. end
  78. end