Permalink
Browse files

More succinct tests

  • Loading branch information...
1 parent b02b00e commit 33d4b070d227042ae6aa9b5915643b90d474a4ff @mjackson committed Aug 2, 2010
Showing with 22 additions and 27 deletions.
  1. +9 −10 test/css_test.rb
  2. +13 −17 test/js_test.rb
View
@@ -1,7 +1,7 @@
require File.expand_path('../helper', __FILE__)
class CSSTest < Test::Unit::TestCase
- FIXTURE_CSS = <<'CODE'
+ FIXTURE = <<'CODE'
.a-class {
background-color: red;
background-position: 0;
@@ -10,17 +10,17 @@ class CSSTest < Test::Unit::TestCase
div#an-id { color: #FFFFFF; }
CODE
- def test_default_arguments
+ def test_default_command_arguments
+ args = command_arguments(default_css_options)
+
if jruby?
- args = command_arguments(default_css_options)
assert_equal([-1], args)
else
- args = command_arguments(default_css_options)
assert_equal(%w< --charset utf-8 >, args)
end
end
- def test_arguments
+ def test_command_arguments
if jruby?
args = command_arguments(:type => 'css')
assert_equal([-1], args)
@@ -42,15 +42,14 @@ def test_arguments
end
end
- def test_default_compress
- assert_equal (<<'CODE').chomp, compress_css(FIXTURE_CSS)
+ def test_default_options
+ assert_equal (<<'CODE').chomp, compress_css(FIXTURE)
.a-class{background-color:red;background-position:0 0;}div#an-id{color:#FFF;}
CODE
end
- def test_line_break_option_should_insert_line_breaks
- options = { :line_break => 0 }
- assert_equal (<<'CODE').chomp, compress_css(FIXTURE_CSS, options)
+ def test_line_break_option
+ assert_equal (<<'CODE').chomp, compress_css(FIXTURE, :line_break => 0)
.a-class{background-color:red;background-position:0 0;}
div#an-id{color:#FFF;}
CODE
View
@@ -1,7 +1,7 @@
require File.expand_path('../helper', __FILE__)
class JSTest < Test::Unit::TestCase
- FIXTURE_JS = <<'CODE'
+ FIXTURE = <<'CODE'
// here's a comment
var Foo = { "a": 1 };
Foo["bar"] = (function(baz) {
@@ -17,7 +17,7 @@ class JSTest < Test::Unit::TestCase
})("hello");
CODE
- def test_default_arguments
+ def test_default_command_arguments
if jruby?
args = command_arguments(default_js_options)
assert_equal([-1], args)
@@ -27,7 +27,7 @@ def test_default_arguments
end
end
- def test_arguments
+ def test_command_arguments
if jruby?
args = command_arguments(:type => 'js')
assert_equal([-1, false, false, false, true], args)
@@ -55,15 +55,14 @@ def test_arguments
end
end
- def test_default_compress
- assert_equal (<<'CODE').chomp, compress_js(FIXTURE_JS)
+ def test_default_options
+ assert_equal (<<'CODE').chomp, compress_js(FIXTURE)
var Foo={a:1};Foo.bar=(function(baz){if(false){doSomething()}else{for(var index=0;index<baz.length;index++){doSomething(baz[index])}}})("hello");
CODE
end
- def test_line_break_option_should_insert_line_breaks
- options = { :line_break => 0 }
- assert_equal (<<'CODE').chomp, compress_js(FIXTURE_JS, options)
+ def test_line_break_option
+ assert_equal (<<'CODE').chomp, compress_js(FIXTURE, :line_break => 0)
var Foo={a:1};
Foo.bar=(function(baz){if(false){doSomething()
}else{for(var index=0;
@@ -73,23 +72,20 @@ def test_line_break_option_should_insert_line_breaks
CODE
end
- def test_munge_option_should_munge_local_variable_names
- options = { :munge => true }
- assert_equal (<<'CODE').chomp, compress_js(FIXTURE_JS, options)
+ def test_munge_option
+ assert_equal (<<'CODE').chomp, compress_js(FIXTURE, :munge => true)
var Foo={a:1};Foo.bar=(function(b){if(false){doSomething()}else{for(var a=0;a<b.length;a++){doSomething(b[a])}}})("hello");
CODE
end
- def test_optimize_option_should_not_modify_property_accesses_or_object_literal_keys_when_false
- options = { :optimize => false }
- assert_equal (<<'CODE').chomp, compress_js(FIXTURE_JS, options)
+ def test_optimize_option
+ assert_equal (<<'CODE').chomp, compress_js(FIXTURE, :optimize => false)
var Foo={"a":1};Foo["bar"]=(function(baz){if(false){doSomething()}else{for(var index=0;index<baz.length;index++){doSomething(baz[index])}}})("hello");
CODE
end
- def test_preserve_semicolons_option_should_preserve_semicolons
- options = { :preserve_semicolons => true }
- assert_equal (<<'CODE').chomp, compress_js(FIXTURE_JS, options)
+ def test_preserve_semicolons_option
+ assert_equal (<<'CODE').chomp, compress_js(FIXTURE, :preserve_semicolons => true)
var Foo={a:1};Foo.bar=(function(baz){if(false){doSomething();}else{for(var index=0;index<baz.length;index++){doSomething(baz[index]);}}})("hello");
CODE
end

0 comments on commit 33d4b07

Please sign in to comment.