compass/test/command_line_test.rb
Chris Eppstein f59ca512ce Refactor of the internal datastructures used to access project
configuration. Configuration is now a singly linked list of configuration objects
that inherit values and defaults from the next configuration instance.
All instances hold a reference to the top of the configuration chain.

There is now a consistent API for reading configuration property values:

                <attr>: Reads the fully-resolved attribute after taking
                        configuration inheritance and defaults into account.
            raw_<attr>: reads attribute from a configuration object without
                        inheritance or defaults.
   default_for(<attr>): reads the default value for an attribute
    default_for_<attr>: specifies the default value for an attribute.
<attr>_without_default: reads the inherited attribute without applying defaults.
    comment_for_<attr>: Specifies a comment that will be emitted above the
                        property when serializing the configuration to a file.

Additionally, method_missing and respond_to both work down the
configuration chain, so any method that is added to a configuration
instance, can be accessed from the top level.

The distinction between default and explicitly set values allows compass
to more correctly manage the serialization of attributes when creating
configuration files for projects.

The compass configuration can still be accessed via
Compass.configuration, however, the configuration object is no longer a
singleton. This means that you can build several configuration chains
to track several projects at once. This should ease the use of compass
in other frameworks and plugins that want to use compass internally.
2009-08-29 13:20:32 -07:00

67 lines
2.1 KiB
Ruby

require File.dirname(__FILE__)+'/test_helper'
require 'fileutils'
require 'compass'
require 'compass/exec'
require 'timeout'
class CommandLineTest < Test::Unit::TestCase
include Compass::TestCaseHelper
include Compass::CommandLineHelper
include Compass::IoHelper
def teardown
Compass.reset_configuration!
end
def test_print_version
compass "-vq"
assert_match /\d+\.\d+\.\d+( [0-9a-f]+)?/, @last_result
end
def test_list_frameworks
compass "--list-frameworks"
assert_equal(%w(blueprint compass yui), @last_result.split.sort)
end
def test_basic_install
within_tmp_directory do
compass "basic"
assert File.exists?("basic/src/screen.sass")
assert File.exists?("basic/stylesheets/screen.css")
assert_action_performed :directory, "basic/"
assert_action_performed :create, "basic/src/screen.sass"
assert_action_performed :compile, "basic/src/screen.sass"
assert_action_performed :create, "basic/stylesheets/screen.css"
end
end
def test_framework_installs
Compass::Frameworks::ALL.each do |framework|
within_tmp_directory do
compass *%W(--framework #{framework.name} #{framework.name}_project)
assert File.exists?("#{framework.name}_project/src/screen.sass")
assert File.exists?("#{framework.name}_project/stylesheets/screen.css")
assert_action_performed :directory, "#{framework.name}_project/"
assert_action_performed :create, "#{framework.name}_project/src/screen.sass"
assert_action_performed :compile, "#{framework.name}_project/src/screen.sass"
assert_action_performed :create, "#{framework.name}_project/stylesheets/screen.css"
end
end
end
def test_basic_update
within_tmp_directory do
compass "basic"
Dir.chdir "basic" do
# basic update with timestamp caching
compass
assert_action_performed :unchanged, "src/screen.sass"
# basic update with force option set
compass "--force"
assert_action_performed :compile, "src/screen.sass"
assert_action_performed :identical, "stylesheets/screen.css"
end
end
end
end