class FeatureGenerator

Constants

ALL_ACTIONS

Public Instance Methods

feature() click to toggle source
# File lib/generators/feature/feature_generator.rb, line 18
def feature
  validate
  @user = User.new self, options[:user]
  create_steps_file
  actions.each do |action|
    @action = action
    create_feature(table_name, action)
    create_steps(action)
  end
end

Private Instance Methods

create_feature(name, action) click to toggle source
# File lib/generators/feature/feature_generator.rb, line 38
def create_feature(name, action)
  template File.join('features',"#{action}.feature"),
    "features/#{name}/#{action}.feature"
end
create_steps(action) click to toggle source
# File lib/generators/feature/feature_generator.rb, line 52
def create_steps(action)
  Object.const_get("#{action.capitalize}Steps").new(
    self, @user, steps_file_path
  ).create
end
create_steps_file() click to toggle source
# File lib/generators/feature/feature_generator.rb, line 43
def create_steps_file
  template File.join('step_definitions', 'blank_steps_file.rb'),
    steps_file_path
end
steps_file_path() click to toggle source
# File lib/generators/feature/feature_generator.rb, line 48
def steps_file_path
  "features/step_definitions/#{file_name}_steps.rb"
end
validate() click to toggle source
# File lib/generators/feature/feature_generator.rb, line 31
def validate
  actions.each do |action|
    fail "'#{action}' is not valid must " \
      "be one of #{ALL_ACTIONS}" unless ALL_ACTIONS.include? action
  end
end