compass/test/units/command_line_test.rb

61 lines
2.1 KiB
Ruby
Raw Permalink Normal View History

2009-11-19 10:26:35 +00:00
require 'test_helper'
require 'fileutils'
require 'compass'
require 'compass/exec'
require 'timeout'
class CommandLineTest < Test::Unit::TestCase
include Compass::TestCaseHelper
include Compass::CommandLineHelper
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-25 21:18:58 +00:00
include Compass::IoHelper
def teardown
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-25 21:18:58 +00:00
Compass.reset_configuration!
end
def test_print_version
compass "-vq"
assert_match /\d+\.\d+\.(\d+|((alpha|beta|rc)\.\d+\.[0-9a-f]+))?/, @last_result
end
def test_basic_install
within_tmp_directory do
compass "create", "--boring", "basic"
2010-10-31 04:59:38 +00:00
assert File.exists?("basic/sass/screen.scss")
assert File.exists?("basic/stylesheets/screen.css")
assert_action_performed :directory, "basic/"
2010-10-31 04:59:38 +00:00
assert_action_performed :create, "basic/sass/screen.scss"
assert_action_performed :create, "basic/stylesheets/screen.css"
end
end
Compass::Frameworks::ALL.each do |framework|
2010-04-07 16:00:49 +00:00
next if framework.name =~ /^_/
define_method "test_#{framework.name}_installation" do
within_tmp_directory do
compass *%W(create --boring --using #{framework.name} #{framework.name}_project)
2010-10-31 04:59:38 +00:00
assert File.exists?("#{framework.name}_project/sass/screen.scss"), "sass/screen.scss is missing. Found: #{Dir.glob("#{framework.name}_project/**/*").join(", ")}"
assert File.exists?("#{framework.name}_project/stylesheets/screen.css")
assert_action_performed :directory, "#{framework.name}_project/"
2010-10-31 04:59:38 +00:00
assert_action_performed :create, "#{framework.name}_project/sass/screen.scss"
assert_action_performed :create, "#{framework.name}_project/stylesheets/screen.css"
end
end
end
def test_basic_update
within_tmp_directory do
compass "create", "--boring", "basic"
Dir.chdir "basic" do
# basic update with timestamp caching
compass "compile", "--boring"
2010-10-31 04:59:38 +00:00
assert_action_performed :unchanged, "sass/screen.scss"
# basic update with force option set
compass "compile", "--force", "--boring"
assert_action_performed :identical, "stylesheets/screen.css"
end
end
end
2009-11-19 10:26:35 +00:00
end