diff --git a/features/command_line.feature b/features/command_line.feature new file mode 100644 index 00000000..d02de470 --- /dev/null +++ b/features/command_line.feature @@ -0,0 +1,21 @@ +Feature: Command Line + In order to manage my stylesheets + As a user on the command line + I want to create a new project + + Scenario: Install a project without a framework + When I enter the command: compass create my_project + Then a directory my_project/ is created + And a configuration file my_project/config.rb is created + And a sass file my_project/src/screen.sass is created + And a sass file my_project/src/print.sass is created + And a sass file my_project/src/ie.sass is created + And a sass file my_project/src/screen.sass is compiled + And a sass file my_project/src/print.sass is compiled + And a sass file my_project/src/ie.sass is compiled + And a css file my_project/stylesheets/screen.css is created + And a css file my_project/stylesheets/print.css is created + And a css file my_project/stylesheets/ie.css is created + And I am told how to link to /stylesheets/screen.css for media "screen, projection" + And I am told how to link to /stylesheets/print.css for media "print" + And I am told how to conditionally link IE to /stylesheets/ie.css for media "screen, projection" diff --git a/features/step_definitions/command_line_steps.rb b/features/step_definitions/command_line_steps.rb new file mode 100644 index 00000000..96086c48 --- /dev/null +++ b/features/step_definitions/command_line_steps.rb @@ -0,0 +1,49 @@ +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 = [] +end + +After do + @cleanup_directories.each do |dir| + FileUtils.rm_rf dir + end +end + +When /I enter the command: compass create ([^\s]+) ?(.+)?/ do |dir, args| + @cleanup_directories << dir + compass 'create', dir, *(args || '').split +end + +# When /I enter the command: compass ([^\s]+) ?(.+)?/ do |command, args| +# compass command, *args.split +# end + + +Then /a directory ([^ ]+) is created/ do |directory| + File.directory?(directory).should == true +end + +Then /a \w+ file ([^ ]+) is created/ do |filename| + File.exists?(filename).should == true +end + +Then /a \w+ file ([^ ]+) is compiled/ do |filename| + @last_result.should =~ /compile #{Regexp.escape(filename)}/ +end + +Then /I am told how to link to ([^ ]+) for media "([^"]+)"/ do |stylesheet, media| + @last_result.should =~ %r{} +end + +Then /I am told how to conditionally link ([^ ]+) to ([^ ]+) for media "([^"]+)"/ do |condition, stylesheet, media| + @last_result.should =~ %r{}mi +end diff --git a/test/command_line_helper.rb b/test/command_line_helper.rb index 2ecb0871..89d5b986 100644 --- a/test/command_line_helper.rb +++ b/test/command_line_helper.rb @@ -91,6 +91,7 @@ module Compass::CommandLineHelper end def execute(*arguments) - Compass::Exec::SwitchUI.new(arguments).run! + command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(arguments) + command_line_class.new(arguments).run! end end diff --git a/test/test_helper.rb b/test/test_helper.rb index d1c32c4a..0c3cd661 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,8 @@ need_gems = false lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) $:.unshift(lib_dir) unless $:.include?(lib_dir) +test_dir = File.dirname(__FILE__) +$:.unshift(test_dir) unless $:.include?(test_dir) # allows testing with edge Haml by creating a test/haml symlink linked_haml = File.dirname(__FILE__) + '/haml' @@ -20,6 +22,6 @@ require 'compass' require 'test/unit' -require File.join(File.dirname(__FILE__), 'test_case_helper') -require File.join(File.dirname(__FILE__), 'io_helper') -require File.join(File.dirname(__FILE__), 'command_line_helper') +require 'test_case_helper' +require 'io_helper' +require 'command_line_helper'