oats 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +52 -0
- data/lib/oats/keywords.rb +66 -67
- data/lib/oats/version.rb +1 -1
- data/oats.gemspec +1 -1
- data/oats_tests/lib/sample_xl_lists.rb +4 -3
- metadata +4 -3
data/.rvmrc
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.8.7" > .rvmrc
|
9
|
+
environment_id="ruby-1.8.7-p358@oats"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.13.4 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
if [[ $- == *i* ]] # check for interactive shells
|
29
|
+
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
30
|
+
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
|
31
|
+
fi
|
32
|
+
else
|
33
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
34
|
+
rvm --create use "$environment_id" || {
|
35
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
36
|
+
return 1
|
37
|
+
}
|
38
|
+
fi
|
39
|
+
|
40
|
+
# # If you use bundler, this might be useful to you:
|
41
|
+
# if [[ -s Gemfile ]] && {
|
42
|
+
# ! builtin command -v bundle >/dev/null ||
|
43
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
44
|
+
# }
|
45
|
+
# then
|
46
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
47
|
+
# gem install bundler
|
48
|
+
# fi
|
49
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
50
|
+
# then
|
51
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
52
|
+
# fi
|
data/lib/oats/keywords.rb
CHANGED
@@ -2,86 +2,85 @@
|
|
2
2
|
module Oats
|
3
3
|
|
4
4
|
# Process keyword driven testing
|
5
|
-
|
6
|
-
class << self
|
5
|
+
module Keywords
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
# Same as selenium.wait_and_type, but maps key via OatsX.locator, and uses
|
8
|
+
# OatsX.data[key] for value
|
9
|
+
def wait_and_type(key, *args)
|
10
|
+
selenium.wait_and_type(locator(key), oats_data[key], *args)
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
# Same as selenium.wait_for_element, but maps key via OatsX.locator first
|
14
|
+
def wait_and_click(key)
|
15
|
+
selenium.wait_and_click(locator(key))
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
# Same as selenium.wait_for_element, maps key via OatsX.locator first
|
19
|
+
def wait_and_text(key)
|
20
|
+
selenium.wait_for_element(locator(key)).text
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
# Returned the key or mappings if defined in the <class>::LOCATOR_MAP
|
24
|
+
def locator(key)
|
25
|
+
self::LOCATOR_MAP[key] || key
|
26
|
+
end
|
28
27
|
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
# Oats.assert list, "Oats.data keywords.list is not defined."
|
41
|
-
val = cell ? xl_root_list[cell] : xl_root_list
|
42
|
-
Oats.assert( val, "No keywords are defined for #{clas}" + (list ? ".#{list}" : '') ) if cell == 'keywords'
|
43
|
-
Marshal.load(Marshal.dump(val)) # Protect Oats.data from modification
|
29
|
+
# Return data from XL spreadsheet entries via Oats.data('xl.data')
|
30
|
+
# OatsX.oats_data(key_string) or OatsX.oats_data[key_string]
|
31
|
+
def oats_data(cell = nil, clas = self)
|
32
|
+
xl_root = $oats[clas.name]
|
33
|
+
list = xl_root['list'] || Oats.data('keywords.list')
|
34
|
+
if list
|
35
|
+
xl_root_list = xl_root[list]
|
36
|
+
else
|
37
|
+
xl_root_list = xl_root
|
44
38
|
end
|
39
|
+
# Oats.assert list, "Oats.data keywords.list is not defined."
|
40
|
+
val = cell ? xl_root_list[cell] : xl_root_list
|
41
|
+
Oats.assert( val, "No keywords are defined for #{clas}" + (list ? ".#{list}" : '') ) if cell == 'keywords'
|
42
|
+
Marshal.load(Marshal.dump(val)) # Protect Oats.data from modification
|
43
|
+
end
|
44
|
+
module_function :oats_data
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
# Handles keyword processing.
|
47
|
+
# Used by OATS framework to run XL driven test suites.
|
48
|
+
# Users can also call this from yaml_handlers.
|
49
|
+
def self.process
|
50
|
+
# Class name comes from Oats.data oats_keywords_cleass, or in the case of XL files from TestCase ID
|
51
|
+
class_name = Oats.data('keywords.class') || File.basename(File.dirname(File.dirname(Oats.test.id)))
|
52
|
+
class_file = nil
|
53
|
+
begin
|
54
|
+
keywords_class = Kernel.const_get class_name
|
55
|
+
rescue NameError
|
56
|
+
class_file = Oats.data('keywords.class_file')
|
57
|
+
unless class_file # Try standard ruby conventions
|
58
|
+
class_file = class_name.dup
|
59
|
+
class_file.gsub!(/::/, '/')
|
60
|
+
class_file.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
61
|
+
class_file.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
62
|
+
class_file.tr!("-", "_")
|
63
|
+
class_file.downcase!
|
64
|
+
end
|
53
65
|
begin
|
54
|
-
|
55
|
-
|
56
|
-
class_file = Oats.data('keywords.class_file')
|
57
|
-
unless class_file # Try standard ruby conventions
|
58
|
-
class_file = class_name.dup
|
59
|
-
class_file.gsub!(/::/, '/')
|
60
|
-
class_file.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
61
|
-
class_file.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
62
|
-
class_file.tr!("-", "_")
|
63
|
-
class_file.downcase!
|
64
|
-
end
|
66
|
+
Oats.info "Loading: '#{class_file}' for #{class_name}"
|
67
|
+
require class_file
|
65
68
|
begin
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
keywords_class = Kernel.const_get class_name
|
70
|
-
rescue NameError
|
71
|
-
raise OatsTestError, "Can not find class '#{class_name}' in class file: '#{class_file}'"
|
72
|
-
end
|
73
|
-
rescue LoadError
|
74
|
-
Oats.assert class_file.nil?, "Could not load Oats.data keywords.class_file '#{class_file}' for class '#{class_name}'."
|
69
|
+
keywords_class = Kernel.const_get class_name
|
70
|
+
rescue NameError
|
71
|
+
raise OatsTestError, "Can not find class '#{class_name}' in class file: '#{class_file}'"
|
75
72
|
end
|
76
|
-
|
77
|
-
|
78
|
-
Oats.assert keywords_class.respond_to?(action),
|
79
|
-
"There is no method defined in #{class_name} to the handle keyword 'a#{action}'."
|
80
|
-
Oats.info "Performing " + action
|
81
|
-
keywords_class.send action
|
73
|
+
rescue LoadError
|
74
|
+
Oats.assert class_file.nil?, "Could not load Oats.data keywords.class_file '#{class_file}' for class '#{class_name}'."
|
82
75
|
end
|
83
76
|
end
|
84
|
-
|
77
|
+
oats_data('keywords',keywords_class).each do |action|
|
78
|
+
Oats.assert keywords_class.respond_to?(action),
|
79
|
+
"There is no method defined in #{class_name} to the handle keyword 'a#{action}'."
|
80
|
+
Oats.info "Performing " + action
|
81
|
+
keywords_class.send action
|
82
|
+
end
|
85
83
|
end
|
84
|
+
|
86
85
|
end
|
87
86
|
end
|
data/lib/oats/version.rb
CHANGED
data/oats.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
# s.extra_rdoc_files = ["CHANGELOG", "COPYING", "lib/oats/oats.rb", "LICENSE", "README"]
|
23
23
|
# s.has_rdoc = true
|
24
|
-
# s.homepage = %q{http://oats
|
24
|
+
# s.homepage = %q{http://oats.org}
|
25
25
|
# s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Oats", "--main", "README"
|
26
26
|
s.date = %q{2012-05-22}
|
27
27
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
@@ -6,19 +6,20 @@ require 'net/imap'
|
|
6
6
|
#require 'openssl'
|
7
7
|
#require 'nokogiri'
|
8
8
|
|
9
|
-
|
9
|
+
module SampleXlLists
|
10
10
|
|
11
|
-
# Maps entries to be accessed by 'locator'
|
11
|
+
# Maps entries to be accessed by 'locator' method below
|
12
12
|
self::LOCATOR_MAP = {
|
13
13
|
'url' => "url_locator"
|
14
14
|
}
|
15
15
|
|
16
16
|
class << self
|
17
|
+
include Oats::Keywords
|
17
18
|
|
18
19
|
def action1
|
19
20
|
data = oats_data
|
20
21
|
data.delete('keywords')
|
21
|
-
Oats.info "Data:" + data.inspect
|
22
|
+
Oats.info "URL: #{locator('url')} Data:" + data.inspect
|
22
23
|
end
|
23
24
|
|
24
25
|
def action2
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Levent Atasoy
|
@@ -85,6 +85,7 @@ extra_rdoc_files: []
|
|
85
85
|
|
86
86
|
files:
|
87
87
|
- .gitignore
|
88
|
+
- .rvmrc
|
88
89
|
- Gemfile
|
89
90
|
- README.txt
|
90
91
|
- Rakefile
|