Permalink
Browse files

Instead of dying with NoMethodError on JRuby, provide a conservative …

…default terminal width.
  • Loading branch information...
1 parent ae57086 commit 6c695c2a9fe552150e1f6570cac6cf47b18fbdc7 @BanzaiMan BanzaiMan committed Jan 14, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/nyan_cat_formatter.rb
@@ -81,11 +81,15 @@ def current_width
end
# A Unix trick using stty to get the console columns
- # does not work in JRuby :-(
#
# @return [Fixnum]
def terminal_width
- @terminal_width ||= `stty size`.split.map { |x| x.to_i }.reverse.first - 1
+ if defined? JRUBY_VERSION
+ default_width = 80
+ else
+ default_width = `stty size`.split.map { |x| x.to_i }.reverse.first - 1
+ end
+ @terminal_width ||= default_width
end
# Creates a data store of pass, failed, and pending example results

0 comments on commit 6c695c2

Please sign in to comment.