Skip to content

Instantly share code, notes, and snippets.

@natritmeyer
Created December 12, 2011 18:20
Show Gist options
  • Save natritmeyer/1468432 to your computer and use it in GitHub Desktop.
Save natritmeyer/1468432 to your computer and use it in GitHub Desktop.
A cucumber formatter to allow doing stuff when a tag is first come across
#cucumber -f TestManagement::TagLogic -o /dev/null
module TestManagement
class TagLogic
#leave this alone...
def initialize(step_mother, io, options)
@old_tags = []
end
#leave this alone too...
def tag_name(tag)
is_new_tag = !@old_tags.include?(tag)
@old_tags << tag if is_new_tag
perform_logic_for(tag) if is_new_tag
end
#add your logic here!
def perform_logic_for tag_name
puts "I've just come across #{tag_name}, going to do something with it..."
# put your logic here
# eg:
case tag_name
when "@users"
#load up a bunch of users
when "@expired_account"
#load an expired account
when "@etc"
#do something
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment