Make these damn tests pass in ruby 1.9. Evidently, you have to read from $stdin explicitly.

This commit is contained in:
Chris Eppstein 2010-01-18 12:09:17 -08:00
parent 07f988ebff
commit d37d63cce3
4 changed files with 34 additions and 19 deletions

View File

@ -62,7 +62,7 @@ module Compass
print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
instead of the Sass default location of #{default_location}.
Is this OK? (Y/n) }
answer = gets.downcase[0]
answer = $stdin.gets.downcase[0]
answer == ?n ? default_location : recommended_location
end
@ -74,7 +74,8 @@ module Compass
instead the Sass default of #{default_location}/.
However, if you're exclusively using Sass, then #{default_location}/ is recommended.
Emit compiled stylesheets to #{recommended_location}/? (Y/n) }
answer = gets.downcase[0]
answer = $stdin.gets
answer = answer.downcase[0]
answer == ?n ? default_location : recommended_location
end

View File

@ -7,7 +7,7 @@ module Compass::CommandLineHelper
if block_given?
responder = Responder.new
yield responder
IO.popen("-", "w+") do |io|
IO.popen("-", "r+") do |io|
if io
#parent process
output = ""
@ -26,6 +26,7 @@ module Compass::CommandLineHelper
prompt = output.split("\n").last.strip
if response = responder.response_for(prompt)
io.puts response
io.flush
end
end
end
@ -60,7 +61,14 @@ module Compass::CommandLineHelper
@responses << Response.new(prompt, options[:with], options[:required])
end
def response_for(prompt)
response = @responses.detect{|r| r.prompt == prompt}
response = @responses.detect do |r|
case r.prompt
when Regexp
prompt =~ r.prompt
when String
r.prompt == prompt
end
end
if response
response.responded = true
response.text
@ -84,7 +92,7 @@ module Compass::CommandLineHelper
end
message = "Action #{action.inspect} was not performed on: #{path}."
message += "The following actions were performed: #{actions_found.map{|a|a.inspect}.join(", ")}" if actions_found.any?
puts @last_result
# puts @last_result
fail message
end
@ -100,6 +108,8 @@ module Compass::CommandLineHelper
def execute(*arguments)
command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(arguments)
command_line_class.new(arguments).run!
exit_code = command_line_class.new(arguments).run!
# fail "Command Failed with exit code: #{exit_code}" unless exit_code == 0
exit_code
end
end

View File

@ -25,7 +25,7 @@ class CommandLineTest < Test::Unit::TestCase
def test_basic_install
within_tmp_directory do
compass "basic"
compass "--boring", "basic"
assert File.exists?("basic/src/screen.sass")
assert File.exists?("basic/stylesheets/screen.css")
assert_action_performed :directory, "basic/"
@ -35,11 +35,11 @@ class CommandLineTest < Test::Unit::TestCase
end
end
def test_framework_installs
Compass::Frameworks::ALL.each do |framework|
Compass::Frameworks::ALL.each do |framework|
define_method "test_#{framework.name}_installation" do
within_tmp_directory do
compass *%W(--framework #{framework.name} #{framework.name}_project)
assert File.exists?("#{framework.name}_project/src/screen.sass")
compass *%W(--boring --framework #{framework.name} #{framework.name}_project)
assert File.exists?("#{framework.name}_project/src/screen.sass"), "src/screen.sass 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/"
assert_action_performed :create, "#{framework.name}_project/src/screen.sass"
@ -51,13 +51,13 @@ class CommandLineTest < Test::Unit::TestCase
def test_basic_update
within_tmp_directory do
compass "basic"
compass "--boring", "basic"
Dir.chdir "basic" do
# basic update with timestamp caching
compass
compass "--boring"
assert_action_performed :unchanged, "src/screen.sass"
# basic update with force option set
compass "--force"
compass "--force", "--boring"
assert_action_performed :compile, "src/screen.sass"
assert_action_performed :identical, "stylesheets/screen.css"
end

View File

@ -15,18 +15,22 @@ class RailsIntegrationTest < Test::Unit::TestCase
end
def test_rails_install
within_tmp_directory do
# within_tmp_directory do
begin
generate_rails_app_directories("compass_rails")
Dir.chdir "compass_rails" do
compass("--rails", '--trace', ".") do |responder|
responder.respond_to "Is this OK? (Y/n)", :with => "Y", :required => true
responder.respond_to "Emit compiled stylesheets to public/stylesheets/compiled/? (Y/n)", :with => "Y", :required => true
compass(*%w(--rails --trace --boring .)) do |responder|
responder.respond_to %r{^\s*Is this OK\? \(Y/n\)\s*$}, :with => "Y", :required => true
responder.respond_to %r{^\s*Emit compiled stylesheets to public/stylesheets/compiled/\? \(Y/n\)\s*$}, :with => "Y", :required => true
end
# puts ">>>#{@last_result}<<<"
assert_action_performed :create, "./app/stylesheets/screen.sass"
assert_action_performed :create, "./config/initializers/compass.rb"
end
ensure
FileUtils.rm_rf "compass_rails"
end
#end
rescue LoadError
puts "Skipping rails test. Couldn't Load rails"
end
@ -35,7 +39,7 @@ class RailsIntegrationTest < Test::Unit::TestCase
within_tmp_directory do
generate_rails_app_directories("compass_rails")
Dir.chdir "compass_rails" do
compass(*%w(--rails --trace --sass-dir app/stylesheets --css-dir public/stylesheets/compiled .))
compass(*%w(--rails --trace --boring --sass-dir app/stylesheets --css-dir public/stylesheets/compiled .))
assert_action_performed :create, "./app/stylesheets/screen.sass"
assert_action_performed :create, "./config/initializers/compass.rb"
end