Skip to content

Instantly share code, notes, and snippets.

@enkessler
Created May 9, 2013 19:07
Show Gist options
  • Save enkessler/5549737 to your computer and use it in GitHub Desktop.
Save enkessler/5549737 to your computer and use it in GitHub Desktop.
Recreating a step smelling bug in cuke_sniffer.
module CukeSniffer
module RuleConfig
FATAL = 100 #will prevent suite from executing properly
ERROR = 25 #will cause problem with debugging
WARNING = 10 #readibility/misuse of cucumber
INFO = 1 #Small improvements that can be made
OUR_RULES = {
:something_wrong => {
:enabled => true,
:phrase => "Something is wrong here.",
:score => ERROR,
}
}
RULES.update(OUR_RULES)
end
end
module CukeSniffer
class StepDefinition
def evaluate_score
super
rule_no_code
rule_too_many_parameters
rule_nested_steps
rule_recursive_nested_step
rule_commented_code
rule_lazy_debugging
rule_pending
rule_todo
sleep_rules
# Our new rules
rule_something_wrong
end
def rule_something_wrong
code.each do |line|
if line =~ /@bad_stuff/
store_rule(RULES[:something_wrong])
return
end
end
end
end
end
Given /a dead step/ do
@bad_stuff
end
Given /ghvh / do
this_method_is_defined_in_a_step_file
end
def this_method_is_defined_in_a_step_file
@bad_stuff
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment