Sha256: 19e7e471b9e4e191991f673a053aba2d6b53a7008d9ca7c52fe3e870cf1a24f1
Contents?: true
Size: 1.03 KB
Versions: 41
Compression:
Stored size: 1.03 KB
Contents
module Cucumber module JsSupport module JsSnippets PARAM_PATTERN = /"([^"]*)"/ ESCAPED_PARAM_PATTERN = '"([^\\"]*)"' def snippet_text(code_keyword, step_name, multiline_arg_class) escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/') escaped = escaped.gsub(PARAM_PATTERN, ESCAPED_PARAM_PATTERN) n = 0 block_args = escaped.scan(ESCAPED_PARAM_PATTERN).map do |a| n += 1 "arg#{n}" end block_args << multiline_arg_class.default_arg_name unless multiline_arg_class.nil? block_arg_string = block_args.empty? ? "" : "#{block_args.join(", ")}" multiline_class_comment = "" if(multiline_arg_class == Ast::Table) multiline_class_comment = "//#{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n" end "#{code_keyword}(/^#{escaped}$/, function(#{block_arg_string}){\n #{multiline_class_comment} //express the regexp above with the code you wish you had\n});" end end end end
Version data entries
41 entries across 41 versions & 8 rubygems
Version | Path |
---|---|
cucumber-0.9.4 | lib/cucumber/js_support/js_snippets.rb |