-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCriaAutomatico.ruby
80 lines (58 loc) · 2.45 KB
/
CriaAutomatico.ruby
1
2
3
4
5
6
7
8
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def pastasIniciantes(opcaoMenu,pasta)
system("cd #{opcaoMenu} ; mkdir #{pasta} ; cd #{pasta} ; cucumber --init ; mkdir results; mkdir Downloads ; mkdir reports ; ")
system("cd support_base ; cp cucumber.yml ../#{opcaoMenu}/#{pasta} ; cp idiomas_script.rb ../#{opcaoMenu}/#{pasta} ; ")
system("cd #{opcaoMenu}/#{pasta}/features ; mkdir pages ; mkdir specs ;" )
system("cd #{opcaoMenu}/#{pasta}/features/step_definitions ; touch #{pasta}.rb ;" )
system("cd #{opcaoMenu}/#{pasta}/features/pages ; touch #{pasta}_elementos_page.rb")
system("cd #{opcaoMenu}/#{pasta}/features/pages ; touch #{pasta}_page.rb")
system("cd #{opcaoMenu}/#{pasta}/features/specs ; touch #{pasta}.feature")
editandoArquivos(opcaoMenu,pasta)
end
def editandoArquivos(opMenu, pasta)
env = File.open("#{opMenu}/#{pasta}/features/support/env.rb",'w')
env.write('require_relative "../../../../support_base/env.rb"')
pageElementos = File.open("#{opMenu}/#{pasta}/features/pages/#{pasta}_elementos_page.rb", 'w')
pageElementos.write(" class Elementos_#{pasta} < SitePrism::Page
set_url '# {CONFIG['url_7112']}'
def variaveisMap(var)
variaveis = {
}
if var.kind_of?(Array)
outro = []
for i in var
outro << variaveis[:'# {i}']
end
return outro
else
return variaveis[:'# {var}']
end
end
end"
)
pageFuncoes = File.open("#{opMenu}/#{pasta}/features/pages/#{pasta}_page.rb", 'w')
pageFuncoes.write("class #{pasta.capitalize} < Elementos_#{pasta}
include Capybara::DSL
include RSpec::Matchers
end")
specs = File.open("#{opMenu}/#{pasta}/features/specs/#{pasta}.feature", 'w')
specs.write("# language: pt")
end
puts 'Selecione uma opção do menu'
@opcaoMenu = gets.chomp()
puts 'Selecione uma tela'
@pasta = gets.chomp()
@pasta = @pasta.downcase().gsub(' ',"_")
@opcaoMenu = @opcaoMenu.downcase().gsub(' ',"_")
if File.exist?(@opcaoMenu)
if File.exist?("#{@opcaoMenu}/#{@pasta}")
puts "ja tem essa pasta"
system("exit ;")
else
pastasIniciantes(@opcaoMenu,@pasta)
end
else
system("mkdir #{@opcaoMenu} ; ")
pastasIniciantes(@opcaoMenu,@pasta)
end
puts("olhar novamente a tela de #{@tela}_elementos_page, é necessario colocar em ordem as variaveis com '# {alguacoisa}' e o set_url")
puts("implantar (se necessario em Page Helper)")