Sha256: 3440d96efafbf8b2bc2139f8bc1a3fc787b8cb522c8a53964f8845c77f03db78
Contents?: true
Size: 1.2 KB
Versions: 7
Compression:
Stored size: 1.2 KB
Contents
# This generator creates a new 'scenario' class ScenarioGenerator < Rails::Generator::Base attr_accessor :name_of_scenario_to_create, :name_of_scenario_file_to_create # `./script/generate scenario foo` will result in: # # runtime_args: ['foo'] # runtime_options: {:quiet=>false, :generator=>"scenario", :command=>:create, :collision=>:ask} # def initialize(runtime_args, runtime_options = {}) setup_rails_to_run_scenarios @name_of_scenario_to_create = runtime_args.join(' ') @name_of_scenario_file_to_create = runtime_args.join('_').downcase super end # this should be done by ./script/generate blackbox def setup_rails_to_run_scenarios rakefile = File.join RAILS_ROOT, 'Rakefile' if File.file? rakefile source = File.read rakefile unless source =~ /require .scenarios.tasks./ File.open( rakefile, 'a' ) do |f| f << %[require 'scenarios/tasks'] end end end end def manifest record do |m| m.directory 'scenarios' m.template 'scenario.erb', "scenarios/#{ name_of_scenario_file_to_create }.rb" end end protected def banner "Usage: #{$0} _scenario Name of Scenario to Create" end end
Version data entries
7 entries across 7 versions & 3 rubygems