Class: Cucumber::Formatter::StepdefsJson

Inherits:
Usage
  • Object
show all
Defined in:
lib/cuke-inspector/formatter/stepdefs_json.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extract_text_from_regexp(regexp) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/cuke-inspector/formatter/stepdefs_json.rb', line 24

def self.extract_text_from_regexp(regexp)
  prompt = '??'
  regexp.sub!(/^\/\^?/, '')
  regexp.sub!(/\$?\/$/, '')
  regexp.gsub!(/\(\[\^\\?\"\]\*\??\)/, prompt)
  regexp.gsub!('(.*)', prompt)
  regexp.gsub!('\/([^\/]*)\/', "/#{prompt}/")
  return PickleSanitizer.unpickle(regexp)
end

Instance Method Details

#build_regexp_usage_structureObject

a list of matches as value

What we want is to export is a hash with the step regexp as the key and a uniquified sorted list of steps as the value



14
15
16
17
18
19
20
21
22
# File 'lib/cuke-inspector/formatter/stepdefs_json.rb', line 14

def build_regexp_usage_structure
  regexp_uses_hash = {}
  @stepdef_to_match.to_a.each do |step_matches_pair|
    step_text = StepdefsJson.extract_text_from_regexp(step_matches_pair[0].regexp_source)
    matches = step_matches_pair[1].map{|m| m[:step_match].format_args}.uniq.sort
    regexp_uses_hash[step_text] = matches
  end
  json = regexp_uses_hash
end


37
38
39
40
# File 'lib/cuke-inspector/formatter/stepdefs_json.rb', line 37

def print_summary(features)
  add_unused_stepdefs
  @io.print "cucumberStepCompletion.cucumberSteps = " + build_regexp_usage_structure.to_json
end

#progress(status) ⇒ Object



34
35
# File 'lib/cuke-inspector/formatter/stepdefs_json.rb', line 34

def progress(status)
end