A helper function for capturing the output of a pipe.

This commit is contained in:
Chris Eppstein 2009-10-26 09:24:38 -07:00
parent a847004811
commit 149978b4c9
3 changed files with 59 additions and 1 deletions

View File

@ -191,3 +191,27 @@ Feature: Command Line
When I run: compass grid-img 50x24 assets/wide_grid.png When I run: compass grid-img 50x24 assets/wide_grid.png
Then a directory assets is not created Then a directory assets is not created
And a png file assets/wide_grid.png is not created And a png file assets/wide_grid.png is not created
Scenario: Generate a compass configuration file
When I run: compass config config/compass.rb --sass-dir sass --css-dir assets/css
Then a configuration file config/compass.rb is created
And the following configuration properties are set in config/compass.rb:
| property | value |
| sass_dir | sass |
| css_dir | assets/css |
Scenario: Validate the generated CSS
Given I am using the existing project in test/fixtures/stylesheets/compass
When I run: compass validate
Then my css is validated
And I am informed that it is not, because IE6 hacks suck.
Scenario: Get stats for my project
Given I am using the existing project in test/fixtures/stylesheets/compass
When I run: compass stats
Then I am told statistics for each file:
| filename | lines | mixins | selectors | properties |
| src/screen.sass | 22 | 1 | 134 | 1,320 |
| src/print.sass | 22 | 1 | 134 | 1,320 |
| src/ie.sass | 22 | 1 | 134 | 1,320 |

View File

@ -164,3 +164,20 @@ Then /^the list of commands should describe the ([^ ]+) command$/ do |command|
@last_result.should =~ /^\s+\* #{command}\s+- [A-Z].+$/ @last_result.should =~ /^\s+\* #{command}\s+- [A-Z].+$/
end end
Then /^the following configuration properties are set in config\/compass\.rb:$/ do |table|
# table is a Cucumber::Ast::Table
pending
end
Then /^my css is validated$/ do
pending
end
Then /^I am informed that it is not, because IE6 hacks suck\.$/ do
pending
end
Then /^I am told statistics for each file:$/ do |table|
# table is a Cucumber::Ast::Table
pending
end

View File

@ -15,5 +15,22 @@ module Compass
ensure ensure
$stderr = real_stderr $stderr = real_stderr
end end
def capture_pipe(io, options = {})
options[:wait] = 0.25
options[:timeout] = 1.0
output = ""
eof_at = nil
while !eof_at || (Time.now - eof_at < options[:wait])
if io.eof?
eof_at ||= Time.now
sleep 0.1
else
eof_at = nil
timeout(options[:timeout]) { output << io.readpartial(1024) }
end
end
output
end
end end
end end