crtu 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88c62b01668cad038d2edd7d4d9ac51e986ded33
4
+ data.tar.gz: 3c1feda010457b8aaf07c3c31f7a3b98193d4610
5
+ SHA512:
6
+ metadata.gz: 27d90120dc1b5b99268332e1829a4d69eeecc555c2219dc3711c7dbcb13b4c07191b3d91c19ac69c3bf4b6bfcb10a1b2e959949222fd0e1c27cc76c582cfc278
7
+ data.tar.gz: c3d253b3631a865f7800108b6fb5eed095444e7a5aef027f1b44bed1201fe8bd022d36d4a37ce6bcf47136c272746253bf523dfb68787fe45d02650185907957
data/.gitignore ADDED
@@ -0,0 +1,51 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+ *.idea
13
+
14
+ # Used by dotenv library to load environment variables.
15
+ # .env
16
+
17
+ ## Specific to RubyMotion:
18
+ .dat*
19
+ .repl_history
20
+ build/
21
+ *.bridgesupport
22
+ build-iPhoneOS/
23
+ build-iPhoneSimulator/
24
+
25
+ ## Specific to RubyMotion (use of CocoaPods):
26
+ #
27
+ # We recommend against adding the Pods directory to your .gitignore. However
28
+ # you should judge for yourself, the pros and cons are mentioned at:
29
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
30
+ #
31
+ # vendor/Pods/
32
+
33
+ ## Documentation cache and generated files:
34
+ /.yardoc/
35
+ /_yardoc/
36
+ /doc/
37
+ /rdoc/
38
+
39
+ ## Environment normalization:
40
+ /.bundle/
41
+ /vendor/bundle
42
+ /lib/bundler/man/
43
+
44
+ # for a library or gem, you might want to ignore these files since the code is
45
+ # intended to run in multiple environments; otherwise, check them in:
46
+ # Gemfile.lock
47
+ # .ruby-version
48
+ # .ruby-gemset
49
+
50
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
51
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at fabio_rodrigues@student-partners.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in crtu.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Th33x1l3
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ CRTU
2
+
3
+ Cucumber Ruby Test Utilities
4
+
5
+ Some assorted test utilities for those who do cucumber testing with ruby.
6
+
7
+ For now it has:
8
+
9
+ Some rake tasks
10
+ Singleton logger utilitie defined with log4r
11
+
12
+
13
+ ## Contributing
14
+
15
+ 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. Aside from that feel free to send pull requests with useful code that you want to share.
16
+
17
+
18
+ ## License
19
+
20
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
21
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ import "./lib/tasks/cucumber_tasks.rake"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "crtu"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/crtu.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'crtu/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "crtu"
8
+ spec.version = Crtu::VERSION
9
+ spec.authors = ["Fábio André Ramos Rodrigues"]
10
+ spec.email = ["fabio_rodrigues@student-partners.com"]
11
+
12
+ spec.summary = %q{Cucumber Ruby Test Utilities}
13
+ spec.description = %q{Useful Cucumber and ruby test utilities,like loggers, rake tasks, etc...}
14
+ spec.homepage = "https://github.com/Th33x1l3/CRTU"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
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
+
27
+ spec.add_runtime_dependency "log4r", "~>1.1.10"
28
+ spec.add_runtime_dependency "cucumber", '~> 2.3', '> 2.3.0'
29
+
30
+ end
data/lib/crtu.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "crtu/version"
2
+
3
+ module Crtu
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,130 @@
1
+ require 'rubygems'
2
+ require 'singleton'
3
+ require 'fileutils'
4
+ require 'log4r'
5
+ include Log4r
6
+
7
+ GLOBAL_LOGGER_FOLDER = File.join(Dir.pwd, 'logs')
8
+ GLOBAL_LOGGER_LOG_FILE = File.join(GLOBAL_LOGGER_FOLDER, 'logfile.log')
9
+
10
+ class GlobalLogger
11
+ include Singleton
12
+
13
+ attr_reader :global_console_logger
14
+ attr_reader :global_file_logger
15
+ attr_reader :global_mix_logger
16
+
17
+ def initialize
18
+
19
+ # Chech if folder exists
20
+ # that way it creates the logs folder beforehand
21
+
22
+ dirname = File.dirname(GLOBAL_LOGGER_FOLDER)
23
+ unless File.directory?(dirname)
24
+ FileUtils.mkdir_p(GLOBAL_LOGGER_FOLDER)
25
+ end
26
+
27
+ @global_console_logger= Log4r::Logger.new("GlobalLoggerConsole")
28
+ @global_file_logger = Log4r::Logger.new("GlobalLoggerFile")
29
+ @global_mix_logger = Log4r::Logger.new("GlobalLoggerConsoleAndFile")
30
+
31
+ pf = PatternFormatter.new(:pattern => "[%l] @ %d : %M")
32
+
33
+ so = StdoutOutputter.new("console", :formatter => pf)
34
+ @global_console_logger.outputters << so
35
+ @global_console_logger.level = DEBUG
36
+
37
+ fo = FileOutputter.new("f1", :filename => GLOBAL_LOGGER_LOG_FILE, :trunc => false, :formatter => pf)
38
+ @global_file_logger.outputters << fo
39
+ @global_file_logger.level = DEBUG
40
+
41
+ @global_mix_logger.outputters << so
42
+ @global_mix_logger.outputters << fo
43
+ @global_mix_logger.level = DEBUG
44
+
45
+ end
46
+ end
47
+
48
+
49
+ #add instance to kernel so we have global acess to them
50
+ module Kernel
51
+ # Console only log
52
+ def console_logger
53
+ GlobalLogger.instance.global_console_logger
54
+ end
55
+
56
+ # File only log
57
+ def file_logger
58
+ GlobalLogger.instance.global_file_logger
59
+ end
60
+
61
+ # Console and File log
62
+ def all_logger
63
+ GlobalLogger.instance.global_mix_logger
64
+ end
65
+ end
66
+
67
+ ## Local, class wide logger. Should have include LocalLogger added to the class, logger is used
68
+ ## In cucumber remenber to add teh Utils module to the world
69
+ ## Usage sample:
70
+ ## class A
71
+ ## include LocalLogger
72
+ ## def method
73
+ ## mix_logger.debug "Logging to console and File: myHash: #{myHash}"
74
+ ## end
75
+ ## end
76
+ ##
77
+ ## It is currently implements three functions:
78
+ ## console_logger() - logging to STDOUT
79
+ ## file_logger() - logging to FILE
80
+ ## mix_logger() - logging to both STDOUT and FILE
81
+ ##
82
+ ## if LOCAL_LOGGER_LOG_FILE not specified, "/tmp/" + self.class.to_s + "./log" will be used
83
+ ##
84
+
85
+ LOCAL_LOGGER_LOG_FILE = File.join(Dir.pwd, 'logs', 'local_logfile.log')
86
+ module Utils
87
+ module LocalLogger
88
+
89
+ # Class console logger. The messages only go to the stdout
90
+ # No message is saved to file
91
+ def console_logger
92
+ @logger = Log4r::Logger.new("LocalLoggerConsole")
93
+ pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M")
94
+
95
+ so = StdoutOutputter.new("console", :formatter => pf)
96
+ @logger.outputters << so
97
+ @logger.level = DEBUG
98
+ @logger
99
+ end
100
+
101
+ # Class simple file logger. Message is stored in file, but
102
+ # it does not appear on stdout
103
+ def file_logger
104
+ log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ? "/tmp/" + self.class.to_s + ".log" : LOCAL_LOGGER_LOG_FILE
105
+ @logger = Log4r::Logger.new("LocalLoggerFile")
106
+ pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M")
107
+
108
+ fo = FileOutputter.new("f1", :filename => log_file, :trunc => false, :formatter => pf)
109
+ @logger.outputters << fo
110
+ @logger.level = DEBUG
111
+ @logger
112
+ end
113
+
114
+
115
+ # Class wide console and file logger. Message appears on console output and it's stored on file
116
+ def mix_logger
117
+ log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ? "/tmp/" + self.class.to_s + ".log" : LOCAL_LOGGER_LOG_FILE
118
+ @logger = Log4r::Logger.new("LocalLoggerConsoleAndFile")
119
+ pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M")
120
+
121
+ so = StdoutOutputter.new("console", :formatter => pf)
122
+ fo = FileOutputter.new("f1", :filename => log_file, :trunc => false, :formatter => pf)
123
+
124
+ @logger.outputters << so
125
+ @logger.outputters << fo
126
+ @logger.level = DEBUG
127
+ @logger
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,3 @@
1
+ module Crtu
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,92 @@
1
+ require 'cucumber/rake/task'
2
+ require 'fileutils'
3
+
4
+ class BuildFailure < Exception;
5
+ def initialize(message = nil)
6
+ message ||= "Build failed"
7
+ super(message)
8
+ end
9
+ end;
10
+
11
+ Cucumber::Rake::Task.new do |t|
12
+ t.cucumber_opts = "-r features/ --format progress --out reports/progress.out --format html --out reports/report.html --format json --out reports/cucumber.json"
13
+ end
14
+
15
+ desc "Create log and reports folder in current directory"
16
+ task :create_log_report_folders do
17
+ log_path = File.join(Dir.pwd, 'logs')
18
+ report_path = File.join(Dir.pwd,'reports')
19
+
20
+ unless File.directory?(log_path)
21
+ FileUtils.mkdir_p(log_path)
22
+ end
23
+
24
+ unless File.directory?(report_path)
25
+ FileUtils.mkdir_p(report_path)
26
+ end
27
+ end
28
+
29
+
30
+ task :cleanup do
31
+ puts '============ Deleting old logs and reports ==============='
32
+ puts "PLEASE DON'T USE THIS TASK IN CI SERVER, USE CI OPTIONS INSTEAD"
33
+ puts '===== USE THIS ONLY FOR DEVELOPMENT IN YOUR OWN MACHINE ====='
34
+
35
+ log_path = File.join(Dir.pwd, 'logs')
36
+ report_path = File.join(Dir.pwd,'reports')
37
+
38
+ FileUtils.rm_rf(log_path)
39
+ FileUtils.rm_rf(report_path)
40
+ Rake::Task['create_log_report_folders'].invoke
41
+ end
42
+
43
+
44
+
45
+ namespace :features do
46
+ desc "Run finished features"
47
+ Cucumber::Rake::Task.new(:finished) do |t|
48
+ t.cucumber_opts = "-r features/ --format progress --out reports/progress.out --format html --out reports/report.html --format json --out reports/cucumber.json --tags ~@wip"
49
+ end
50
+
51
+ desc "Run in-progress features"
52
+ Cucumber::Rake::Task.new(:in_progress) do |t|
53
+ t.cucumber_opts = "-r features/ --require formatters/ --format progress --out reports/progress.out --format html --out reports/report.html --format json --out reports/cucumber.json --tags @wip"
54
+ end
55
+
56
+
57
+ desc "Run features with given tags - OR joing"
58
+ task :run_with_tags, [:tags] do |t,args|
59
+ if args[:tags].is_a?(String)
60
+ tags_line = args[:tags]
61
+ else
62
+ tags_line = args[:tags].join(',')
63
+ end
64
+ Cucumber::Rake::Task.new(t) do |c|
65
+ c.cucumber_opts = "-r features/ --format progress --out reports/progress.out --format html --out reports/report.html --format json --out reports/cucumber.json --tags #{tags_line}"
66
+ end
67
+ end
68
+ end
69
+
70
+ desc "Run complete feature build"
71
+ task :cruise do
72
+ finished_successful = run_and_check_for_exception("finished")
73
+ in_progress_successful = run_and_check_for_exception("in_progress")
74
+
75
+ unless finished_successful && in_progress_successful
76
+ 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
+ puts
80
+ raise BuildFailure
81
+ end
82
+ end
83
+
84
+ def run_and_check_for_exception(task_name)
85
+ puts "*** Running #{task_name} features ***"
86
+ begin
87
+ Rake::Task["features:#{task_name}"].invoke
88
+ rescue Exception => e
89
+ return false
90
+ end
91
+ true
92
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crtu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fábio André Ramos Rodrigues
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: log4r
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.10
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.1.10
69
+ - !ruby/object:Gem::Dependency
70
+ name: cucumber
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.3'
76
+ - - ">"
77
+ - !ruby/object:Gem::Version
78
+ version: 2.3.0
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '2.3'
86
+ - - ">"
87
+ - !ruby/object:Gem::Version
88
+ version: 2.3.0
89
+ description: Useful Cucumber and ruby test utilities,like loggers, rake tasks, etc...
90
+ email:
91
+ - fabio_rodrigues@student-partners.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".travis.yml"
98
+ - CODE_OF_CONDUCT.md
99
+ - Gemfile
100
+ - LICENSE
101
+ - README.md
102
+ - Rakefile
103
+ - bin/console
104
+ - bin/setup
105
+ - crtu.gemspec
106
+ - lib/crtu.rb
107
+ - lib/crtu/utils/logger.rb
108
+ - lib/crtu/version.rb
109
+ - lib/tasks/cucumber_tasks.rake
110
+ homepage: https://github.com/Th33x1l3/CRTU
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.5.1
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Cucumber Ruby Test Utilities
134
+ test_files: []