SimpliTest 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -21
  3. data/SimpliTest.gemspec +42 -42
  4. data/bin/SimpliTest +22 -22
  5. data/lib/SimpliTest.rb +2 -2
  6. data/lib/SimpliTest/cli/main.rb +333 -333
  7. data/lib/SimpliTest/config/configuration.rb +107 -107
  8. data/lib/SimpliTest/config/directory_paths.rb +36 -36
  9. data/lib/SimpliTest/config/environment.rb +67 -67
  10. data/lib/SimpliTest/config/local_environment.rb +20 -20
  11. data/lib/SimpliTest/config/profiles/chrome.rb +18 -18
  12. data/lib/SimpliTest/config/profiles/firefox.rb +14 -14
  13. data/lib/SimpliTest/config/profiles/internet_explorer.rb +11 -11
  14. data/lib/SimpliTest/config/profiles/phantom.rb +9 -9
  15. data/lib/SimpliTest/config/profiles/phantom_debug.rb +12 -12
  16. data/lib/SimpliTest/config/profiles/selenium.rb +13 -13
  17. data/lib/SimpliTest/config/screen_size.rb +25 -25
  18. data/lib/SimpliTest/config/steps.rb +8 -8
  19. data/lib/SimpliTest/helpers/data_validation.rb +60 -60
  20. data/lib/SimpliTest/helpers/file.rb +38 -38
  21. data/lib/SimpliTest/helpers/project_setup.rb +186 -186
  22. data/lib/SimpliTest/helpers/step_helpers/custom_chrome_helpers.rb +14 -14
  23. data/lib/SimpliTest/helpers/step_helpers/custom_date_helpers.rb +64 -64
  24. data/lib/SimpliTest/helpers/step_helpers/custom_form_helpers.rb +66 -66
  25. data/lib/SimpliTest/helpers/step_helpers/custom_phantomjs_helpers.rb +49 -49
  26. data/lib/SimpliTest/helpers/step_helpers/custom_selenium_helpers.rb +41 -41
  27. data/lib/SimpliTest/helpers/step_helpers/html_selectors_helpers.rb +154 -154
  28. data/lib/SimpliTest/helpers/step_helpers/navigation_helpers.rb +206 -206
  29. data/lib/SimpliTest/helpers/step_helpers/tolerance_for_sync_issues.rb +38 -38
  30. data/lib/SimpliTest/helpers/step_helpers/within_helpers.rb +6 -6
  31. data/lib/SimpliTest/helpers/windows_ui.rb +51 -51
  32. data/lib/SimpliTest/steps/debugging_steps.rb +19 -19
  33. data/lib/SimpliTest/steps/form_steps.rb +348 -352
  34. data/lib/SimpliTest/steps/form_verification_steps.rb +189 -189
  35. data/lib/SimpliTest/steps/navigation_steps.rb +58 -47
  36. data/lib/SimpliTest/steps/scoper.rb +42 -42
  37. data/lib/SimpliTest/steps/verification_steps.rb +306 -306
  38. data/lib/SimpliTest/tasks/document.rb +169 -169
  39. data/lib/SimpliTest/tasks/examples.rb +18 -18
  40. data/lib/SimpliTest/tasks/testinstall.rb +5 -5
  41. data/lib/SimpliTest/templates/NewSimpliTestProject/Readme.txt +4 -4
  42. data/lib/SimpliTest/templates/NewSimpliTestProject/cucumber.yml +26 -26
  43. data/lib/SimpliTest/templates/NewSimpliTestProject/documentation/step_definitions.html +88 -87
  44. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/RegressionTests/HelloWorld.feature +3 -3
  45. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/SmokeTest/HelloWorld.feature +3 -3
  46. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/accessibilityTests/HelloWorld.feature +3 -3
  47. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/environments.yml +10 -10
  48. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/pages.yml +26 -26
  49. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/selectors.yml +44 -44
  50. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/settings.yml +26 -26
  51. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/env.rb +33 -33
  52. data/lib/SimpliTest/templates/NewSimpliTestProject/license.txt +29 -29
  53. data/lib/SimpliTest/templates/document/css/style.css +28 -28
  54. data/lib/SimpliTest/templates/document/index.html +60 -60
  55. data/lib/version.rb +3 -3
  56. metadata +4 -4
@@ -1,107 +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
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
@@ -1,36 +1,36 @@
1
- require 'yaml'
2
- require 'pathname'
3
- require 'SimpliTest/helpers/project_setup'
4
- # exports instance variables for various directories of interest in the gem and the satelite projects
5
- module SimpliTest
6
- extend ProjectSetupHelpers
7
- @config_dir = File.dirname(__FILE__)
8
- @SimpliTest_dir = Pathname.new( @config_dir).parent.to_s
9
- @helpers_dir = File.join(@SimpliTest_dir, 'helpers')
10
- @steps_dir = File.join(@SimpliTest_dir, 'steps')
11
- @step_helpers_dir = File.join(@helpers_dir, 'step_helpers')
12
- @templates_dir = File.join(@SimpliTest_dir, 'templates')
13
- @lib_dir = Pathname.new(@SimpliTest_dir).parent.to_s
14
- @tasks_dir = File.join(@SimpliTest_dir, 'tasks')
15
- @gem_dir = Pathname.new(@lib_dir).parent.to_s
16
- class << self
17
- #TODO: Using method missing despite all the reasons not to
18
- #FIXME: Get rid of this
19
- def method_missing(meth, *args, &block)
20
- if match = meth.to_s.match(/^config_(.+)$/)
21
- config[match[1].to_sym]
22
- elsif match = meth.to_s.match(/^path_to_(.+)$/)
23
- instance_variable_get("@#{match[1]}")
24
- else
25
- super # You *must* call super if you don't handle the
26
- # method, otherwise you'll mess up Ruby's method
27
- # lookup.
28
- end
29
- end
30
-
31
- def respond_to_missing?(method_name, include_private = false)
32
- method_name.to_s.start_with?('config_') || meth.to_s.start_with?('path_to_') || super
33
- end
34
- end
35
-
36
- end
1
+ require 'yaml'
2
+ require 'pathname'
3
+ require 'SimpliTest/helpers/project_setup'
4
+ # exports instance variables for various directories of interest in the gem and the satelite projects
5
+ module SimpliTest
6
+ extend ProjectSetupHelpers
7
+ @config_dir = File.dirname(__FILE__)
8
+ @SimpliTest_dir = Pathname.new( @config_dir).parent.to_s
9
+ @helpers_dir = File.join(@SimpliTest_dir, 'helpers')
10
+ @steps_dir = File.join(@SimpliTest_dir, 'steps')
11
+ @step_helpers_dir = File.join(@helpers_dir, 'step_helpers')
12
+ @templates_dir = File.join(@SimpliTest_dir, 'templates')
13
+ @lib_dir = Pathname.new(@SimpliTest_dir).parent.to_s
14
+ @tasks_dir = File.join(@SimpliTest_dir, 'tasks')
15
+ @gem_dir = Pathname.new(@lib_dir).parent.to_s
16
+ class << self
17
+ #TODO: Using method missing despite all the reasons not to
18
+ #FIXME: Get rid of this
19
+ def method_missing(meth, *args, &block)
20
+ if match = meth.to_s.match(/^config_(.+)$/)
21
+ config[match[1].to_sym]
22
+ elsif match = meth.to_s.match(/^path_to_(.+)$/)
23
+ instance_variable_get("@#{match[1]}")
24
+ else
25
+ super # You *must* call super if you don't handle the
26
+ # method, otherwise you'll mess up Ruby's method
27
+ # lookup.
28
+ end
29
+ end
30
+
31
+ def respond_to_missing?(method_name, include_private = false)
32
+ method_name.to_s.start_with?('config_') || meth.to_s.start_with?('path_to_') || super
33
+ end
34
+ end
35
+
36
+ end
@@ -1,67 +1,67 @@
1
- require 'capybara'
2
- require 'capybara/cucumber'
3
- require 'capybara/dsl'
4
- require 'rspec'
5
- require "nokogiri"
6
- require 'open-uri'
7
- require_relative './local_environment'
8
- require_relative './screen_size'
9
- require_relative './steps'
10
- require File.join(SimpliTest.path_to_helpers_dir, 'project_setup')
11
- RSpec.configure do |config|
12
- config.include Capybara::DSL
13
- end
14
-
15
- Capybara.save_and_open_page_path = File.expand_path(File.join(SimpliTest.config_support_directory,'../../tmp')) if SimpliTest.config[:support_directory]
16
- Capybara.default_max_wait_time = 2
17
-
18
- driver = SimpliTest.driver #default is selenium
19
- profiles_dir = File.join(File.dirname(__FILE__), 'profiles')
20
- profiles = {
21
- 'phantomjs' => 'phantom',
22
- 'phantom_debug' => 'phantom_debug',
23
- 'chrome' => 'chrome',
24
- 'selenium' => 'selenium',
25
- 'ie' => 'internet_explorer',
26
- 'fire' => 'firefox'
27
- }
28
- profile = File.join profiles_dir, profiles[driver]
29
- require profile
30
- puts "Loaded Environment"
31
-
32
-
33
-
34
- #Leave the window open after a test fails if this tag is provided
35
- After('@leave_the_window_open') do |scenario|
36
- if scenario.respond_to?(:status) && scenario.status == :failed
37
- print "Step Failed. Press Return to close browser"
38
- STDIN.getc
39
- end
40
- end
41
-
42
- Before do |s|
43
- # if SimpliTest.env_or_setting('JIRA_INTEGRATION_ENABLED') && SimpliTest.env_or_setting('JIRA_URL')
44
- # $has_jira_info ||= false
45
- # return $has_jira_info if $has_jira_info
46
- # $jira = SimpliTest::JiraIntegration.load_project_details
47
- # $has_jira_info = true
48
- # end
49
- end
50
-
51
- After do |s|
52
-
53
- #Reuse Browser sessions
54
- if SimpliTest.config[:settings]['REUSE_BROWSER_SESSIONS']
55
- Capybara.current_session.instance_variable_set('@touched', !SimpliTest.config[:settings]['REUSE_BROWSER_SESSIONS'])
56
- else
57
- Capybara.current_session.instance_variable_set('@touched', true)
58
- end
59
-
60
- # Tell Cucumber to quit after this scenario is done - if it failed.
61
- #Cucumber.wants_to_quit = true if SimpliTest.config[:settings][QUIT_ON_FAIL] && s.failed?
62
- #zephyr_reporter = SimpliTest::JiraIntegration.new(s)
63
- #zephyr_reporter.report
64
- end
65
-
66
-
67
-
1
+ require 'capybara'
2
+ require 'capybara/cucumber'
3
+ require 'capybara/dsl'
4
+ require 'rspec'
5
+ require "nokogiri"
6
+ require 'open-uri'
7
+ require_relative './local_environment'
8
+ require_relative './screen_size'
9
+ require_relative './steps'
10
+ require File.join(SimpliTest.path_to_helpers_dir, 'project_setup')
11
+ RSpec.configure do |config|
12
+ config.include Capybara::DSL
13
+ end
14
+
15
+ Capybara.save_and_open_page_path = File.expand_path(File.join(SimpliTest.config_support_directory,'../../tmp')) if SimpliTest.config[:support_directory]
16
+ Capybara.default_max_wait_time = 2
17
+
18
+ driver = SimpliTest.driver #default is selenium
19
+ profiles_dir = File.join(File.dirname(__FILE__), 'profiles')
20
+ profiles = {
21
+ 'phantomjs' => 'phantom',
22
+ 'phantom_debug' => 'phantom_debug',
23
+ 'chrome' => 'chrome',
24
+ 'selenium' => 'selenium',
25
+ 'ie' => 'internet_explorer',
26
+ 'fire' => 'firefox'
27
+ }
28
+ profile = File.join profiles_dir, profiles[driver]
29
+ require profile
30
+ puts "Loaded Environment"
31
+
32
+
33
+
34
+ #Leave the window open after a test fails if this tag is provided
35
+ After('@leave_the_window_open') do |scenario|
36
+ if scenario.respond_to?(:status) && scenario.status == :failed
37
+ print "Step Failed. Press Return to close browser"
38
+ STDIN.getc
39
+ end
40
+ end
41
+
42
+ Before do |s|
43
+ # if SimpliTest.env_or_setting('JIRA_INTEGRATION_ENABLED') && SimpliTest.env_or_setting('JIRA_URL')
44
+ # $has_jira_info ||= false
45
+ # return $has_jira_info if $has_jira_info
46
+ # $jira = SimpliTest::JiraIntegration.load_project_details
47
+ # $has_jira_info = true
48
+ # end
49
+ end
50
+
51
+ After do |s|
52
+
53
+ #Reuse Browser sessions
54
+ if SimpliTest.config[:settings]['REUSE_BROWSER_SESSIONS']
55
+ Capybara.current_session.instance_variable_set('@touched', !SimpliTest.config[:settings]['REUSE_BROWSER_SESSIONS'])
56
+ else
57
+ Capybara.current_session.instance_variable_set('@touched', true)
58
+ end
59
+
60
+ # Tell Cucumber to quit after this scenario is done - if it failed.
61
+ #Cucumber.wants_to_quit = true if SimpliTest.config[:settings][QUIT_ON_FAIL] && s.failed?
62
+ #zephyr_reporter = SimpliTest::JiraIntegration.new(s)
63
+ #zephyr_reporter.report
64
+ end
65
+
66
+
67
+
@@ -1,20 +1,20 @@
1
- module SimpliTest
2
- def self.gems_installed?(list)
3
- specs = []
4
- list.each do |gem|
5
- dep = Gem::Dependency.new(gem)
6
- specs << !dep.matching_specs.empty?
7
- end
8
- specs.uniq == [true]
9
- end
10
-
11
- def self.chromedriver_detected?
12
- installed = `chromedriver --help` rescue false
13
- installed ? true : false
14
- end
15
-
16
- def self.env_or_setting(setting_name)
17
- ENV[setting_name] || SimpliTest.config_settings[setting_name]
18
- end
19
- end
20
-
1
+ module SimpliTest
2
+ def self.gems_installed?(list)
3
+ specs = []
4
+ list.each do |gem|
5
+ dep = Gem::Dependency.new(gem)
6
+ specs << !dep.matching_specs.empty?
7
+ end
8
+ specs.uniq == [true]
9
+ end
10
+
11
+ def self.chromedriver_detected?
12
+ installed = `chromedriver --help` rescue false
13
+ installed ? true : false
14
+ end
15
+
16
+ def self.env_or_setting(setting_name)
17
+ ENV[setting_name] || SimpliTest.config_settings[setting_name]
18
+ end
19
+ end
20
+