Class: CucumberScaffold::FeatureGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- CucumberScaffold::FeatureGenerator
- Defined in:
- lib/generators/cucumber_scaffold/feature/feature_generator.rb
Constant Summary collapse
- INDENT =
" "
- LINE_BREAK_WITH_INDENT =
"\n#{INDENT}"
- LINE_BREAK_WITH_INDENT_COMMENTED =
"\n#{INDENT}# "
Instance Method Summary collapse
- #do_it ⇒ Object
-
#initialize(args, *options) ⇒ FeatureGenerator
constructor
A new instance of FeatureGenerator.
Constructor Details
#initialize(args, *options) ⇒ FeatureGenerator
Returns a new instance of FeatureGenerator.
12 13 14 15 16 17 18 |
# File 'lib/generators/cucumber_scaffold/feature/feature_generator.rb', line 12 def initialize(args, *) super args.shift @args = args # seems to be a conflict if I call this @options @x_options = end |
Instance Method Details
#do_it ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/cucumber_scaffold/feature/feature_generator.rb', line 20 def do_it @attributes = [] @args.each do |param_pair| name, type = param_pair.split(':') @attributes << { name => type } end template('feature.feature', "features/manage_#{plural}.feature") template('steps.rb', "features/step_definitions/#{singular}_steps.rb") extra_paths = <<EOF when /edit page for that #{singular.humanize.downcase}/ raise 'no #{singular.humanize.downcase}' unless @#{singular} edit_#{singular}_path(@#{singular}) when /page for that #{singular.humanize.downcase}/ raise 'no #{singular.humanize.downcase}' unless @#{singular} #{singular}_path(@#{singular}) when /edit page for the (\\d+)(?:st|nd|rd|th) #{singular.humanize.downcase}/ raise 'no #{plural.humanize.downcase}' unless @#{plural} nth_#{singular} = @#{plural}[$1.to_i - 1] edit_#{singular}_path(nth_#{singular}) when /page for the (\\d+)(?:st|nd|rd|th) #{singular.humanize.downcase}/ raise 'no #{plural.humanize.downcase}' unless @#{plural} nth_#{singular} = @#{plural}[$1.to_i - 1] #{singular}_path(nth_#{singular}) EOF gsub_file 'features/support/paths.rb', /'\/'/mi do |match| "#{match}\n" + extra_paths end end |