lib/cucumber/rb_support/rb_world.rb in cucumber-0.8.5 vs lib/cucumber/rb_support/rb_world.rb in cucumber-0.8.6

- old
+ new

@@ -1,9 +1,13 @@ +require 'gherkin/formatter/ansi_escapes' + module Cucumber module RbSupport # All steps are run in the context of an object that extends this module. module RbWorld + include Gherkin::Formatter::AnsiEscapes + class << self def alias_adverb(adverb) alias_method adverb, :__cucumber_invoke end end @@ -30,39 +34,35 @@ # See StepMother#table def table(text_or_table, file=nil, line_offset=0) @__cucumber_step_mother.table(text_or_table, file, line_offset) end - # See StepMother#py_string - def py_string(string_with_triple_quotes, file=nil, line_offset=0) - @__cucumber_step_mother.py_string(string_with_triple_quotes, file, line_offset) + # See StepMother#doc_string + def doc_string(string_with_triple_quotes, file=nil, line_offset=0) + @__cucumber_step_mother.doc_string(string_with_triple_quotes, file, line_offset) end - # See StepMother#announce - def announce(announcement) - @__cucumber_step_mother.announce(announcement) + def announce(*messages) + STDERR.puts failed + "WARNING: #announce is deprecated. Use #puts instead:" + caller[0] + reset + puts(*messages) end + # See StepMother#puts + def puts(*messages) + @__cucumber_step_mother.puts(*messages) + end + # See StepMother#ask def ask(question, timeout_seconds=60) @__cucumber_step_mother.ask(question, timeout_seconds) end # See StepMother#embed - def embed(file, mime_type) - @__cucumber_step_mother.embed(file, mime_type) + def embed(file, mime_type, label='Screenshot') + @__cucumber_step_mother.embed(file, mime_type, label) end - # Prints out the world class, followed by all included modules. - def announce_world - announce "WORLD:\n #{self.class}" - world = self - (class << self; self; end).instance_eval do - world.announce " #{included_modules.join("\n ")}" - end - end - # Mark the matched step as pending. def pending(message = "TODO") if block_given? begin yield @@ -86,10 +86,18 @@ # A World object can have many references created by the user # or frameworks (Rails), so to avoid long waiting times on # such errors in World we define it to just return a simple String. # def inspect #:nodoc: - sprintf("#<%s:0x%x>", self.class, self.object_id) + modules = [self.class] + (class << self; self; end).instance_eval do + modules += included_modules + end + sprintf("#<%s:0x%x>", modules.join('+'), self.object_id) + end + + def to_s + inspect end end end end