SimpliTest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +22 -0
- data/SimpliTest.gemspec +42 -0
- data/bin/SimpliTest +22 -0
- data/lib/SimpliTest.rb +2 -0
- data/lib/SimpliTest/cli/main.rb +305 -0
- data/lib/SimpliTest/config/configuration.rb +107 -0
- data/lib/SimpliTest/config/directory_paths.rb +36 -0
- data/lib/SimpliTest/config/environment.rb +67 -0
- data/lib/SimpliTest/config/local_environment.rb +20 -0
- data/lib/SimpliTest/config/profiles/chrome.rb +18 -0
- data/lib/SimpliTest/config/profiles/firefox.rb +14 -0
- data/lib/SimpliTest/config/profiles/internet_explorer.rb +12 -0
- data/lib/SimpliTest/config/profiles/phantom.rb +9 -0
- data/lib/SimpliTest/config/profiles/phantom_debug.rb +12 -0
- data/lib/SimpliTest/config/profiles/selenium.rb +13 -0
- data/lib/SimpliTest/config/screen_size.rb +25 -0
- data/lib/SimpliTest/config/steps.rb +8 -0
- data/lib/SimpliTest/helpers/data_validation.rb +60 -0
- data/lib/SimpliTest/helpers/file.rb +38 -0
- data/lib/SimpliTest/helpers/project_setup.rb +186 -0
- data/lib/SimpliTest/helpers/step_helpers/custom_chrome_helpers.rb +14 -0
- data/lib/SimpliTest/helpers/step_helpers/custom_date_helpers.rb +64 -0
- data/lib/SimpliTest/helpers/step_helpers/custom_form_helpers.rb +66 -0
- data/lib/SimpliTest/helpers/step_helpers/custom_phantomjs_helpers.rb +49 -0
- data/lib/SimpliTest/helpers/step_helpers/custom_selenium_helpers.rb +41 -0
- data/lib/SimpliTest/helpers/step_helpers/html_selectors_helpers.rb +154 -0
- data/lib/SimpliTest/helpers/step_helpers/navigation_helpers.rb +196 -0
- data/lib/SimpliTest/helpers/step_helpers/tolerance_for_sync_issues.rb +38 -0
- data/lib/SimpliTest/helpers/step_helpers/within_helpers.rb +6 -0
- data/lib/SimpliTest/helpers/windows_ui.rb +52 -0
- data/lib/SimpliTest/steps/debugging_steps.rb +19 -0
- data/lib/SimpliTest/steps/form_steps.rb +352 -0
- data/lib/SimpliTest/steps/form_verification_steps.rb +190 -0
- data/lib/SimpliTest/steps/navigation_steps.rb +47 -0
- data/lib/SimpliTest/steps/scoper.rb +42 -0
- data/lib/SimpliTest/steps/verification_steps.rb +306 -0
- data/lib/SimpliTest/tasks/document.rb +169 -0
- data/lib/SimpliTest/tasks/examples.rb +18 -0
- data/lib/SimpliTest/tasks/internal_release.rb +39 -0
- data/lib/SimpliTest/tasks/testinstall.rb +5 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/Readme.txt +5 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/cucumber.yml +26 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/documentation/step_definitions.html +87 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/RegressionTests/HelloWorld.feature +4 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/SmokeTest/HelloWorld.feature +4 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/accessibilityTests/HelloWorld.feature +4 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/environments.yml +11 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/pages.yml +26 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/selectors.yml +44 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/settings.yml +26 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/env.rb +33 -0
- data/lib/SimpliTest/templates/NewSimpliTestProject/license.txt +30 -0
- data/lib/SimpliTest/templates/document/css/style.css +28 -0
- data/lib/SimpliTest/templates/document/index.html +60 -0
- data/lib/version.rb +3 -0
- metadata +395 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ecfccf93b0a513b8a7aa26beb13b76d25a5c3494
|
4
|
+
data.tar.gz: 5081822b7a8a6f3094e060babf7e9532e73183fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d99ffdb0f8f822ac3a78cc6b8c9958d8a27495f5bfa6bcf71f29f09950e1e5a6d2c63206078bdeac8db0b5bf6d7cdcd99cf43aa9e4b03a9f7b3b9d8a054b304
|
7
|
+
data.tar.gz: d1b1730a4a306b084c6d75f5939cb18fd6bca7f19177ae3163c522d071129135b913cf49c700134f2c306909ac858b5d6512ff7a11635cf7e4d70af6a3b15ece
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# SimpliTest
|
2
|
+
SimpliTest was create by CGI Group Inc. members to accelerate the adoption of ATDD/BDD using Cucumber/Gherkin as the base framework. At it's core are many predefined step definitions backed by helper and utility methods. Mainly focused on the web interfaces using Selenium, but not restricted to only web apps, your imagination is it's limitation.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
1) Install Ruby & DevKit: https://rubyinstaller.org/downloads/
|
7
|
+
|
8
|
+
2) Build this Ruby gem
|
9
|
+
$ gem build SimpliTest.gemspec
|
10
|
+
$ gem install SimpliTest
|
11
|
+
|
12
|
+
3) Use it
|
13
|
+
$SimpliTest new MyNewSimpliTestProject
|
14
|
+
or cd into an existing directory and run
|
15
|
+
$SimpliTest init
|
16
|
+
|
17
|
+
$SimpliTest run
|
18
|
+
$SimpliTest smoketest
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
data/SimpliTest.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "SimpliTest"
|
8
|
+
spec.version = SimpliTest::VERSION
|
9
|
+
spec.authors = ["CGI Federal"]
|
10
|
+
spec.email = ["SimpliTest@cgifederal.com"]
|
11
|
+
spec.description = %q{Cucumber Websteps, Helpers and Executable for Web Test Automation }
|
12
|
+
spec.summary = %q{This gem provides common web steps and command line executable for automated acceptance testing }
|
13
|
+
spec.homepage = "https://github.com/CGIFederalInc/SimpliTest"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = Dir['lib/**/*'] + Dir['features/**/*'] + Dir['bin/*'] + ["SimpliTest.gemspec","README.md"] + Dir['test/**/*']
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.add_dependency "rubygems-update", "2.6.11"
|
21
|
+
spec.add_dependency "unf_ext", "0.0.7.2"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "sinatra", "~> 0"
|
25
|
+
spec.add_development_dependency "cucumber-sinatra", "~> 0"
|
26
|
+
spec.add_development_dependency "rake-notes", "~> 0"
|
27
|
+
spec.add_development_dependency "simplecov", "~> 0"
|
28
|
+
spec.add_development_dependency "aruba", "~> 0"
|
29
|
+
spec.add_development_dependency "hirb", "~> 0"
|
30
|
+
spec.add_development_dependency "geminabox", "~> 0"
|
31
|
+
spec.add_dependency "cucumber", "2.1.0"
|
32
|
+
spec.add_dependency "poltergeist", "1.7.0"
|
33
|
+
spec.add_dependency "capybara", "2.5.0"
|
34
|
+
spec.add_dependency "rspec", "3.3.0"
|
35
|
+
spec.add_dependency "selenium-webdriver", "3.2.1"
|
36
|
+
spec.add_dependency "launchy", "2.4.3"
|
37
|
+
spec.add_dependency "rake", "10.4.2"
|
38
|
+
spec.add_dependency 'parallel_tests', "1.9"
|
39
|
+
spec.add_dependency 'tiny_tds', "0.7"
|
40
|
+
spec.add_dependency 'rest-client', "~> 0"
|
41
|
+
spec.add_dependency "axe-matchers", "1.3.4"
|
42
|
+
end
|
data/bin/SimpliTest
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
## Run rake tasks and cucumber features
|
3
|
+
## from SimpliTest once it's installed.
|
4
|
+
#
|
5
|
+
# Example:
|
6
|
+
#
|
7
|
+
# SimpliTest init
|
8
|
+
# SimpliTest new ProjectName
|
9
|
+
# SimpliTest "document[html]"
|
10
|
+
|
11
|
+
require 'SimpliTest/cli/main'
|
12
|
+
pwd = Dir.pwd
|
13
|
+
gem_dir = File.expand_path('..', File.dirname(__FILE__))
|
14
|
+
command, *arguments = ARGV.dup
|
15
|
+
$LOAD_PATH.unshift gem_dir
|
16
|
+
options = {
|
17
|
+
:pwd => pwd,
|
18
|
+
:gem_dir => gem_dir,
|
19
|
+
:command => command,
|
20
|
+
:arguments => arguments
|
21
|
+
}
|
22
|
+
SimpliTest::Cli::Main.new(options).execute!
|
data/lib/SimpliTest.rb
ADDED
@@ -0,0 +1,305 @@
|
|
1
|
+
require 'SimpliTest'
|
2
|
+
require 'SimpliTest/config/directory_paths'
|
3
|
+
require 'SimpliTest/helpers/project_setup'
|
4
|
+
require 'SimpliTest/helpers/data_validation'
|
5
|
+
#TODO: Clean this up with OptionsParser
|
6
|
+
module SimpliTest
|
7
|
+
module Cli
|
8
|
+
## Command Line Interface to the SimpliTest Suite
|
9
|
+
class Main
|
10
|
+
extend ProjectSetupHelpers
|
11
|
+
class << self
|
12
|
+
def execute(args)
|
13
|
+
new(args).execute!
|
14
|
+
end
|
15
|
+
|
16
|
+
def new(opts={})
|
17
|
+
initialize(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
|
21
|
+
opts, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
|
22
|
+
@command = opts[:command].respond_to?(:downcase) ? opts[:command].downcase : opts[:command]
|
23
|
+
@arguments = opts[:arguments]
|
24
|
+
@arguments = @arguments.reject{|arg| (arg.to_s.empty? rescue true) } unless @arguments.is_a?(Array)
|
25
|
+
@pwd = opts[:pwd]
|
26
|
+
@gem_dir = opts[:gem_dir]
|
27
|
+
@environment = ENV['ENVIRONMENT']
|
28
|
+
@valid_commands = %w[create_update_task
|
29
|
+
document
|
30
|
+
document[csv]
|
31
|
+
document[html]
|
32
|
+
focustest
|
33
|
+
generate_npp_plugin
|
34
|
+
generate_registries
|
35
|
+
help
|
36
|
+
init
|
37
|
+
new
|
38
|
+
parallel
|
39
|
+
run
|
40
|
+
run_feature
|
41
|
+
sauce
|
42
|
+
setup
|
43
|
+
smoketest
|
44
|
+
testinstall
|
45
|
+
testproject
|
46
|
+
update
|
47
|
+
validate_service
|
48
|
+
-v
|
49
|
+
version
|
50
|
+
]
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def execute!
|
55
|
+
case @command
|
56
|
+
when 'create_update_task'
|
57
|
+
create_update_task
|
58
|
+
when 'generate_npp_plugin'
|
59
|
+
generate_npp_plugin
|
60
|
+
when 'generate_registries'
|
61
|
+
generate_registries
|
62
|
+
when 'help'
|
63
|
+
puts help_text
|
64
|
+
when 'init'
|
65
|
+
initialize_project_in
|
66
|
+
when 'new'
|
67
|
+
create_new_project
|
68
|
+
when 'parallel'
|
69
|
+
run_in_parallel
|
70
|
+
when 'run'
|
71
|
+
run_as_cucumber
|
72
|
+
when 'run_feature'
|
73
|
+
run_feature
|
74
|
+
when 'setup'
|
75
|
+
setup_SimpliTest
|
76
|
+
when 'smoketest'
|
77
|
+
perform_smoke_test
|
78
|
+
when 'testinstall'
|
79
|
+
run_as_rake
|
80
|
+
when 'testproject'
|
81
|
+
testproject
|
82
|
+
when 'update'
|
83
|
+
`gem update SimpliTest`
|
84
|
+
when 'validate_service'
|
85
|
+
validate_service
|
86
|
+
when '-v', 'version'
|
87
|
+
puts "SimpliTest: v#{SimpliTest::VERSION}"
|
88
|
+
when '',nil
|
89
|
+
alert(framework_correctly_installed_message)
|
90
|
+
else
|
91
|
+
if @valid_commands.include?(@command)
|
92
|
+
alert "This feature has been deprecated. Please see the documentation folder in your project for help"
|
93
|
+
else
|
94
|
+
alert "You entered an invalid command"
|
95
|
+
end
|
96
|
+
@kernel.exit(0)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
=begin
|
100
|
+
*********************************************-------------------****************************************************************************
|
101
|
+
********************************************| CUCUMBER COMMANDS |***************************************************************************
|
102
|
+
*********************************************-------------------****************************************************************************
|
103
|
+
=end
|
104
|
+
|
105
|
+
|
106
|
+
def run_as_cucumber(args = @arguments.dup, verify_file_exists=false)
|
107
|
+
if verify_file_exists
|
108
|
+
unless File.exists? args.first
|
109
|
+
alert "#{args.first} File was Not Found. Could not run tests"
|
110
|
+
raise "FileNotFoundError"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
@project_path ||= project_path_for(@pwd)
|
114
|
+
runtime = prepare_runtime
|
115
|
+
run_dir = @project_path
|
116
|
+
Dir.chdir(run_dir)
|
117
|
+
Cucumber::Cli::Main.new(args).execute!(runtime)
|
118
|
+
end
|
119
|
+
|
120
|
+
def run_in_parallel
|
121
|
+
raise "Parallelization is not supported on Windows" if windows?
|
122
|
+
begin
|
123
|
+
`parallel_cucumber features`
|
124
|
+
rescue Exception => e
|
125
|
+
message = "There was a problem running tests in parallel"
|
126
|
+
alert message
|
127
|
+
puts e.message
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def prepare_runtime
|
132
|
+
require 'cucumber'
|
133
|
+
runtime = Cucumber::Runtime.new
|
134
|
+
runtime.load_programming_language('rb')
|
135
|
+
runtime
|
136
|
+
end
|
137
|
+
|
138
|
+
def perform_smoke_test
|
139
|
+
@project_path ||= project_path_for(@pwd)
|
140
|
+
smoke_test = File.join(@project_path, 'features', 'specifications', 'SmokeTest')
|
141
|
+
run_as_cucumber([smoke_test], true)
|
142
|
+
end
|
143
|
+
|
144
|
+
def perform_focus_test
|
145
|
+
focus_path = File.join(project_path_for(@pwd), 'features', 'specifications', 'Focus')
|
146
|
+
run_as_cucumber([focus_path], true)
|
147
|
+
end
|
148
|
+
|
149
|
+
def testproject
|
150
|
+
#TODO: Write a utility that verifies project configuration. See list below:
|
151
|
+
#YAML errors in config files
|
152
|
+
#Missing Files
|
153
|
+
#Access to Gem Step definitions
|
154
|
+
#Basically anything the user can break by changing something in the test project
|
155
|
+
@project_path ||= project_path_for(@pwd)
|
156
|
+
Dir.chdir @project_path
|
157
|
+
begin
|
158
|
+
`cucumber --dry-run`
|
159
|
+
alert('Finished checking the project. If you do not see any errors on the command prompt..you are good to go')
|
160
|
+
rescue Exception => e
|
161
|
+
message = "It seems that your project directory is corrupted \n It maybe possible for you to simply generate a new project and copy your test cases over. "
|
162
|
+
alert(message)
|
163
|
+
puts e.message
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
def run_feature
|
169
|
+
feature = @arguments.first
|
170
|
+
feature = File.exists?(feature) ? feature : File.join(project_path_for(@pwd), 'features', 'specifications', feature)
|
171
|
+
run_as_cucumber([feature], true)
|
172
|
+
end
|
173
|
+
=begin
|
174
|
+
*********************************************-------------------****************************************************************************
|
175
|
+
********************************************| CUCUMBER COMMANDS |***************************************************************************
|
176
|
+
*********************************************-------------------****************************************************************************
|
177
|
+
=end
|
178
|
+
|
179
|
+
=begin
|
180
|
+
*********************************************-------------------****************************************************************************
|
181
|
+
********************************************| PROJECT SETUP |***************************************************************************
|
182
|
+
*********************************************-------------------****************************************************************************
|
183
|
+
=end
|
184
|
+
|
185
|
+
## Invoked with SimpliTest new <project name>
|
186
|
+
## Creates a new example project with the <project name> with sample test cases and documentation
|
187
|
+
def create_new_project
|
188
|
+
if user_consents?
|
189
|
+
unless project_exists_in?(@pwd)
|
190
|
+
new_dir_name = @arguments.join(' ')
|
191
|
+
new_dir_path = (File.join(@pwd, new_dir_name))
|
192
|
+
make_directory(new_dir_path)
|
193
|
+
initialize_project_in(new_dir_path, true)
|
194
|
+
else
|
195
|
+
alert "You cant create a project inside an existing project!"
|
196
|
+
end
|
197
|
+
else
|
198
|
+
alert abort_message
|
199
|
+
end
|
200
|
+
end
|
201
|
+
## Invoked inside a directory with SimpliTest init
|
202
|
+
## Creates a new SimpliTest project within the current directory
|
203
|
+
# @param target_directory
|
204
|
+
# @param user_has_consented (true if user types or clicks yes)
|
205
|
+
def initialize_project_in(target_directory=@pwd, user_has_consented=false)
|
206
|
+
if (user_has_consented|| user_consents?)
|
207
|
+
if (project_exists_in?(target_directory))
|
208
|
+
alert directory_exists_message
|
209
|
+
else
|
210
|
+
project_template_dir = template_path_to 'NewSimpliTestProject'
|
211
|
+
FileUtils.cp_r(Dir[File.join(project_template_dir, '*')], target_directory)
|
212
|
+
alert("Successfully Initialized Project!")
|
213
|
+
end
|
214
|
+
else
|
215
|
+
alert abort_message
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
=begin
|
220
|
+
*********************************************-------------------****************************************************************************
|
221
|
+
********************************************| PROJECT SETUP |***************************************************************************
|
222
|
+
*********************************************-------------------****************************************************************************
|
223
|
+
=end
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
=begin
|
228
|
+
*********************************************-------------------****************************************************************************
|
229
|
+
********************************************| DATA VALIDATION |***************************************************************************
|
230
|
+
*********************************************-------------------****************************************************************************
|
231
|
+
=end
|
232
|
+
|
233
|
+
def validate_service
|
234
|
+
args = @arguments.dup
|
235
|
+
load_db_options
|
236
|
+
if args.empty?
|
237
|
+
validate_all_services
|
238
|
+
else
|
239
|
+
args.each do |service_name|
|
240
|
+
validate_service_by_name(service_name)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def load_db_options
|
246
|
+
require 'tiny_tds'
|
247
|
+
require 'csv'
|
248
|
+
extend DataValidationHelpers
|
249
|
+
@project_path ||= project_path_for(@pwd)
|
250
|
+
database_config = File.join(@project_path, 'features', 'support', 'config', 'database.yml')
|
251
|
+
options = YAML.load(File.read(database_config))
|
252
|
+
@db = TinyTds::Client.new(options)
|
253
|
+
end
|
254
|
+
|
255
|
+
def validate_all_services
|
256
|
+
services_dir_glob_pattern = File.join(@project_path, 'data', '*', File::SEPARATOR)
|
257
|
+
services = Dir.glob(services_dir_glob_pattern).collect{|k| k.split(File::SEPARATOR).last}
|
258
|
+
services.each do |service|
|
259
|
+
puts "Running Test for: #{service}"
|
260
|
+
validate_service_by_name service
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def validate_service_by_name(name)
|
265
|
+
service_config_dir = File.join(@project_path, 'data', name)
|
266
|
+
variables_file = File.join(service_config_dir, 'variables.csv')
|
267
|
+
variables_csv = CSV.read(variables_file, :headers => true)
|
268
|
+
variables_hash = variables_csv.reject{|r| r.empty?}.map {|r| r.to_hash }
|
269
|
+
variables_hash.each do |set|
|
270
|
+
validate_service_against(@db, service_config_dir, set)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
=begin
|
275
|
+
*********************************************-------------------****************************************************************************
|
276
|
+
********************************************| DATA VALIDATION |***************************************************************************
|
277
|
+
*********************************************-------------------****************************************************************************
|
278
|
+
=end
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
def run_as_rake(from_dir=@pwd)
|
285
|
+
require 'rake'
|
286
|
+
require 'pp'
|
287
|
+
Dir.chdir(@gem_dir) # We'll load rakefile from the gem's dir.
|
288
|
+
Rake.application.init
|
289
|
+
Rake.application.load_rakefile
|
290
|
+
Dir.chdir(from_dir)
|
291
|
+
Rake.application.invoke_task(@command)
|
292
|
+
end
|
293
|
+
|
294
|
+
def help_text
|
295
|
+
#TODO: Write a man page
|
296
|
+
'You have been helped!!'
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
end #end self << class. Any methods below this are instance methods
|
301
|
+
end#end Main
|
302
|
+
end#end Cli
|
303
|
+
end#end SimpliTest
|
304
|
+
|
305
|
+
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require 'SimpliTest/config/directory_paths'
|
3
|
+
# Loads configuration from satelite projects
|
4
|
+
module SimpliTest
|
5
|
+
@config = {
|
6
|
+
:support_directory => nil,
|
7
|
+
:environments_file => nil,
|
8
|
+
:pages_file => nil,
|
9
|
+
:selectors_file => nil,
|
10
|
+
:settings_file => nil,
|
11
|
+
:environments => nil,
|
12
|
+
:pages => nil,
|
13
|
+
:selectors => nil,
|
14
|
+
:settings => nil,
|
15
|
+
:environment => nil
|
16
|
+
}
|
17
|
+
@valid_config_keys = @config.keys
|
18
|
+
|
19
|
+
class << self
|
20
|
+
|
21
|
+
#TODO: Improve the documentation below
|
22
|
+
=begin
|
23
|
+
****************************************************************
|
24
|
+
Load Order/ Dependencies
|
25
|
+
****************************************************************
|
26
|
+
|
27
|
+
********TEST PROJECTS****************
|
28
|
+
In Test Projects, first load this file
|
29
|
+
Then set any config variables
|
30
|
+
Then load the environments file in the @config_dir
|
31
|
+
The environments file loads the steps directory
|
32
|
+
Steps Directory is self sufficient (no external files need to be loaded)
|
33
|
+
**************************************
|
34
|
+
|
35
|
+
********BIN STUBS*********************
|
36
|
+
The gem has one bin stub: SimpliTest
|
37
|
+
This simply executes a method in the Main class with @cli_directory
|
38
|
+
The Main class in the cli dir requires @helpers_dir and @tasks_dir
|
39
|
+
***************************************
|
40
|
+
|
41
|
+
********RAKE TASKS*********************
|
42
|
+
Some cli commands execute rake tasks in the @tasks_dir
|
43
|
+
@tasks_dir requires @helpers_dir
|
44
|
+
***************************************
|
45
|
+
|
46
|
+
*****************************************************************
|
47
|
+
=end
|
48
|
+
|
49
|
+
def configure(opts={})
|
50
|
+
opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
|
51
|
+
load_configuration
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_path_for(key)
|
55
|
+
File.join(@config[:support_directory], 'config', "#{key.to_s}.yml")
|
56
|
+
end
|
57
|
+
|
58
|
+
def read_from(path_to_file)
|
59
|
+
begin
|
60
|
+
YAML::load(IO.read(path_to_file))
|
61
|
+
rescue Errno::ENOENT
|
62
|
+
alert ("Expected to find #{path_to_file} but did not find it.")
|
63
|
+
rescue Psych::SyntaxError
|
64
|
+
alert "#{path_to_file} YAML file contains invalid syntax. Please correct it"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def config
|
69
|
+
@config
|
70
|
+
end
|
71
|
+
|
72
|
+
def load_configuration
|
73
|
+
begin
|
74
|
+
@config[:environments] = read_from(@config[:environments_file] || default_path_for(:environments))
|
75
|
+
@config[:pages] = read_from(@config[:pages_file] || default_path_for(:pages))
|
76
|
+
@config[:selectors] = read_from(@config[:selectors_file] || default_path_for(:selectors))
|
77
|
+
@config[:settings] = read_from(@config[:settings_file] || default_path_for(:settings))
|
78
|
+
@config[:environment] = ENV['ENVIRONMENT'] || @config[:settings]['DEFAULT_ENVIRONMENT'] || @config[:settings][:environments].values.first
|
79
|
+
@valid_config_keys = @config.keys
|
80
|
+
rescue Exception => e
|
81
|
+
alert "There was a problem reading one of the required configuration files\n" + e.message
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def driver
|
86
|
+
ENV['SimpliTest_DRIVER'] || @config[:settings]['DRIVER'] || 'selenium'
|
87
|
+
end
|
88
|
+
|
89
|
+
def driver=(name)
|
90
|
+
@config[:driver]=name
|
91
|
+
end
|
92
|
+
|
93
|
+
def mode
|
94
|
+
@config[:settings]['MODE'] || 'REGULAR'
|
95
|
+
end
|
96
|
+
|
97
|
+
def screen_size
|
98
|
+
ENV['SCREEN_SIZE'] || @config[:settings]['SCREEN_SIZE'] || 'Desktop'
|
99
|
+
end
|
100
|
+
|
101
|
+
def wait_for_page_load
|
102
|
+
@config[:settings]['WAIT_FOR_PAGE_LOAD'].to_i rescue 0
|
103
|
+
end
|
104
|
+
|
105
|
+
end #end self << class all methods below this are instance methods
|
106
|
+
|
107
|
+
end
|