Skip to content
Browse files

simplify tests

  • Loading branch information...
1 parent 7990548 commit b66becbee0061d37f65c1b457fe42fefcccd7c6c @grosser grosser committed Feb 11, 2010
Showing with 15 additions and 9 deletions.
  1. +15 −9 test/more_test.rb
View
24 test/more_test.rb
@@ -11,10 +11,16 @@ def prepare_for_generate
Less::More.source_path = 'less_files'
Less::More.destination_path = 'css'
- css = "#{Rails.root}/public/css"
- `rm -rf #{css}`
- `mkdir -p #{css}`
- css
+ `rm -rf #{css_path}`
+ `mkdir -p #{css_path}`
+ end
+
+ def css_path
+ "#{Rails.root}/public/css"
+ end
+
+ def teardown
+ `rm -rf #{css_path}`
end
def test_default_for_header
@@ -54,7 +60,7 @@ def test_compression_can_be_overwritten
end
def test_generate_with_partials
- css_path = prepare_for_generate
+ prepare_for_generate
Less::More.generate_all
css = File.read(File.join(css_path, 'test.css'))
assert css.include?(".allforms { font-size: 110%; }
@@ -66,30 +72,30 @@ def test_generate_with_partials
end
def test_generate_does_not_parse_css
- css_path = prepare_for_generate
+ prepare_for_generate
Less::More.generate_all
original_css = File.read(File.join(css_path, 'plain.css'))
assert_equal File.read(File.join(Rails.root,'less_files', 'plain.css')), original_css
end
def test_generate_uses_header_when_set
- css_path = prepare_for_generate
+ prepare_for_generate
Less::More.header = true
Less::More.generate_all
css = File.read(File.join(css_path, 'test.css'))
assert_match /^\/\*/, css # starts with comment -> header
end
def test_generate_uses_no_header_when_not_set
- css_path = prepare_for_generate
+ prepare_for_generate
Less::More.header = false
Less::More.generate_all
css = File.read(File.join(css_path, 'test.css'))
assert_match /^\.allforms/, css
end
def test_generate_does_not_generate_partials
- css_path = prepare_for_generate
+ prepare_for_generate
Less::More.generate_all
assert !File.exist?(File.join(css_path, '_global.css'))
end

0 comments on commit b66becb

Please sign in to comment.
Something went wrong with that request. Please try again.