Class: CucumberRailsTrainingWheels::FeatureGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/cucumber_rails_training_wheels/feature/feature_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#named_argsObject (readonly)

Returns the value of attribute named_args.



9
10
11
# File 'lib/generators/cucumber_rails_training_wheels/feature/feature_generator.rb', line 9

def named_args
  @named_args
end

Class Method Details



23
24
25
# File 'lib/generators/cucumber_rails_training_wheels/feature/feature_generator.rb', line 23

def self.banner
  "#{$0} cucumber:feature ModelName [field:type, field:type]"
end

Instance Method Details

#generateObject



15
16
17
18
19
20
21
# File 'lib/generators/cucumber_rails_training_wheels/feature/feature_generator.rb', line 15

def generate
  template 'feature.erb', "features/manage_#{plural_name}.feature"
  template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
  gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
    "#{match}\n    when /the new #{singular_name} page/\n      new_#{singular_name}_path\n"
  end
end

#parse_fieldsObject



11
12
13
# File 'lib/generators/cucumber_rails_training_wheels/feature/feature_generator.rb', line 11

def parse_fields
  @named_args = @fields.nil? ? [] : @fields.map { |arg| NamedArg.new(arg) }
end