Sha256: 0db47370e6a62c5b3a26bc288db1793374ac99f50704a77934296a0568abfe39

Contents?: true

Size: 1.43 KB

Versions: 27

Compression:

Stored size: 1.43 KB

Contents

module Cucumber
  module Ast
    # Represents an inline argument in a step. Example:
    #
    #   Given the message
    #     """
    #     I like
    #     Cucumber sandwich
    #     """
    #
    # The text between the pair of <tt>"""</tt> is stored inside a DocString,
    # which is yielded to the StepDefinition block as the last argument.
    #
    # 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 < String #:nodoc:
      attr_accessor :file

      def self.default_arg_name
        "string"
      end

      attr_reader :content_type

      def initialize(string, content_type)
        @content_type = content_type
        super string
      end

      def to_step_definition_arg
        self
      end

      def accept(visitor)
        return if Cucumber.wants_to_quit
        visitor.visit_doc_string(self)
      end

      def arguments_replaced(arguments) #:nodoc:
        string = self
        arguments.each do |name, value|
          value ||= ''
          string = string.gsub(name, value)
        end
        DocString.new(string, content_type)
      end

      def has_text?(text)
        index(text)
      end

      # For testing only
      def to_sexp #:nodoc:
        [:doc_string, to_step_definition_arg]
      end
    end
  end
end

Version data entries

27 entries across 25 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/cucumber-1.3.18/lib/cucumber/ast/doc_string.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/cucumber-1.3.16/lib/cucumber/ast/doc_string.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/cucumber-1.3.18/lib/cucumber/ast/doc_string.rb
cucumber-1.3.20 lib/cucumber/ast/doc_string.rb
cucumber-1.3.19 lib/cucumber/ast/doc_string.rb
cucumber-1.3.18 lib/cucumber/ast/doc_string.rb
cucumber-1.3.17 lib/cucumber/ast/doc_string.rb
cucumber-1.3.16 lib/cucumber/ast/doc_string.rb
cucumber-1.3.15 lib/cucumber/ast/doc_string.rb
cucumber-1.3.14 lib/cucumber/ast/doc_string.rb
cucumber-1.3.13 lib/cucumber/ast/doc_string.rb
cucumber-1.3.12 lib/cucumber/ast/doc_string.rb
cucumber-1.3.11 lib/cucumber/ast/doc_string.rb
cucumber-1.3.10 lib/cucumber/ast/doc_string.rb
cucumber-1.3.9 lib/cucumber/ast/doc_string.rb
cucumber-1.3.8 lib/cucumber/ast/doc_string.rb
cucumber-1.3.7 lib/cucumber/ast/doc_string.rb
cucumber-1.3.6 lib/cucumber/ast/doc_string.rb
cucumber-1.3.5 lib/cucumber/ast/doc_string.rb
cucumber-1.3.4 lib/cucumber/ast/doc_string.rb