Sha256: 23ba0c5c16fa78d6ca3d9ff23ccdcd1ce5bc03c01cd9fdfdc39ac69b9695117d

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require "rbconfig"
 
# This generator bootstraps a Rails project for use with Cucumber
class CucumberGenerator < Rails::Generator::Base  
  DEFAULT_SHEBANG = File.join(Config::CONFIG["bindir"],
                              Config::CONFIG["ruby_install_name"])
  
  attr_reader :language
  
  def initialize(runtime_args, runtime_options = {})
    super
    @features_path = "features"
  end  
  
  def manifest 
    if options[:language]
      @language = options[:language]
      set_language(@language)
    end
    record do |m|
      m.directory  File.join(@features_path, "step_definitions")
      m.file "webrat_steps.rb", File.join(@features_path, "step_definitions", "webrat_steps.rb")
 
      m.directory "features/support"
      m.file "env.rb", "features/support/env.rb"
      m.file "paths.rb", "features/support/paths.rb"
 
      m.directory "lib/tasks"
      m.template "cucumber.rake", "lib/tasks/cucumber.rake"
 
      m.file "cucumber", "script/cucumber", {
        :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
      }
    end
  end
 
protected
 
  def banner
    "Usage: #{$0} cucumber"
  end
    
  def add_options!(opt)
    opt.separator ""
    opt.separator "Options:"
    opt.on("-l", "--language=lang", String, "Use a [language] subdirectoy in /features.") { |v| options[:language] = v }
   end
   
  # Load up the transations for the passed language, and modify the features_path accordingly
  def set_language(language)
    @features_path = File.join(@features_path, language)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kosmas58-cucumber-0.1.99.21 rails_generators/cucumber/cucumber_generator.rb