fixed some issues with test runners calling out the the command line which was creating unexpected results

This commit is contained in:
Scott Davis 2011-12-11 01:31:54 -05:00
parent 684ad8754a
commit 89de5cb492
5 changed files with 24 additions and 10 deletions

View File

@ -2,9 +2,9 @@ source :rubygems
gemspec gemspec
gem "cucumber", "~> 1.1.0" gem "cucumber", "~> 1.1.4"
gem "rspec", "~>2.0.0" gem "rspec", "~>2.0.0"
gem "rails", "~>3.0.0.rc" gem "rails", "~> 3.1"
gem "compass-validator", "3.0.1" gem "compass-validator", "3.0.1"
gem "css_parser", "~> 1.0.1" gem "css_parser", "~> 1.0.1"
gem "sass", "~> 3.1" gem "sass", "~> 3.1"

View File

@ -15,7 +15,7 @@ Feature: Extensions
@listframeworks @listframeworks
Scenario: Extensions directory for rails projects Scenario: Extensions directory for rails projects
Given ruby supports fork Given ruby supports fork
And I'm in a newly created rails project: my_rails_project And I'm in a newly created rails project: extension_test_rails_project
And I run: compass init rails And I run: compass init rails
And the "vendor/plugins/compass_extensions" directory exists And the "vendor/plugins/compass_extensions" directory exists
And and I have a fake extension at vendor/plugins/compass_extensions/testing And and I have a fake extension at vendor/plugins/compass_extensions/testing

View File

@ -42,10 +42,11 @@ Given %r{^I am in the parent directory$} do
end end
Given %r{^I'm in a newly created rails project: (.+)$} do |project_name| Given %r{^I'm in a newly created rails project: (.+)$} do |project_name|
@cleanup_directories << project_name dir = File.join(Dir.pwd, project_name)
@cleanup_directories << dir
begin begin
generate_rails_app project_name generate_rails_app project_name, Dir.pwd
Dir.chdir project_name Dir.chdir dir
rescue LoadError rescue LoadError
pending "Missing Ruby-on-rails gems: sudo gem install rails" pending "Missing Ruby-on-rails gems: sudo gem install rails"
end end

View File

@ -10,7 +10,7 @@ module Compass
# Generate a rails application without polluting our current set of requires # Generate a rails application without polluting our current set of requires
# with the rails libraries. This will allow testing against multiple versions of rails # with the rails libraries. This will allow testing against multiple versions of rails
# by manipulating the load path. # by manipulating the load path.
def generate_rails_app(name) def generate_rails_app(name, dir = nil)
if pid = fork if pid = fork
Process.wait(pid) Process.wait(pid)
if $?.exitstatus == 2 if $?.exitstatus == 2
@ -22,7 +22,16 @@ module Compass
begin begin
require 'action_pack/version' require 'action_pack/version'
if ActionPack::VERSION::MAJOR >= 3 if ActionPack::VERSION::MAJOR >= 3
`rails new #{name}` require 'rails/generators'
require 'rails/generators/rails/app/app_generator'
require 'mocha'
dir ||= File.join(File.expand_path('../../', __FILE__))
args = [File.join(dir, name), '-q', '-f', '--skip-bundle', '--skip-gemfile']
#stub this so you can generate more apps
Rails::Generators::AppGenerator.any_instance.stubs(:valid_const?).returns(true)
Rails::Generators::AppGenerator.start(args, {:destination_root => dir})
else else
require 'rails/version' require 'rails/version'
require 'rails_generator' require 'rails_generator'

View File

@ -1,6 +1,10 @@
require 'test_helper' require 'test_helper'
require 'compass/exec'
class SpriteCommandTest < Test::Unit::TestCase class SpriteCommandTest < Test::Unit::TestCase
include Compass::TestCaseHelper
include Compass::CommandLineHelper
include Compass::IoHelper
attr_reader :test_dir attr_reader :test_dir
include SpriteHelper include SpriteHelper
def setup def setup
@ -27,7 +31,7 @@ class SpriteCommandTest < Test::Unit::TestCase
def run_compass_with_options(options) def run_compass_with_options(options)
output = 'foo' output = 'foo'
::Dir.chdir @test_dir ::Dir.chdir @test_dir
%x{compass #{options.join(' ')}} compass *options
end end
def options_to_cli(options) def options_to_cli(options)