From 929e82cd5597b893719e3fe2580acb2ad3c9f176 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 26 Jul 2013 15:42:28 +0000 Subject: [PATCH] Add monkey patch to fix cucumber docstrings: Cucumber chomp the last \n from multiline strings (docstrings), this monkey patch modify Cucumber::Ast::DocString constructor to add the missing ending new line character and Cucumber::Formatter::Pretty#doc_string to remove it from the output. --- features/support/env.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/features/support/env.rb b/features/support/env.rb index 06d38ec..dc82856 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -14,3 +14,28 @@ module Cucumber end require 'aruba/cucumber' + + +require 'cucumber/formatter/pretty' + +module Cucumber + module Ast + class DocString + alias :old_initialize :initialize + + def initialize(string, content_type) + old_initialize(string + "\n", content_type) + end + end + end + + module Formatter + class Pretty + alias :old_doc_string :doc_string + + def doc_string(string) + old_doc_string(string.chomp) + end + end + end +end