2009-10-16 07:57:34 +00:00
|
|
|
require 'spec/expectations'
|
|
|
|
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../test')))
|
|
|
|
|
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
require 'compass/exec'
|
|
|
|
|
|
|
|
include Compass::CommandLineHelper
|
|
|
|
include Compass::IoHelper
|
|
|
|
|
|
|
|
Before do
|
|
|
|
@cleanup_directories = []
|
2009-10-24 22:21:49 +00:00
|
|
|
@original_working_directory = Dir.pwd
|
2009-10-16 07:57:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
After do
|
2009-10-24 22:21:49 +00:00
|
|
|
Dir.chdir @original_working_directory
|
2009-10-16 07:57:34 +00:00
|
|
|
@cleanup_directories.each do |dir|
|
|
|
|
FileUtils.rm_rf dir
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-10-24 22:21:49 +00:00
|
|
|
# Given Preconditions
|
|
|
|
Given %r{^I am using the existing project in ([^\s]+)$} do |project|
|
|
|
|
tmp_project = "tmp_#{File.basename(project)}"
|
|
|
|
@cleanup_directories << tmp_project
|
|
|
|
FileUtils.cp_r project, tmp_project
|
|
|
|
Dir.chdir tmp_project
|
|
|
|
end
|
|
|
|
|
|
|
|
Given %r{^I am in the parent directory$} do
|
|
|
|
Dir.chdir ".."
|
|
|
|
end
|
|
|
|
|
|
|
|
# When Actions are performed
|
|
|
|
When /^I create a project using: compass create ([^\s]+) ?(.+)?$/ do |dir, args|
|
2009-10-16 07:57:34 +00:00
|
|
|
@cleanup_directories << dir
|
|
|
|
compass 'create', dir, *(args || '').split
|
|
|
|
end
|
|
|
|
|
2009-10-24 22:21:49 +00:00
|
|
|
When /^I run: compass ([^\s]+) ?(.+)?$/ do |command, args|
|
|
|
|
compass command, *(args || '').split
|
|
|
|
end
|
2009-10-16 07:57:34 +00:00
|
|
|
|
2009-10-24 22:21:49 +00:00
|
|
|
When /^I touch ([^\s]+)$/ do |filename|
|
|
|
|
FileUtils.touch filename
|
|
|
|
end
|
|
|
|
|
|
|
|
When /^I wait ([\d.]+) seconds?$/ do |count|
|
|
|
|
sleep count.to_f
|
|
|
|
end
|
|
|
|
|
|
|
|
# Then postconditions
|
|
|
|
Then /^a directory ([^ ]+) is (not )?created$/ do |directory, negated|
|
2009-10-17 00:36:29 +00:00
|
|
|
File.directory?(directory).should == !negated
|
2009-10-16 07:57:34 +00:00
|
|
|
end
|
|
|
|
|
2009-10-17 00:36:29 +00:00
|
|
|
Then /an? \w+ file ([^ ]+) is created/ do |filename|
|
2009-10-16 07:57:34 +00:00
|
|
|
File.exists?(filename).should == true
|
|
|
|
end
|
|
|
|
|
2009-10-17 00:36:29 +00:00
|
|
|
Then /an? \w+ file ([^ ]+) is reported created/ do |filename|
|
|
|
|
@last_result.should =~ /create #{Regexp.escape(filename)}/
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /a \w+ file ([^ ]+) is (?:reported )?compiled/ do |filename|
|
2009-10-16 07:57:34 +00:00
|
|
|
@last_result.should =~ /compile #{Regexp.escape(filename)}/
|
|
|
|
end
|
|
|
|
|
2009-10-24 22:21:49 +00:00
|
|
|
Then /a \w+ file ([^ ]+) is reported unchanged/ do |filename|
|
|
|
|
@last_result.should =~ /unchanged #{Regexp.escape(filename)}/
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /a \w+ file ([^ ]+) is reported identical/ do |filename|
|
|
|
|
@last_result.should =~ /identical #{Regexp.escape(filename)}/
|
|
|
|
end
|
|
|
|
|
2009-10-16 07:57:34 +00:00
|
|
|
Then /I am told how to link to ([^ ]+) for media "([^"]+)"/ do |stylesheet, media|
|
|
|
|
@last_result.should =~ %r{<link href="#{stylesheet}" media="#{media}" rel="stylesheet" type="text/css" />}
|
|
|
|
end
|
|
|
|
|
2009-10-17 00:36:29 +00:00
|
|
|
Then /I am told how to conditionally link "([^"]+)" to ([^ ]+) for media "([^"]+)"/ do |condition, stylesheet, media|
|
2009-10-16 07:57:34 +00:00
|
|
|
@last_result.should =~ %r{<!--\[if #{condition}\]>\s+<link href="#{stylesheet}" media="#{media}" rel="stylesheet" type="text/css" />\s+<!\[endif\]-->}mi
|
|
|
|
end
|
2009-10-22 16:46:46 +00:00
|
|
|
|
|
|
|
Then /^an error message is printed out: (.+)$/ do |error_message|
|
|
|
|
@last_error.should =~ Regexp.new(Regexp.escape(error_message))
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^the command exits with a non\-zero error code$/ do
|
|
|
|
@last_exit_code.should_not == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
Then /^I am congratulated$/ do
|
2009-10-24 22:21:08 +00:00
|
|
|
@last_result.should =~ /Congratulations!/
|
2009-10-22 16:46:46 +00:00
|
|
|
end
|
|
|
|
|
2009-10-24 22:21:08 +00:00
|
|
|
Then /^I am told that I can place stylesheets in the ([^\s]+) subdirectory$/ do |subdir|
|
|
|
|
@last_result.should =~ /You may now add sass stylesheets to the #{subdir} subdirectory of your project./
|
2009-10-22 16:46:46 +00:00
|
|
|
end
|
|
|
|
|
2009-10-24 22:21:08 +00:00
|
|
|
Then /^I am told how to compile my sass stylesheets$/ do
|
|
|
|
@last_result.should =~ /You must compile your sass stylesheets into CSS when they change.\nThis can be done in one of the following ways:/
|
2009-10-22 16:46:46 +00:00
|
|
|
end
|
|
|
|
|
2009-10-24 22:21:49 +00:00
|
|
|
end
|
|
|
|
|