Class: PickleGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/pickle_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ PickleGenerator

Returns a new instance of PickleGenerator.



12
13
14
15
16
17
18
19
# File 'lib/generators/pickle_generator.rb', line 12

def initialize(args = [], options = {}, config = {})
  super

  if self.options.paths? && !File.exists?("features/support/paths.rb")
    say "features/support/paths.rb not found, is your cucumber up to date?", :red
    exit
  end
end

Instance Method Details

#copy_email_steps_fileObject



44
45
46
47
48
# File 'lib/generators/pickle_generator.rb', line 44

def copy_email_steps_file
  return unless options.email?
  template "email_steps.rb", "features/step_definitions/email_steps.rb"
  template "email.rb", "features/support/email.rb"
end

#copy_paths_fileObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/pickle_generator.rb', line 31

def copy_paths_file
  return unless options.paths?

  current_paths = File.read("features/support/paths.rb")
  unless current_paths.include?('#{capture_model}')
    if current_paths =~ /^(.*)(\n\s+else\n\s+raise "Can't find.*".*$)/m
      @current_paths_header = $1
      @current_paths_footer = $2
    end
    template "paths.rb", "features/support/paths.rb"
  end
end

#copy_pickle_steps_fileObject



26
27
28
29
# File 'lib/generators/pickle_generator.rb', line 26

def copy_pickle_steps_file
  template "pickle_steps.rb", "features/step_definitions/pickle_steps.rb"
  template "pickle.rb", "features/support/pickle.rb"
end

#create_directoriesObject



21
22
23
24
# File 'lib/generators/pickle_generator.rb', line 21

def create_directories
  empty_directory "features/step_definitions"
  empty_directory "features/support"
end