Sha256: df1b4879ddad76a57d4c552bc4563f8790bd6f978f91e5ce46c8b9bbafb025bd

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# Pickle == cucumber + factory
#
# = Usage
#   # in features/steps/_env.rb
#   require 'pickle/steps'
#
# If you need to configure pickle, do it like this
#
#   Pickle::Config.map 'I|me|my', :to => 'user: "me"'
#   require 'pickle/steps'
module Pickle
  module Version
    Major = 0
    Minor = 1
    Tiny  = 1
    
    String = [Major, Minor, Tiny].join('.')
  end
    
  module Config
    class << self
      attr_writer :model_names, :factory_names, :names, :mappings
      
      def model_names
        @model_names ||= Dir["#{RAILS_ROOT}/app/models/**/*.rb"].reject{|f| f =~ /observer.rb$/}.map{|f| f.sub("#{RAILS_ROOT}/app/models/",'').sub(".rb",'')}
      end

      def factory_names
        require 'factory_girl'
        @factory_names ||= Factory.factories.keys.map(&:to_s)
      end

      def names
        @names ||= (model_names | factory_names)
      end
      
      def mappings
        @mappings ||= []
      end
      
      def map(search, options)
        raise ArgumentError, "Usage: map 'search', :to => 'replace'" unless search.is_a?(String) && options[:to].is_a?(String)
        self.mappings << [search, options[:to]]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ianwhite-pickle-0.1.1 lib/pickle.rb