test scenario for the rails project initialization.
This commit is contained in:
parent
c0a3916080
commit
217c522a92
@ -74,6 +74,17 @@ Feature: Command Line
|
||||
Then an error message is printed out: A bare project cannot be created when a framework is specified.
|
||||
And the command exits with a non-zero error code
|
||||
|
||||
Scenario: Initializing a rails project
|
||||
Given I'm in a newly created rails project: my_rails_project
|
||||
When I initialize a project using: compass init rails --sass-dir app/stylesheets --css-dir public/stylesheets/compiled
|
||||
Then a config file config/compass.config is reported created
|
||||
Then a config file config/compass.config is created
|
||||
And a ruby file config/compass.config is created
|
||||
And a sass file config/initializers/compass.rb is created
|
||||
And a sass file app/stylesheets/screen.sass is created
|
||||
And a sass file app/stylesheets/print.sass is created
|
||||
And a sass file app/stylesheets/ie.sass is created
|
||||
|
||||
Scenario: Compiling an existing project.
|
||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||
When I run: compass compile
|
||||
|
@ -7,8 +7,10 @@ require 'compass/exec'
|
||||
|
||||
include Compass::CommandLineHelper
|
||||
include Compass::IoHelper
|
||||
include Compass::RailsHelper
|
||||
|
||||
Before do
|
||||
Compass.reset_configuration!
|
||||
@cleanup_directories = []
|
||||
@original_working_directory = Dir.pwd
|
||||
end
|
||||
@ -32,12 +34,22 @@ Given %r{^I am in the parent directory$} do
|
||||
Dir.chdir ".."
|
||||
end
|
||||
|
||||
Given /^I'm in a newly created rails project: (.+)$/ do |project_name|
|
||||
@cleanup_directories << project_name
|
||||
generate_rails_app project_name
|
||||
Dir.chdir project_name
|
||||
end
|
||||
|
||||
# When Actions are performed
|
||||
When /^I create a project using: compass create ([^\s]+) ?(.+)?$/ do |dir, args|
|
||||
@cleanup_directories << dir
|
||||
compass 'create', dir, *(args || '').split
|
||||
end
|
||||
|
||||
When /^I initialize a project using: compass init ?(.+)?$/ do |args|
|
||||
compass 'init', *(args || '').split
|
||||
end
|
||||
|
||||
When /^I run: compass ([^\s]+) ?(.+)?$/ do |command, args|
|
||||
compass command, *(args || '').split
|
||||
end
|
||||
@ -91,8 +103,8 @@ Then /^a directory ([^ ]+) is (not )?created$/ do |directory, negated|
|
||||
File.directory?(directory).should == !negated
|
||||
end
|
||||
|
||||
Then /an? \w+ file ([^ ]+) is created/ do |filename|
|
||||
File.exists?(filename).should == true
|
||||
Then /an? \w+ file ([^ ]+) is (not )?created/ do |filename, negated|
|
||||
File.exists?(filename).should == !negated
|
||||
end
|
||||
|
||||
Then /an? \w+ file ([^ ]+) is reported created/ do |filename|
|
||||
|
@ -99,7 +99,7 @@ module Compass
|
||||
if arguments.size == 1
|
||||
parser.options[:project_name] = arguments.shift
|
||||
elsif arguments.size == 0
|
||||
raise Compass::Error, "Please specify a path to the project."
|
||||
# default to the current directory.
|
||||
else
|
||||
raise Compass::Error, "Too many arguments were specified."
|
||||
end
|
||||
|
@ -8,6 +8,7 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
||||
include Compass::TestCaseHelper
|
||||
include Compass::CommandLineHelper
|
||||
include Compass::IoHelper
|
||||
include Compass::RailsHelper
|
||||
|
||||
def setup
|
||||
Compass.reset_configuration!
|
||||
@ -42,43 +43,4 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
||||
rescue LoadError
|
||||
puts "Skipping rails test. Couldn't Load rails"
|
||||
end
|
||||
|
||||
|
||||
def generate_rails_app_directories(name)
|
||||
Dir.mkdir name
|
||||
Dir.mkdir File.join(name, "config")
|
||||
Dir.mkdir File.join(name, "config", "initializers")
|
||||
end
|
||||
|
||||
# Generate a rails application without polluting our current set of requires
|
||||
# with the rails libraries. This will allow testing against multiple versions of rails
|
||||
# by manipulating the load path.
|
||||
def generate_rails_app(name)
|
||||
if pid = fork
|
||||
Process.wait(pid)
|
||||
if $?.exitstatus == 2
|
||||
raise LoadError, "Couldn't load rails"
|
||||
elsif $?.exitstatus != 0
|
||||
raise "Failed to generate rails application."
|
||||
end
|
||||
else
|
||||
begin
|
||||
require 'rails/version'
|
||||
require 'rails_generator'
|
||||
require 'rails_generator/scripts/generate'
|
||||
Rails::Generator::Base.use_application_sources!
|
||||
capture_output do
|
||||
Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new $stdout
|
||||
Rails::Generator::Scripts::Generate.new.run([name], :generator => 'app')
|
||||
end
|
||||
rescue LoadError
|
||||
Kernel.exit(2)
|
||||
rescue => e
|
||||
$stderr.puts e
|
||||
Kernel.exit!(1)
|
||||
end
|
||||
Kernel.exit!(0)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -24,4 +24,5 @@ require 'test/unit'
|
||||
|
||||
require 'test_case_helper'
|
||||
require 'io_helper'
|
||||
require 'rails_helper'
|
||||
require 'command_line_helper'
|
||||
|
Loading…
Reference in New Issue
Block a user