Sha256: 8a18a69aec3a2f812374326032a73889a6d0627924fe545cc28dbf7634f712af

Contents?: true

Size: 1.84 KB

Versions: 20

Compression:

Stored size: 1.84 KB

Contents

require 'rbconfig'
require 'cucumber/version'

# 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_accessor :framework

  def manifest
    record do |m|
      m.directory 'features/step_definitions'
      m.template  'webrat_steps.rb', 'features/step_definitions/webrat_steps.rb'
      m.template  'cucumber_environment.rb', 'config/environments/cucumber.rb',
        :assigns => { :cucumber_version => ::Cucumber::VERSION::STRING }

      m.gsub_file 'config/database.yml', /test:.*\n/, "test: &TEST\n"
      m.gsub_file 'config/database.yml', /\z/, "\ncucumber:\n  <<: *TEST"

      m.directory 'features/support'

      if options[:spork]
        m.template  'spork_env.rb',     'features/support/env.rb'
      else
        m.template  'env.rb',           'features/support/env.rb'
      end

      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

  def framework
    options[:framework] || :rspec
  end

protected

  def banner
    "Usage: #{$0} cucumber"
  end

  def add_options!(opt)
    opt.separator ''
    opt.separator 'Options:'
    opt.on('--rspec', 'Setup cucumber for use with RSpec (default)') do |value|
      options[:framework] = :rspec
    end

    opt.on('--testunit', 'Setup cucumber for use with test/unit') do |value|
      options[:framework] = :testunit
    end

    opt.on('--spork', 'Setup cucumber for use with Spork') do |value|
      options[:spork] = true
    end
  end

end

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.3.10 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.11.1 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.11.200907091518 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.11.3 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.11.5 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.11.6 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.11 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.9.5 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.90 rails_generators/cucumber/cucumber_generator.rb
aslakhellesoy-cucumber-0.3.92 rails_generators/cucumber/cucumber_generator.rb
jwilger-cucumber-0.3.11.200906161550 rails_generators/cucumber/cucumber_generator.rb
jwilger-cucumber-0.3.11.200907091518 rails_generators/cucumber/cucumber_generator.rb
square-cucumber-0.3.12.2 rails_generators/cucumber/cucumber_generator.rb
squirrel-cucumber-0.3.12.1 rails_generators/cucumber/cucumber_generator.rb
squirrel-cucumber-0.3.12 rails_generators/cucumber/cucumber_generator.rb
cucumber-0.3.90 rails_generators/cucumber/cucumber_generator.rb
cucumber-0.3.91 rails_generators/cucumber/cucumber_generator.rb
cucumber-0.3.92 rails_generators/cucumber/cucumber_generator.rb
cucumber-0.3.10 rails_generators/cucumber/cucumber_generator.rb
cucumber-0.3.11 rails_generators/cucumber/cucumber_generator.rb