Make these damn tests pass in ruby 1.9. Evidently, you have to read from $stdin explicitly.
This commit is contained in:
parent
07f988ebff
commit
d37d63cce3
@ -62,7 +62,7 @@ module Compass
|
|||||||
print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
|
print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
|
||||||
instead of the Sass default location of #{default_location}.
|
instead of the Sass default location of #{default_location}.
|
||||||
Is this OK? (Y/n) }
|
Is this OK? (Y/n) }
|
||||||
answer = gets.downcase[0]
|
answer = $stdin.gets.downcase[0]
|
||||||
answer == ?n ? default_location : recommended_location
|
answer == ?n ? default_location : recommended_location
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -74,7 +74,8 @@ module Compass
|
|||||||
instead the Sass default of #{default_location}/.
|
instead the Sass default of #{default_location}/.
|
||||||
However, if you're exclusively using Sass, then #{default_location}/ is recommended.
|
However, if you're exclusively using Sass, then #{default_location}/ is recommended.
|
||||||
Emit compiled stylesheets to #{recommended_location}/? (Y/n) }
|
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
|
answer == ?n ? default_location : recommended_location
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ module Compass::CommandLineHelper
|
|||||||
if block_given?
|
if block_given?
|
||||||
responder = Responder.new
|
responder = Responder.new
|
||||||
yield responder
|
yield responder
|
||||||
IO.popen("-", "w+") do |io|
|
IO.popen("-", "r+") do |io|
|
||||||
if io
|
if io
|
||||||
#parent process
|
#parent process
|
||||||
output = ""
|
output = ""
|
||||||
@ -26,6 +26,7 @@ module Compass::CommandLineHelper
|
|||||||
prompt = output.split("\n").last.strip
|
prompt = output.split("\n").last.strip
|
||||||
if response = responder.response_for(prompt)
|
if response = responder.response_for(prompt)
|
||||||
io.puts response
|
io.puts response
|
||||||
|
io.flush
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -60,7 +61,14 @@ module Compass::CommandLineHelper
|
|||||||
@responses << Response.new(prompt, options[:with], options[:required])
|
@responses << Response.new(prompt, options[:with], options[:required])
|
||||||
end
|
end
|
||||||
def response_for(prompt)
|
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
|
if response
|
||||||
response.responded = true
|
response.responded = true
|
||||||
response.text
|
response.text
|
||||||
@ -84,7 +92,7 @@ module Compass::CommandLineHelper
|
|||||||
end
|
end
|
||||||
message = "Action #{action.inspect} was not performed on: #{path}."
|
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?
|
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
|
fail message
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -100,6 +108,8 @@ module Compass::CommandLineHelper
|
|||||||
|
|
||||||
def execute(*arguments)
|
def execute(*arguments)
|
||||||
command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(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
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ class CommandLineTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_basic_install
|
def test_basic_install
|
||||||
within_tmp_directory do
|
within_tmp_directory do
|
||||||
compass "basic"
|
compass "--boring", "basic"
|
||||||
assert File.exists?("basic/src/screen.sass")
|
assert File.exists?("basic/src/screen.sass")
|
||||||
assert File.exists?("basic/stylesheets/screen.css")
|
assert File.exists?("basic/stylesheets/screen.css")
|
||||||
assert_action_performed :directory, "basic/"
|
assert_action_performed :directory, "basic/"
|
||||||
@ -35,11 +35,11 @@ class CommandLineTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
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
|
within_tmp_directory do
|
||||||
compass *%W(--framework #{framework.name} #{framework.name}_project)
|
compass *%W(--boring --framework #{framework.name} #{framework.name}_project)
|
||||||
assert File.exists?("#{framework.name}_project/src/screen.sass")
|
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 File.exists?("#{framework.name}_project/stylesheets/screen.css")
|
||||||
assert_action_performed :directory, "#{framework.name}_project/"
|
assert_action_performed :directory, "#{framework.name}_project/"
|
||||||
assert_action_performed :create, "#{framework.name}_project/src/screen.sass"
|
assert_action_performed :create, "#{framework.name}_project/src/screen.sass"
|
||||||
@ -51,13 +51,13 @@ class CommandLineTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_basic_update
|
def test_basic_update
|
||||||
within_tmp_directory do
|
within_tmp_directory do
|
||||||
compass "basic"
|
compass "--boring", "basic"
|
||||||
Dir.chdir "basic" do
|
Dir.chdir "basic" do
|
||||||
# basic update with timestamp caching
|
# basic update with timestamp caching
|
||||||
compass
|
compass "--boring"
|
||||||
assert_action_performed :unchanged, "src/screen.sass"
|
assert_action_performed :unchanged, "src/screen.sass"
|
||||||
# basic update with force option set
|
# basic update with force option set
|
||||||
compass "--force"
|
compass "--force", "--boring"
|
||||||
assert_action_performed :compile, "src/screen.sass"
|
assert_action_performed :compile, "src/screen.sass"
|
||||||
assert_action_performed :identical, "stylesheets/screen.css"
|
assert_action_performed :identical, "stylesheets/screen.css"
|
||||||
end
|
end
|
||||||
|
@ -15,18 +15,22 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_rails_install
|
def test_rails_install
|
||||||
within_tmp_directory do
|
# within_tmp_directory do
|
||||||
|
begin
|
||||||
generate_rails_app_directories("compass_rails")
|
generate_rails_app_directories("compass_rails")
|
||||||
Dir.chdir "compass_rails" do
|
Dir.chdir "compass_rails" do
|
||||||
compass("--rails", '--trace', ".") do |responder|
|
compass(*%w(--rails --trace --boring .)) do |responder|
|
||||||
responder.respond_to "Is this OK? (Y/n)", :with => "Y", :required => true
|
responder.respond_to %r{^\s*Is this OK\? \(Y/n\)\s*$}, :with => "Y", :required => true
|
||||||
responder.respond_to "Emit compiled stylesheets to public/stylesheets/compiled/? (Y/n)", :with => "Y", :required => true
|
responder.respond_to %r{^\s*Emit compiled stylesheets to public/stylesheets/compiled/\? \(Y/n\)\s*$}, :with => "Y", :required => true
|
||||||
end
|
end
|
||||||
# puts ">>>#{@last_result}<<<"
|
# puts ">>>#{@last_result}<<<"
|
||||||
assert_action_performed :create, "./app/stylesheets/screen.sass"
|
assert_action_performed :create, "./app/stylesheets/screen.sass"
|
||||||
assert_action_performed :create, "./config/initializers/compass.rb"
|
assert_action_performed :create, "./config/initializers/compass.rb"
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
FileUtils.rm_rf "compass_rails"
|
||||||
end
|
end
|
||||||
|
#end
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
puts "Skipping rails test. Couldn't Load rails"
|
puts "Skipping rails test. Couldn't Load rails"
|
||||||
end
|
end
|
||||||
@ -35,7 +39,7 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
|||||||
within_tmp_directory do
|
within_tmp_directory do
|
||||||
generate_rails_app_directories("compass_rails")
|
generate_rails_app_directories("compass_rails")
|
||||||
Dir.chdir "compass_rails" do
|
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, "./app/stylesheets/screen.sass"
|
||||||
assert_action_performed :create, "./config/initializers/compass.rb"
|
assert_action_performed :create, "./config/initializers/compass.rb"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user