Skip to content

Instantly share code, notes, and snippets.

@bosko
Created September 14, 2010 11:52
Show Gist options
  • Save bosko/578914 to your computer and use it in GitHub Desktop.
Save bosko/578914 to your computer and use it in GitHub Desktop.
RSpec load win32console on start
From f9aa9934e53446e281ed8b054c984d8e314050f5 Mon Sep 17 00:00:00 2001
From: Bosko Ivanisevic <bosko.ivanisevic@gmail.com>
Date: Tue, 14 Sep 2010 13:41:06 +0200
Subject: [PATCH] Load win32console on startup
At the time color option is set, wrong IO objects are configured
for error and output streams. Win32console must be loaded before
run is called in order to get coloured output on MS Windows.
---
bin/rspec | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/bin/rspec b/bin/rspec
index 3aecb61..bde646a 100755
--- a/bin/rspec
+++ b/bin/rspec
@@ -1,3 +1,9 @@
#!/usr/bin/env ruby
require 'rspec/core'
+begin
+ require 'Win32/Console/ANSI' if Config::CONFIG['host_os'] =~ /mswin|mingw/
+rescue LoadError
+ warn "You must 'gem install win32console' to use colour on Windows"
+end
+
exit RSpec::Core::Runner.run(ARGV, $stderr, $stdout)
--
1.7.2.3.msysgit.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment