Class: FeatureGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_feature_fileObject



9
10
11
12
13
14
15
16
17
18
19
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
52
53
54
55
56
57
58
59
60
# File 'lib/generators/feature_generator.rb', line 9

def create_feature_file
  if options['language'] == 'pt'
    if options['scaffold']
      template = "Funcionalidade: #{file_name}
Como [stakeholder]
Para que eu [funcionalidade]
Eu quero [finalidade]\n
#index
Cenário: Listar todos os #{file_name.pluralize}\n
#create
Cenário: Criar um #{file_name}\n
#show
Cenário: Mostrar um #{file_name}\n
#edit
Cenário: Editar um #{file_name}\n
#destroy
Cenário: Deletar um #{file_name}\n"
    else
      template = "Funcionalidade: #{file_name}
Como [stakeholder]
Para que eu [funcionalidade]
Eu quero [finalidade]\n"
    end
  else
    if options['scaffold']
      template = "Feature: #{file_name}
As a [stakeholder]
So that I [functionality]
I want to [goal]\n
#index
Scenario: List all #{file_name.pluralize}\n
#create
Scenario: Create a #{file_name}\n
#show
Scenario: Show a #{file_name}\n
#edit
Scenario: Edit a #{file_name}\n
#destroy
Scenario: Delete a #{file_name}\n"
    else
      template = "Feature: #{file_name}
As a [stakeholder]
So that I [functionality]
I want to [goal]\n"
    end
  end
  if options['folder']
    create_file "features/#{options['folder']}/#{file_name}.feature", "#language: #{options['language']}\n#encoding: utf-8\n\n#{template}"
  else
    create_file "features/#{file_name}.feature", "#language: #{options['language']}\n#encoding: utf-8\n\n@#{file_name}\n#{template}"
  end
end

#create_feature_steps_fileObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/generators/feature_generator.rb', line 62

def create_feature_steps_file
  if options['folder']
    if options['scaffold']
      create_file "features/step_definitions/#{options['folder']}/#{file_name}_steps.rb","# This is the steps file referred to #{file_name} feature\n# Place your code relative to that feature here\n
#index steps\n
#create steps\n
#show steps\n
#edit steps\n
#destroy steps\n"
    else
      create_file "features/step_definitions/#{options['folder']}/#{file_name}_steps.rb","# This is the steps file referred to #{file_name} feature\n# Place your code relative to that feature here"
    end
  else
    if options['scaffold']
      create_file "features/step_definitions/#{file_name}_steps.rb","# This is the steps file referred to #{file_name} feature\n# Place your code relative to that feature here\n
#index steps\n
#create steps\n
#show steps\n
#edit steps\n
#destroy steps\n"
    else
      create_file "features/step_definitions/#{file_name}_steps.rb","# This is the steps file referred to #{file_name} feature\n# Place your code relative to that feature here"
    end
  end
end