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
|
# File 'lib/yattex.rb', line 2
def self.runTests
require 'rspec'
require 'json'
require 'fileutils'
require 'pathname'
@inputArray = [];
if(File.exist?('.yattex'))
FileUtils.remove_dir(".yattex")
end
Dir.mkdir(".yattex")
def self.getDecorators
value = ""
puts("Please Enter test decorator name: ")
value << gets
if(value.strip.empty?)
Yattex.getDecorators
else
@inputArray << value
Yattex.askToExit
end
end
def self.askToExit
value1 = ""
puts("Do you want to add more?(y/n)")
value1 << gets
value1 = value1.chomp
if ["y", "yes"].include?(value1.downcase)
Yattex.getDecorators
elsif ["n", "no"].include?(value1.downcase)
puts("Your entered decorators are : #{@inputArray.map!(&:chomp)}")
else
Yattex.askToExit
end
end
def self.makeGitFile
head_file = File.open(".git/HEAD", "r")
branch_name = head_file.read.strip.split("/").last
project_name = Pathname.pwd.basename
head_file.close
@git_info = {"Branch Name" => branch_name, "Project Name" => project_name}
File.open(".yattex/git.json", "w") do |f|
json = JSON.generate(@git_info)
f.write(json)
end
end
Yattex.getDecorators
json = JSON.generate(@inputArray)
File.open(".yattex/decorators.json", "w") do |f|
f.write(json)
end
Yattex.makeGitFile
RSpec.configuration.add_formatter('html', ".yattex/report.html")
spec_pattern = File.expand_path('spec/**/*_spec.rb')
spec_files = Dir.glob(spec_pattern)
RSpec::Core::Runner.run(spec_files)
end
|