crtu 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +16 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +4 -1
- data/Gemfile +2 -0
- data/README.md +35 -4
- data/crtu.gemspec +5 -5
- data/lib/crtu/utils/logger.rb +28 -14
- data/lib/crtu/version.rb +1 -1
- data/lib/tasks/cucumber_tasks.rake +7 -7
- metadata +10 -2
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
[](https://badge.fury.io/rb/crtu)
|
2
2
|
[](https://travis-ci.org/Th33x1l3/CRTU)
|
3
3
|
|
4
|
-
CRTU
|
4
|
+
[](https://codeclimate.com/github/Th33x1l3/CRTU)
|
5
|
+
[](https://codeclimate.com/github/Th33x1l3/CRTU/coverage)
|
6
|
+
[](https://codeclimate.com/github/Th33x1l3/CRTU)
|
7
|
+
|
8
|
+
#CRTU
|
5
9
|
|
6
10
|
Cucumber Ruby Test Utilities
|
7
11
|
|
@@ -11,14 +15,41 @@ For now it has:
|
|
11
15
|
|
12
16
|
Some rake tasks
|
13
17
|
Singleton logger utilitie defined with log4r
|
18
|
+
|
19
|
+
# Usage
|
20
|
+
|
21
|
+
## Rake Tasks
|
22
|
+
To use the rake tasks insert the following lines on your Rakefile:
|
23
|
+
|
24
|
+
```
|
25
|
+
spec = Gem::Specification.find_by_name('crtu')
|
26
|
+
load "#{spec.gem_dir}/lib/tasks/cucumber_tasks.rake"
|
27
|
+
|
28
|
+
```
|
29
|
+
|
30
|
+
## Loggers
|
31
|
+
Add the Utils module to the world, then you can call
|
32
|
+
|
33
|
+
if in a class add `include Utils::LocalLogger`
|
34
|
+
then you can call
|
35
|
+
```
|
36
|
+
console_logger.<level> "MESSAGE TO LOG"
|
37
|
+
file_logger.<level> "MESSAGE TO LOG"
|
38
|
+
all_logger.<level> "MESSAGE TO LOG"
|
39
|
+
```
|
40
|
+
|
41
|
+
- `console_logger` logs message only to stdout
|
42
|
+
- `file_logger` logs to a file
|
43
|
+
- `all_logger` logs to both console and file
|
14
44
|
|
45
|
+
# Contributing
|
15
46
|
|
16
|
-
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Th33x1l3/crtu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
17
48
|
|
18
|
-
|
49
|
+
Aside from that feel free to send pull requests with useful code that you want to share.
|
19
50
|
|
20
51
|
|
21
|
-
|
52
|
+
# License
|
22
53
|
|
23
54
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
24
55
|
|
data/crtu.gemspec
CHANGED
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
26
|
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
27
|
+
spec.add_runtime_dependency 'log4r', '~> 1.1', '>= 1.1.10'
|
28
|
+
spec.add_runtime_dependency 'cucumber', '~> 2.3', '> 2.3.0'
|
29
29
|
|
30
30
|
end
|
data/lib/crtu/utils/logger.rb
CHANGED
@@ -2,10 +2,12 @@ require 'rubygems'
|
|
2
2
|
require 'singleton'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'log4r'
|
5
|
+
require 'tmpdir'
|
5
6
|
include Log4r
|
6
7
|
|
7
8
|
GLOBAL_LOGGER_FOLDER = File.join(Dir.pwd, 'logs')
|
8
9
|
GLOBAL_LOGGER_LOG_FILE = File.join(GLOBAL_LOGGER_FOLDER, 'logfile.log')
|
10
|
+
SECONDS_IN_DAY ||= 86400
|
9
11
|
|
10
12
|
class GlobalLogger
|
11
13
|
include Singleton
|
@@ -24,17 +26,21 @@ class GlobalLogger
|
|
24
26
|
FileUtils.mkdir_p(GLOBAL_LOGGER_FOLDER)
|
25
27
|
end
|
26
28
|
|
27
|
-
@global_console_logger= Log4r::Logger.new(
|
28
|
-
@global_file_logger = Log4r::Logger.new(
|
29
|
-
@global_mix_logger = Log4r::Logger.new(
|
29
|
+
@global_console_logger= Log4r::Logger.new('GlobalLoggerConsole')
|
30
|
+
@global_file_logger = Log4r::Logger.new('GlobalLoggerFile')
|
31
|
+
@global_mix_logger = Log4r::Logger.new('GlobalLoggerConsoleAndFile')
|
30
32
|
|
31
33
|
pf = PatternFormatter.new(:pattern => "[%l] @ %d : %M")
|
32
34
|
|
33
|
-
so = StdoutOutputter.new(
|
35
|
+
so = StdoutOutputter.new('console', :formatter => pf)
|
34
36
|
@global_console_logger.outputters << so
|
35
37
|
@global_console_logger.level = DEBUG
|
36
38
|
|
37
|
-
fo =
|
39
|
+
fo = RollingFileOutputter .new('f1',
|
40
|
+
filename: GLOBAL_LOGGER_LOG_FILE,
|
41
|
+
trunc: false,
|
42
|
+
:formatter => pf,
|
43
|
+
maxtime: SECONDS_IN_DAY )
|
38
44
|
@global_file_logger.outputters << fo
|
39
45
|
@global_file_logger.level = DEBUG
|
40
46
|
|
@@ -89,10 +95,10 @@ module Utils
|
|
89
95
|
# Class console logger. The messages only go to the stdout
|
90
96
|
# No message is saved to file
|
91
97
|
def console_logger
|
92
|
-
@logger = Log4r::Logger.new(
|
98
|
+
@logger = Log4r::Logger.new('LocalLoggerConsole')
|
93
99
|
pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M")
|
94
100
|
|
95
|
-
so = StdoutOutputter.new(
|
101
|
+
so = StdoutOutputter.new('console', :formatter => pf)
|
96
102
|
@logger.outputters << so
|
97
103
|
@logger.level = DEBUG
|
98
104
|
@logger
|
@@ -101,11 +107,15 @@ module Utils
|
|
101
107
|
# Class simple file logger. Message is stored in file, but
|
102
108
|
# it does not appear on stdout
|
103
109
|
def file_logger
|
104
|
-
log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ?
|
105
|
-
@logger = Log4r::Logger.new(
|
110
|
+
log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ? File.join(Dir.tmpdir , "#{self.class.to_s}.log") : LOCAL_LOGGER_LOG_FILE
|
111
|
+
@logger = Log4r::Logger.new('LocalLoggerFile')
|
106
112
|
pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M")
|
107
113
|
|
108
|
-
fo =
|
114
|
+
fo = RollingFileOutputter.new('f1',
|
115
|
+
filename: log_file,
|
116
|
+
trunc: false,
|
117
|
+
formatter: pf,
|
118
|
+
maxtime: SECONDS_IN_DAY)
|
109
119
|
@logger.outputters << fo
|
110
120
|
@logger.level = DEBUG
|
111
121
|
@logger
|
@@ -114,12 +124,16 @@ module Utils
|
|
114
124
|
|
115
125
|
# Class wide console and file logger. Message appears on console output and it's stored on file
|
116
126
|
def all_logger
|
117
|
-
log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ?
|
118
|
-
@logger = Log4r::Logger.new(
|
127
|
+
log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ? File.join(Dir.tmpdir , "#{self.class.to_s}.log") : LOCAL_LOGGER_LOG_FILE
|
128
|
+
@logger = Log4r::Logger.new('LocalLoggerConsoleAndFile')
|
119
129
|
pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M")
|
120
130
|
|
121
|
-
so = StdoutOutputter.new(
|
122
|
-
fo =
|
131
|
+
so = StdoutOutputter.new('console', :formatter => pf)
|
132
|
+
fo = RollingFileOutputter.new('f1',
|
133
|
+
filename: log_file,
|
134
|
+
trunc: false,
|
135
|
+
formatter: pf,
|
136
|
+
maxtime: SECONDS_IN_DAY)
|
123
137
|
|
124
138
|
@logger.outputters << so
|
125
139
|
@logger.outputters << fo
|
data/lib/crtu/version.rb
CHANGED
@@ -54,7 +54,7 @@ namespace :features do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
|
57
|
-
desc
|
57
|
+
desc 'Run features with given tags - OR joining'
|
58
58
|
task :run_with_tags, [:tags] do |t,args|
|
59
59
|
if args[:tags].is_a?(String)
|
60
60
|
tags_line = args[:tags]
|
@@ -67,15 +67,15 @@ namespace :features do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
desc
|
70
|
+
desc 'Run complete feature build'
|
71
71
|
task :cruise do
|
72
|
-
finished_successful = run_and_check_for_exception(
|
73
|
-
in_progress_successful = run_and_check_for_exception(
|
72
|
+
finished_successful = run_and_check_for_exception('finished')
|
73
|
+
in_progress_successful = run_and_check_for_exception('in_progress')
|
74
74
|
|
75
75
|
unless finished_successful && in_progress_successful
|
76
76
|
puts
|
77
|
-
puts(
|
78
|
-
puts(
|
77
|
+
puts('Finished features had failing steps') unless finished_successful
|
78
|
+
puts('In-progress Scenario/s passed when they should fail or be pending') unless in_progress_successful
|
79
79
|
puts
|
80
80
|
raise BuildFailure
|
81
81
|
end
|
@@ -85,7 +85,7 @@ def run_and_check_for_exception(task_name)
|
|
85
85
|
puts "*** Running #{task_name} features ***"
|
86
86
|
begin
|
87
87
|
Rake::Task["features:#{task_name}"].invoke
|
88
|
-
rescue
|
88
|
+
rescue StandardError
|
89
89
|
return false
|
90
90
|
end
|
91
91
|
true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crtu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fábio André Ramos Rodrigues
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,6 +57,9 @@ dependencies:
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
- - ">="
|
60
63
|
- !ruby/object:Gem::Version
|
61
64
|
version: 1.1.10
|
62
65
|
type: :runtime
|
@@ -64,6 +67,9 @@ dependencies:
|
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
69
|
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '1.1'
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: 1.1.10
|
69
75
|
- !ruby/object:Gem::Dependency
|
@@ -93,7 +99,9 @@ executables: []
|
|
93
99
|
extensions: []
|
94
100
|
extra_rdoc_files: []
|
95
101
|
files:
|
102
|
+
- ".codeclimate.yml"
|
96
103
|
- ".gitignore"
|
104
|
+
- ".rubocop.yml"
|
97
105
|
- ".travis.yml"
|
98
106
|
- CODE_OF_CONDUCT.md
|
99
107
|
- Gemfile
|