testrailtagging 0.3.6.8

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: d9f009ba3976701fa82d946346d030b94031d6f2
4
+ data.tar.gz: 5ad488c40e11de6091230a008d046219c954b1fa
5
+ SHA512:
6
+ metadata.gz: 67c05020b50585a06696d8a4f5afa0fb93c24be4d7efa9d8858241439b5186ae24c31358b075fdb31f392e689f051d6b2dd08750943400eebe577b48c69912d6
7
+ data.tar.gz: e3630127311e5850c6b33b14f5ff831054f1c9d36f0a921730782aa2573cc35b153b40dd0ba8c5a0c8d9927470e1e8c0c5f5bf969bd63a9ad3cc59f4435551b1
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -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 cjohnson@instructure.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,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in testrailtagging.gemspec
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Chris Johnson
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Testrailtagging
2
+
3
+ Testrailtagging is some ruby modules and classes that integrate rspec together with GuRock's Testrail web-application.
4
+ The main feature of this gem is to allow realtime reporting of rspec results to testrail.
5
+
6
+ There is also functionality to push and pull data to testrail.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'testrailtagging'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install testrailtagging
23
+
24
+ ## Usage
25
+
26
+ First, you must have a valid and active testrail account you want to post results to.
27
+ Second to use the API's you will need a username and a password for testrail.
28
+
29
+ Hence to do anything with this gem you will need to set the following environment variables:
30
+
31
+ `TESTRAIL_USER`
32
+ `TESTRAIL_PASSWORD`
33
+
34
+ which this gem will look for and use.
35
+
36
+ ### For Reporting results to testrail
37
+
38
+ This is for reporting rspec results to a pre-existing test run at testrail.com.
39
+ First, in testrail find the ID of the test run you want to push results to. You can find it in URL like this:
40
+
41
+ `https://blablabla.testrail.com/index.php?/runs/view/14153`
42
+
43
+ Here the test run is 14153.
44
+
45
+ Then you set an environment variable called TESTRAIL_RUN_ID, with that value. For example:
46
+
47
+ `export TESTRAIL_RUN_ID=14153`
48
+
49
+ Next, in your RSpec configuration file (usually spec_helper.rb) you need to call a registration function:
50
+
51
+
52
+ ```ruby
53
+ RSpec.configure do |config|
54
+ TestRailRSpecIntegration.register_rspec_integration(config,:bridge)
55
+ end
56
+ ```
57
+
58
+ Here you pass in the rspec config, and an identifier for your product. Either :bridge or :canvas.
59
+
60
+
61
+ ## Development
62
+
63
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
+
65
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/testrailtagging. 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.
70
+
71
+
72
+ ## License
73
+
74
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
75
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require_relative "../lib/testrailtagging"
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
@@ -0,0 +1,177 @@
1
+ require "parser/current"
2
+ require_relative "TestCase"
3
+
4
+ def colorize(text, color_code)
5
+ "\e[1;#{color_code}m#{text}\e[0m"
6
+ end
7
+
8
+ def red(text)
9
+ colorize(text, 31)
10
+ end
11
+
12
+ def green(text)
13
+ colorize(text, 32)
14
+ end
15
+
16
+ class RSpecParser
17
+ public
18
+ attr_reader :file, :test_cases
19
+ attr_accessor :verbose
20
+ def initialize(file_name)
21
+ file = file_name
22
+ @top_node = Parser::CurrentRuby.parse_file(file)
23
+ @ids = []
24
+ @metadata = {}
25
+ @skips = []
26
+ test_cases = []
27
+ @skips_in_before = []
28
+ @condition_set = false
29
+ @indent_amount = " "
30
+ @in_testrail_id = false
31
+ end
32
+
33
+ # Performs the parsing of the rspec file and generates an array of TestCase instances
34
+ def parse(verbosity:false)
35
+ verbose = verbosity
36
+ traverse(@top_node, "")
37
+ # get the last one added to the array
38
+ test_cases << @current_test_case.clone
39
+ test_cases.each do |tc|
40
+ tc.skip += @skips_in_before
41
+ end
42
+ puts "" if verbose
43
+ end
44
+
45
+ # Prints to standard out the test cases that were generated by parsing the file
46
+ def inspect
47
+ test_cases.each do |tc|
48
+ puts tc.print
49
+ end
50
+ end
51
+
52
+ # Prints to standard out the full, unvarnished abstract syntax tree in all it's ugliness.
53
+ def dump_ast
54
+ print_ast(@top_node, "")
55
+ puts ""
56
+ end
57
+
58
+ private
59
+ def check_node(node)
60
+ case node
61
+ when :before
62
+ @state = :example_body
63
+ @in_before = true
64
+ when :example
65
+ @in_before = false
66
+ if @state != :example
67
+ test_cases << @current_test_case.clone if @current_test_case
68
+ @ids.clear
69
+ @metadata.clear
70
+ @skips.clear
71
+ @condition_set = false
72
+ @title = nil
73
+ end
74
+ @current_test_case = TestRailOperations::TestCase.new(nil, # test ID, don't know it yet
75
+ nil, # title, don't know it yet
76
+ nil, # priority, don't know it yet
77
+ true, # automated, of course this is automated
78
+ nil, # screen size, don't know it yet
79
+ true, # is automatable if it is automated
80
+ nil, # no Jira references
81
+ nil) # no runonce references
82
+ # get the title
83
+ @state = :example_title
84
+ when :skip
85
+ if @condition_set
86
+ # do nothing, the browsers have already been set.
87
+ else
88
+ @skips << "allbrowsers" # a skip call with no conditions. Skips on all browsers
89
+ end
90
+
91
+ if @in_before
92
+ @skips_in_before += @skips.clone
93
+ else
94
+ @current_test_case.skip = @skips.clone
95
+ end
96
+ @state = :example_body
97
+ when :testrail_id
98
+ @state = :testrail_id
99
+ when :priority
100
+ @state = :priority
101
+ when :ENV
102
+ @state = :example_body
103
+ end
104
+ end
105
+
106
+ def check_node_string(node)
107
+ if @state == :example_title
108
+ @title = node.children[0]
109
+ @current_test_case.title = @title.clone
110
+ @state = :example_args
111
+ elsif @state == :example_body
112
+ if (node.children[0] == "SELENIUM_BROWSER")
113
+ @state = :selenium_browser
114
+ end
115
+ elsif @state == :selenium_browser
116
+ browser_skip = node.children[0]
117
+ @skips << browser_skip
118
+ @state == :example_body
119
+ elsif @state == :skip
120
+ @state = :example_body
121
+ elsif @state == :testrail_id
122
+ id = node.children[0]
123
+ @ids << id
124
+ end
125
+ end
126
+
127
+ def check_node_type(node)
128
+ case node.type
129
+ when :if
130
+ @condition_set = true
131
+ when :str
132
+ check_node_string(node)
133
+ when :args
134
+ @state == :example_body
135
+ when :begin
136
+ @state = :example_body
137
+ if @ids.count > 0
138
+ @metadata[:testrail_id] = @ids.clone
139
+ @current_test_case.metadata = @metadata.clone
140
+ @current_test_case.id = @ids.clone
141
+ end
142
+ when :int
143
+ if @state == :priority
144
+ @metadata[:priority] = node.children[0].to_i
145
+ @current_test_case.priority = node.children[0].to_i
146
+ @state = :example_args
147
+ end
148
+ end
149
+ end
150
+
151
+ # Recursive function to iterate through the direct acyclic graph of the abstract syntax tree (AST).
152
+ def traverse(node, indent)
153
+ check_node(node)
154
+ check_node_type(node) if node.respond_to?(:type)
155
+ return unless node.respond_to?(:children)
156
+ node.children.each do |child|
157
+ traverse(child, indent + @indent_amount)
158
+ end
159
+ end
160
+
161
+ # recursive function to dump the entire abstract syntax tree, and NOT the pretty print version
162
+ # which hides child elements
163
+ def print_ast(node, indent)
164
+ if node.to_s.match("example")
165
+ puts green("#{indent}#{node} <#{node.class}>")
166
+ elsif node.to_s.match("skip") && node.class == Symbol
167
+ puts red("#{indent}#{node} <#{node.class}>")
168
+ else
169
+ puts "#{indent}#{node} <#{node.class}>"
170
+ end
171
+
172
+ return unless node.respond_to?(:children)
173
+ node.children.each do |child|
174
+ print_ast(child, indent + @indent_amount)
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,38 @@
1
+
2
+ module TestRailOperations
3
+ # Represents a test case in test rail.
4
+ class TestCase
5
+ attr_accessor :id, :title, :priority, :automated, :screen_size, :result_message, :status
6
+ attr_accessor :automatable, :references, :run_once
7
+ attr_accessor :file # Which rspec file the test case is found in
8
+ attr_accessor :metadata, :skip
9
+ attr_accessor :temp_id
10
+ attr_accessor :assigned_to
11
+
12
+ def initialize(id, title, priority, automated, screen_size, automatable, references, run_once)
13
+ @id = id
14
+ @title = title
15
+ @priority = priority
16
+ @automated = automated
17
+ @screen_size = screen_size
18
+ @automatable = automatable
19
+ @references = references
20
+ @run_once = run_once
21
+ @skip = []
22
+ end
23
+
24
+ def set_status(status, message)
25
+ @status = status
26
+ @result_message = message # a string
27
+ end
28
+
29
+ def print
30
+ puts ""
31
+ puts "Test Case: #{@id}, #{@title}"
32
+ puts "\tPriority: #{@priority}"
33
+ puts "\tScreen Size: #{@screen_size}"
34
+ puts "\tAutomated: #{@automated}"
35
+ puts "\tSkips: #{skip}"
36
+ end
37
+ end
38
+ end