From 3fc4b6c66d4eb245855df68118de9c703b87b658 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Tue, 7 Feb 2012 11:05:42 -0800 Subject: [PATCH] Expose AnsiEscapes methods on the class level as well, for easy calling without inclusion --- lib/gherkin/formatter/ansi_escapes.rb | 2 ++ spec/gherkin/formatter/ansi_escapes_spec.rb | 25 ++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/gherkin/formatter/ansi_escapes.rb b/lib/gherkin/formatter/ansi_escapes.rb index c9f71d5b..90cae666 100644 --- a/lib/gherkin/formatter/ansi_escapes.rb +++ b/lib/gherkin/formatter/ansi_escapes.rb @@ -90,6 +90,8 @@ def reset def up(n) "\e[#{n}A" end + + extend self end end end diff --git a/spec/gherkin/formatter/ansi_escapes_spec.rb b/spec/gherkin/formatter/ansi_escapes_spec.rb index c16bae55..6922baea 100644 --- a/spec/gherkin/formatter/ansi_escapes_spec.rb +++ b/spec/gherkin/formatter/ansi_escapes_spec.rb @@ -4,16 +4,29 @@ module Gherkin module Formatter describe AnsiEscapes do - include Gherkin::Formatter::AnsiEscapes + describe "instance methods" do + include AnsiEscapes - it "failed should be red" do - failed.should == "\e[31m" - end + it "failed should be red" do + failed.should == "\e[31m" + end - it "failed arg should be red bold" do - failed_arg.should == "\e[31m\e[1m" + it "failed_arg should be red bold" do + failed_arg.should == "\e[31m\e[1m" + end end + describe "class methods" do + subject { AnsiEscapes } + + it "failed should be red" do + subject.failed.should == "\e[31m" + end + + it "failed_arg should be red bold" do + subject.failed_arg.should == "\e[31m\e[1m" + end + end end end end