Created
          February 7, 2011 20:16 
        
      - 
      
- 
        Save sleistner/815101 to your computer and use it in GitHub Desktop. 
    factory_girl cucumber step definitions using mongoid
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | FactoryGirl.factories.values.each do |factory| | |
| if factory.build_class.respond_to?(:fields) | |
| factory.build_class.fields.map(&:first).each do |field| | |
| human_field_name = field.downcase.gsub('_', ' ') | |
| Given /^an? #{factory.human_name} exists with an? #{human_field_name} of "([^"]*)"$/i do |value| | |
| Factory(factory.name, field => value) | |
| end | |
| Given /^(\d+) #{factory.human_name.pluralize} exist with an? #{human_field_name} of "([^"]*)"$/i do |count, value| | |
| count.to_i.times { Factory(factory.name, field => value) } | |
| end | |
| end | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment