Sha256: b61c81482824057edb78ccea1ec3c45fbf5f3456e96645aeb3d9af7e10006f60
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
module Blueprints # A helper module that should be included in test framework. Adds methods <tt>build</tt> and <tt>demolish</tt> module Helper # Builds one or more blueprints by their names. You can pass names as symbols or strings. You can also pass additional # options hash which will be available by calling <tt>options</tt> in blueprint block. Returns result of blueprint block. # # build :apple and orange blueprints # build :apple, :orange # # # build :apple scenario with additional options # build :apple => {:color => 'red'} # # # options can also be passed for several blueprints # build :pear, :apple => {:color => 'red'}, :orange => {:color => 'orange'} def build_plan(*names) returning(Namespace.root.build(*names)) { Namespace.root.copy_ivars(self) } end alias :build :build_plan # Clears all tables in database. You can pass table names to clear only those tables. You can also pass <tt>:undo</tt> option # to remove scenarios from built scenarios cache. # # TODO: add sample usage def demolish(*args) options = args.extract_options! Blueprints.delete_tables(*args) if options[:undo] == :all Namespace.root.executed_plans.clear else undo = [options[:undo]].flatten.compact.collect {|bp| bp.to_s } unless (not_found = undo - Namespace.root.executed_plans.to_a).blank? raise(PlanNotFoundError, not_found) end Namespace.root.executed_plans -= undo end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
blueprints-0.5.1 | lib/blueprints/helper.rb |
blueprints-0.5.0 | lib/blueprints/helper.rb |