Created
March 22, 2016 04:32
-
-
Save ajesler/c07d50106745a84a64b0 to your computer and use it in GitHub Desktop.
Start of a helper for understanding cucumber specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CucumberStepDebugging | |
def print_step_definitions | |
step_definitions.each do |sdl| | |
puts "#{sdl.regexp_source} in #{sdl.file_colon_line}" | |
end | |
end | |
def step_definitions | |
language_map = @__cucumber_runtime.instance_variable_get("@support_code").instance_variable_get("@language_map") | |
step_definitions = language_map["rb"].instance_variable_get("@available_step_definition_hash").keys | |
end | |
def show_step_source | |
match = begin | |
@__cucumber_runtime.step_match(step_def) | |
rescue Cucumber::Undefined => e | |
nil | |
end | |
source = match.nil? ? "could not be found" : "is #{match.file_colon_line}" | |
puts "Source for step #{step_def} #{source}" | |
end | |
def steps_matching(search_regex) | |
# show all steps where the step definition regex is a match for the search regex | |
end | |
end | |
# TODO | |
# * Show options for each step definition | |
# https://marcclifton.wordpress.com/2013/10/11/list-all-cucumber-step-definitions/ | |
# https://gist.github.com/andrzejsliwa/778535 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment