lib/cucumber/ast/doc_string.rb in cucumber-1.0.2 vs lib/cucumber/ast/doc_string.rb in cucumber-1.0.3

- old
+ new

@@ -14,62 +14,43 @@ # The StepDefinition can then access the String via the #to_s method. In the # example above, that would return: <tt>"I like\nCucumber sandwich"</tt> # # Note how the indentation from the source is stripped away. # - class DocString #:nodoc: - class Builder - attr_reader :string - - def initialize - @string = '' - end - - def doc_string(string, line_number) - @string = string - end - - def eof - end - end - + class DocString < String #:nodoc: attr_accessor :file def self.default_arg_name "string" end - def self.parse(text) - builder = Builder.new - lexer = Gherkin::I18nLexer.new(builder) - lexer.scan(text) - new(builder.string) - end + attr_reader :content_type - def initialize(string) - @string = string + def initialize(string, content_type) + @content_type = content_type + super string end def to_step_definition_arg - @string + self end def accept(visitor) return if Cucumber.wants_to_quit - visitor.visit_doc_string(@string) + visitor.visit_doc_string(self) end def arguments_replaced(arguments) #:nodoc: - string = @string + string = self arguments.each do |name, value| value ||= '' string = string.gsub(name, value) end - DocString.new(string) + DocString.new(string, content_type) end def has_text?(text) - @string.index(text) + index(text) end # For testing only def to_sexp #:nodoc: [:doc_string, to_step_definition_arg]