Skip to content

Commit

Permalink
make tests more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Feb 13, 2010
1 parent b66becb commit f9acaf0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
36 changes: 18 additions & 18 deletions test/more_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
require 'test_helper'

class MoreTest < Test::Unit::TestCase
class MoreTest < ActiveSupport::TestCase
def setup
[:compression, :header, :destination_path, :source_path].each do |variable|
Less::More.send("#{variable}=", nil)
end
end

def teardown
`rm -rf #{css_path}`
end

def prepare_for_generate
Less::More.source_path = 'less_files'
Less::More.destination_path = 'css'
Expand All @@ -19,47 +23,43 @@ def css_path
"#{Rails.root}/public/css"
end

def teardown
`rm -rf #{css_path}`
end

def test_default_for_header
test "header is true by default" do
assert_equal Less::More.header, true
end

def test_header_can_be_overwritten
test "header can be overwritten" do
Less::More.header = false
assert_equal false, Less::More.header
end

def test_default_for_source_path
test "source_path is app/stylesheets by default" do
assert_equal 'app/stylesheets', Less::More.source_path
end

def test_source_path_can_be_overwritten
test "source_path can be overwritten" do
Less::More.source_path = 'xxx'
assert_equal 'xxx', Less::More.source_path
end

def test_default_for_destination_path
test "destination_path is public/stylesheets by default" do
assert_equal 'stylesheets', Less::More.destination_path
end

def test_destination_path_can_be_overwritten
test "destination_path can be overwritten" do
Less::More.destination_path = 'xxx'
assert_equal 'xxx', Less::More.destination_path
end

def test_default_for_compression
test "compression is off by default" do
assert_equal nil, Less::More.compression
end

def test_compression_can_be_overwritten
test "compression can be overwritten" do
Less::More.compression = true
assert_equal true, Less::More.compression
end

def test_generate_with_partials
test "generate includes imported partials" do
prepare_for_generate
Less::More.generate_all
css = File.read(File.join(css_path, 'test.css'))
Expand All @@ -71,30 +71,30 @@ def test_generate_with_partials
}")
end

def test_generate_does_not_parse_css
test "generate does not parse css" do
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
test "generate adds disclaimer-header when active" do
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
test "generate uses no header when not set" do
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
test "generate does not generate partials" do
prepare_for_generate
Less::More.generate_all
assert !File.exist?(File.join(css_path, '_global.css'))
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'rubygems'
require 'active_support'
require 'active_support/test_case'

class Rails
def self.root
Expand Down

0 comments on commit f9acaf0

Please sign in to comment.