Sha256: 684d9038a40d9de14168d189a5dd84a5b105198b9e8e78006e85a8c43539c0bb

Contents?: true

Size: 1.43 KB

Versions: 33

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

33 entries across 31 versions & 8 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/doc_string.rb
candlepin-api-0.4.0 bundle/ruby/gems/cucumber-1.2.1/lib/cucumber/ast/doc_string.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/cucumber-1.2.1/lib/cucumber/ast/doc_string.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/doc_string.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/doc_string.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/lib/cucumber/ast/doc_string.rb
casecumber-1.2.1.cb2 lib/cucumber/ast/doc_string.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/lib/cucumber/ast/doc_string.rb
cucumber-1.2.1 lib/cucumber/ast/doc_string.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
ftl-0.2.0 vendor/bundle/gems/cucumber-1.2.0/lib/cucumber/ast/doc_string.rb
cucumber-1.2.0 lib/cucumber/ast/doc_string.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/doc_string.rb
cucumber-1.1.9 lib/cucumber/ast/doc_string.rb