RLib 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +3 -89
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -3
- data/CODE_OF_CONDUCT.md +0 -13
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/README.md +0 -41
- data/RLib.gemspec +0 -33
- data/Rakefile +0 -2
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/lib/RLib.rb +0 -9
- data/lib/RLib/ProxyAgent.rb +0 -124
- data/lib/RLib/SpiraAgent.rb +0 -114
- data/lib/RLib/assertions.rb +0 -63
- data/lib/RLib/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f06cbde74346c04154cfeb51984690fde295b9d6
|
4
|
+
data.tar.gz: 7dd812da89158a0af0f820e55444b386038aabf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1f7275a3b502134efc16a9369696a459d5f64856181cd413e1f02efa29d61997e2c0a3c428826ebf27fd20e5525184825c8ff5f8f8c219acbd38a253b22222d
|
7
|
+
data.tar.gz: 4b62e532873164e1b605758faab273620897bdfc342c3f886cc2fda7275e8e784468ea1ffd53732a20db8bb9f3c362322d10539ca2c980b05663b4cdf26b383f
|
metadata
CHANGED
@@ -1,85 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RLib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- QA Automation Group @ Yellow Pages Group
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: savon
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.8.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 2.8.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: json
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.8.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rest-client
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.6.7
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.6.7
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 3.1.0
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 3.1.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: calabash-cucumber
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.12.0
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.12.0
|
83
13
|
- !ruby/object:Gem::Dependency
|
84
14
|
name: bundler
|
85
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,23 +44,7 @@ email:
|
|
114
44
|
executables: []
|
115
45
|
extensions: []
|
116
46
|
extra_rdoc_files: []
|
117
|
-
files:
|
118
|
-
- .gitignore
|
119
|
-
- .rspec
|
120
|
-
- .travis.yml
|
121
|
-
- CODE_OF_CONDUCT.md
|
122
|
-
- Gemfile
|
123
|
-
- LICENSE.txt
|
124
|
-
- README.md
|
125
|
-
- RLib.gemspec
|
126
|
-
- Rakefile
|
127
|
-
- bin/console
|
128
|
-
- bin/setup
|
129
|
-
- lib/RLib.rb
|
130
|
-
- lib/RLib/ProxyAgent.rb
|
131
|
-
- lib/RLib/SpiraAgent.rb
|
132
|
-
- lib/RLib/assertions.rb
|
133
|
-
- lib/RLib/version.rb
|
47
|
+
files: []
|
134
48
|
homepage:
|
135
49
|
licenses:
|
136
50
|
- MIT
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
-
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
-
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
-
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
-
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
-
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 Taru Malik
|
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
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# RLib
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/RLib`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'RLib'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install RLib
|
22
|
-
|
23
|
-
## Example Usage
|
24
|
-
|
25
|
-
@proxy_agent = RLib::ProxyAgent.new(:proxy_server_ip => PROXY_SERVER_IP, :proxy_server_port => PROXY_SERVER_PORT, :device_ip => get_device_ip(@device))
|
26
|
-
@spira_agent = RLib::SpiraAgent.new( SPIRA_USER_NAME, SPIRA_PASSWORD, SPIRA_WSDL)
|
27
|
-
@assertion = Assertions.view_exists(view_id)
|
28
|
-
|
29
|
-
## Development
|
30
|
-
|
31
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
-
|
33
|
-
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
34
|
-
|
35
|
-
## Contributing
|
36
|
-
|
37
|
-
1. Fork it ( https://github.com/[my-github-username]/RLib/fork )
|
38
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
-
5. Create a new Pull Request
|
data/RLib.gemspec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'RLib/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "RLib"
|
8
|
-
spec.version = RLib::VERSION
|
9
|
-
spec.authors = ["QA Automation Group @ Yellow Pages Group"]
|
10
|
-
spec.email = ["mobileqaypg@gmail.com"]
|
11
|
-
|
12
|
-
if spec.respond_to?(:metadata)
|
13
|
-
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
14
|
-
end
|
15
|
-
|
16
|
-
spec.summary = %q{Ruby Package to help the wayward QA Tester}
|
17
|
-
spec.description = %q{Ruby Package to help the wayward QA Tester at Yellow Pages Group}
|
18
|
-
spec.license = "MIT"
|
19
|
-
|
20
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.add_runtime_dependency "savon", "~> 2.8.0"
|
25
|
-
spec.add_runtime_dependency "json", "~> 1.8.1"
|
26
|
-
spec.add_runtime_dependency "rest-client", "~> 1.6.7"
|
27
|
-
spec.add_runtime_dependency "rspec", "~> 3.1.0"
|
28
|
-
spec.add_runtime_dependency "calabash-cucumber", "~> 0.12.0"
|
29
|
-
|
30
|
-
spec.add_development_dependency "bundler", "~> 1.8"
|
31
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
-
|
33
|
-
end
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "RLib"
|
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
DELETED
data/lib/RLib.rb
DELETED
data/lib/RLib/ProxyAgent.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
require 'rest-client'
|
2
|
-
require 'json'
|
3
|
-
require 'rspec'
|
4
|
-
|
5
|
-
module RLib
|
6
|
-
class ProxyAgent
|
7
|
-
|
8
|
-
attr_accessor :proxy_server_ip, :proxy_server_port, :device_ip
|
9
|
-
|
10
|
-
# Sets the proxy server ip here or write your own function to load from config file
|
11
|
-
def initialize(hash)
|
12
|
-
puts "Initializing proxy agent"
|
13
|
-
@proxy_server_ip = hash[:proxy_server_ip]
|
14
|
-
@proxy_server_port = hash[:proxy_server_port]
|
15
|
-
@device_ip = hash[:device_ip]
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
# Gets the status of logging for the agent
|
20
|
-
# return: boolean
|
21
|
-
def is_logging?
|
22
|
-
begin
|
23
|
-
return (RestClient.get "#{@proxy_server_ip}/logging?src_ip=#{@device_ip}").code == 200
|
24
|
-
rescue
|
25
|
-
return false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Enables logging for the agent on Server
|
30
|
-
# return: None
|
31
|
-
def start_logging
|
32
|
-
begin
|
33
|
-
puts "Trying to Start logging at #{proxy_url} for device #{@device_ip}" if Calabash::Cucumber::Logging.full_console_logging?
|
34
|
-
RestClient.post "#{proxy_url}/start_logging?src_ip=#{@device_ip}", ''
|
35
|
-
puts 'Success...!' if Calabash::Cucumber::Logging.full_console_logging?
|
36
|
-
return true
|
37
|
-
rescue
|
38
|
-
return false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
# Stops logging on the proxy server for the agent
|
44
|
-
# return: None
|
45
|
-
def stop_logging
|
46
|
-
begin
|
47
|
-
puts "Trying to Terminate logging at #{proxy_url} for device #{@device_ip}" if Calabash::Cucumber::Logging.full_console_logging?
|
48
|
-
RestClient.post "#{proxy_url}/stop_logging?src_ip=#{@device_ip}", ''
|
49
|
-
puts 'Success...!' if Calabash::Cucumber::Logging.full_console_logging?
|
50
|
-
return true
|
51
|
-
rescue
|
52
|
-
return false
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
# Clears proxy server memory
|
58
|
-
# return: None
|
59
|
-
def clear_server_mem(max_delete_retries=2)
|
60
|
-
max_delete_retries.times do |n|
|
61
|
-
begin
|
62
|
-
puts "Trying to Clear server memory at #{proxy_url} for device #{@device_ip}..." if Calabash::Cucumber::Logging.full_console_logging?
|
63
|
-
RestClient.delete ("#{proxy_url}/log?src_ip=#{@device_ip}") { |response, request, result, &block|
|
64
|
-
sleep 1
|
65
|
-
case response.code
|
66
|
-
when 200
|
67
|
-
puts 'Success...!' if Calabash::Cucumber::Logging.full_console_logging?
|
68
|
-
return response
|
69
|
-
else
|
70
|
-
puts "Failed to delete the logs on the proxy server. (attempt #{n+1})"
|
71
|
-
if n==max_delete_retries-1
|
72
|
-
puts "Delete retry attempts exhausted.\nResponse: #{result.code} #{result.message}"
|
73
|
-
return false
|
74
|
-
else
|
75
|
-
puts 'Retrying to delete after failure.'
|
76
|
-
end
|
77
|
-
end
|
78
|
-
}
|
79
|
-
rescue
|
80
|
-
return false
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
# Gets requests from the proxy server
|
87
|
-
# return: A list of URLs {url1, url2, ..., urlN}
|
88
|
-
def get_all_request(max_get_retries = 2)
|
89
|
-
max_get_retries.times do |n|
|
90
|
-
begin
|
91
|
-
RestClient.get ("#{proxy_url}/log?src_ip=#{@device_ip}") { |response, request, result, &block|
|
92
|
-
sleep 1
|
93
|
-
case response.code
|
94
|
-
when 200
|
95
|
-
return response
|
96
|
-
when 404
|
97
|
-
if JSON.parse(response)['message'].start_with?('NO logs found for IP')
|
98
|
-
return false
|
99
|
-
end
|
100
|
-
else
|
101
|
-
puts "Failed to get the logs on the proxy server. (attempt #{n+1})"
|
102
|
-
if n==max_get_retries-1
|
103
|
-
puts "Get retry attempts exhausted.\nResponse: #{result.code} #{result.message}"
|
104
|
-
return false
|
105
|
-
#return response.return!(request, result, &block)
|
106
|
-
else
|
107
|
-
puts 'Retrying to get after failure.'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
}
|
111
|
-
rescue
|
112
|
-
return false
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def proxy_url
|
118
|
-
'http://'+@proxy_server_ip+':'+@proxy_server_port
|
119
|
-
end
|
120
|
-
|
121
|
-
private :proxy_url
|
122
|
-
|
123
|
-
end
|
124
|
-
end
|
data/lib/RLib/SpiraAgent.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'savon'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module RLib
|
5
|
-
class SpiraAgent
|
6
|
-
|
7
|
-
@cookies
|
8
|
-
@client
|
9
|
-
@test_name_table
|
10
|
-
@project_id
|
11
|
-
|
12
|
-
# Initializes Spira Agent, set up savon client and makes connection to the Service point
|
13
|
-
def initialize(user_name, password, spira_wsdl, project_id = nil, folder_id = nil)
|
14
|
-
@client = Savon.client(wsdl: spira_wsdl)
|
15
|
-
connection = @client.call(:connection_authenticate, message: {user_name: user_name, password: password})
|
16
|
-
@cookies = connection.http.cookies
|
17
|
-
#Retrieves the table which maps test names to the unique test IDs automatically generated by spira (can be found in test URL)
|
18
|
-
if project_id != nil and folder_id != nil
|
19
|
-
set_test_name_table(project_id, folder_id)
|
20
|
-
@project_id = project_id
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns the table with test names mapped to test IDs
|
25
|
-
def get_test_table_from_spira_by_folder(project_id, folder_id)
|
26
|
-
#Connects to project Id
|
27
|
-
@client.call(:connection_connect_to_project, message: {project_id: project_id}, cookies: @cookies)
|
28
|
-
resp = @client.call(:test_case_retrieve_by_folder, message: {test_casefolder_id: folder_id}, cookies: @cookies)
|
29
|
-
# gets the response body and retrieves an array with the test cases
|
30
|
-
test_cases = resp.body[:test_case_retrieve_by_folder_response][:test_case_retrieve_by_folder_result][:remote_test_case]
|
31
|
-
test_table = {}
|
32
|
-
# for each test case slice the name and the ID of the test case and save it in the table
|
33
|
-
test_cases.each do |test|
|
34
|
-
test_table[test[:name]] = test[:test_case_id]
|
35
|
-
end
|
36
|
-
return test_table
|
37
|
-
end
|
38
|
-
|
39
|
-
# Returns Test information from a specific Test Case
|
40
|
-
def get_test_case_from_spira_by_id(project_id, test_case_id)
|
41
|
-
test_case = {}
|
42
|
-
@client.call(:connection_connect_to_project, message: {project_id: project_id}, cookies: @cookies)
|
43
|
-
|
44
|
-
resp = @client.call(:test_case_retrieve_by_id, message: {test_case_id: test_case_id}, cookies: @cookies)
|
45
|
-
# getting the response body
|
46
|
-
response_body = resp.body[:test_case_retrieve_by_id_response][:test_case_retrieve_by_id_result]
|
47
|
-
test_case['tcDescription'] = response_body[:description].gsub( %r{</?[^>]+?>}, '' )
|
48
|
-
test_case['tcName'] = response_body[:name]
|
49
|
-
steps_data = response_body[:test_steps][:remote_test_step]
|
50
|
-
steps = []
|
51
|
-
# Parses array and returns result
|
52
|
-
if steps_data
|
53
|
-
# if multiple steps
|
54
|
-
if steps_data.kind_of?(Array)
|
55
|
-
steps_data.each_with_index{|step|
|
56
|
-
temp_step = {}
|
57
|
-
temp_step['tsExpectedResult'] = step[:expected_result]
|
58
|
-
temp_step['tsDescription'] = step[:description].gsub('<div>',"\n").gsub(/<[^>]*>/,'').strip
|
59
|
-
steps.push temp_step
|
60
|
-
}
|
61
|
-
else
|
62
|
-
temp_step = {}
|
63
|
-
temp_step['tsExpectedResult'] = steps_data[:expected_result]
|
64
|
-
temp_step['tsDescription'] = steps_data[:description].gsub('<div>',"\n").gsub(/<[^>]*>/,'').strip
|
65
|
-
steps.push temp_step
|
66
|
-
end
|
67
|
-
end
|
68
|
-
test_case['tcSteps'] = steps
|
69
|
-
return test_case
|
70
|
-
end
|
71
|
-
|
72
|
-
# Returns the expected result in array for a given project and test case in JSON format
|
73
|
-
def get_expected_result_by_id(project_id, test_case_id)
|
74
|
-
test_case = self.get_test_case_from_spira_by_id(project_id, test_case_id)
|
75
|
-
steps = test_case['tcSteps']
|
76
|
-
expected = []
|
77
|
-
expected_hash = {}
|
78
|
-
steps.each{|le_step|
|
79
|
-
# expected.push JSON.parse(le_step['tsExpectedResult'])
|
80
|
-
le_step['tsExpectedResult'].split('</div>').each { |item| expected.push(item.gsub( %r{</?[^>]+?>}, '' )) }
|
81
|
-
}
|
82
|
-
expected.each { |item| items = item.split(':'); expected_hash.merge!({items[0] => items[1] })}
|
83
|
-
{ :expected_results => expected_hash, :test_case_name => test_case['tcName'], :test_case_description => test_case['tcDescription'] }
|
84
|
-
end
|
85
|
-
|
86
|
-
# Retrieves the expected result for a specific test case
|
87
|
-
# To get the expected results first initialize test names by calling set_test_name_table(projectId, folderId) method
|
88
|
-
# and provide the ID of the project and the ID of the folder that contains the test cases. Once the test tables are
|
89
|
-
# initialized get the expected result by simply providing the name of the desired test case.
|
90
|
-
def get_expected_result_by_name(test_case_name)
|
91
|
-
if @test_name_table == nil
|
92
|
-
raise 'ERROR: test_name_table is not set, call set_test_name_table(project_id, folder_id) method to initialize the '+
|
93
|
-
'test_name_table and project ID. Alternatively you can call get_expected_result_by_id(project_id, test_case_id) or' +
|
94
|
-
'set_test_name_table(project_id, folder_id) to set test_name_table.'
|
95
|
-
end
|
96
|
-
|
97
|
-
test_id = @test_name_table[test_case_name]
|
98
|
-
if test_id == nil
|
99
|
-
raise "ERROR: Program returned empty ID for the test name \"#{test_case_name}\""
|
100
|
-
end
|
101
|
-
|
102
|
-
get_expected_result_by_id(@project_id, test_id)
|
103
|
-
end
|
104
|
-
|
105
|
-
# Sets the test_name_table variable to the map that contains mapping of test names to the test IDs
|
106
|
-
def set_test_name_table(project_id, folder_id)
|
107
|
-
@project_id = project_id
|
108
|
-
@test_name_table = self.get_test_table_from_spira_by_folder(project_id, folder_id)
|
109
|
-
end
|
110
|
-
|
111
|
-
private :set_test_name_table
|
112
|
-
|
113
|
-
end
|
114
|
-
end
|
data/lib/RLib/assertions.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'calabash-cucumber'
|
3
|
-
|
4
|
-
# Common assertions used while working with Calabash-Cucumber
|
5
|
-
module Assertions
|
6
|
-
WAIT_TIMEOUT =(ENV['WAIT_TIMEOUT'] || 30).to_f
|
7
|
-
extend Calabash::Cucumber::Operations
|
8
|
-
|
9
|
-
|
10
|
-
# Verifies if a view exists
|
11
|
-
def Assertions.view_exists? (view_id)
|
12
|
-
!query("view marked:'#{view_id}'").empty?
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
# Waits for a view to exists on the page
|
17
|
-
def Assertions.wait_for_view_to_exist (view_id, timeout=WAIT_TIMEOUT)
|
18
|
-
msg = "waited for '#{timeout}' seconds but did not see '#{view_id}'"
|
19
|
-
wait_for(:timeout => timeout,
|
20
|
-
:retry_frequency => 0.2,
|
21
|
-
:post_timeout => 0.1,
|
22
|
-
:timeout_message => msg) do
|
23
|
-
view_exists? view_id
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Waits for a view to exists on the page
|
28
|
-
def Assertions.wait_for_view_does_not_exist (view_id, timeout=WAIT_TIMEOUT)
|
29
|
-
msg = "waited for '#{timeout}' seconds but did not see '#{view_id}'"
|
30
|
-
wait_for_element_does_not_exists(:timeout => timeout,
|
31
|
-
:retry_frequency => 0.2,
|
32
|
-
:post_timeout => 0.1,
|
33
|
-
:timeout_message => msg) do
|
34
|
-
view_exists? view_id
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Waits for the page to load
|
39
|
-
def Assertions.wait_for_the_page_to_load(text, timeout=WAIT_TIMEOUT)
|
40
|
-
wait_for(:timeout => timeout) {element_exists("view marked:'#{text}'")}
|
41
|
-
end
|
42
|
-
|
43
|
-
# Waits for the element that contains a specific text
|
44
|
-
def Assertions.wait_for_element_contains_text(text, timeout=WAIT_TIMEOUT)
|
45
|
-
wait_for(:timeout => timeout) {element_exists("label {text CONTAINS '#{text}'")}
|
46
|
-
end
|
47
|
-
|
48
|
-
# Waits for the element that begins with a specific text
|
49
|
-
def Assertions.wait_for_element_beginswith_text(text, timeout=WAIT_TIMEOUT)
|
50
|
-
wait_for(:timeout => timeout) {element_exists("label {text BEGINSWITH '#{text}'")}
|
51
|
-
end
|
52
|
-
|
53
|
-
# Waits for the element that ends with a specific text
|
54
|
-
def Assertions.wait_for_element_endswith_text(text, timeout=WAIT_TIMEOUT)
|
55
|
-
wait_for(:timeout => timeout) {element_exists("label {text ENDSWITH '#{text}'")}
|
56
|
-
end
|
57
|
-
|
58
|
-
# Waits for a specific text to load on the page
|
59
|
-
def Assertions.wait_for_specific_text_to_load(text, timeout=WAIT_TIMEOUT)
|
60
|
-
wait_for(:timeout => timeout) {element_exists("* marked:'#{text}'")}
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
data/lib/RLib/version.rb
DELETED