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,169 +1,169 @@
1
-
2
- =begin
3
- ##########Background###############
4
- This file adds a rake task to generate documentation for the Step Definitions available
5
- in this gem
6
- It basically reads each file in the web steps folder, looks for a step definition pattern and parses them
7
- into three columns:
8
- Step(Regex): The regular expression used by the Step Definition
9
- Example step in plain language: Exactly as you would use in your feature files
10
- Arguments the step definition accepts
11
-
12
- ################Usage:###############
13
- To print this on a Mac or a Linux system with the hirb gem installed: 'gem install hirb'
14
- simply type
15
- rake document
16
-
17
- On lesser systems :) (and of course of Mac and Linux too), generate a csv with:
18
- rake document[csv]
19
-
20
- ZSH(and some other shell) users, escape the argument with:
21
- rake document\[csv\]
22
- =end
23
-
24
- desc 'List all defined steps'
25
- task :document, :format do |t, args|
26
- format = args[:format]
27
- initialize_variables
28
- if format == 'csv'
29
- @csv = true
30
- require 'csv'
31
- CSV.open('step_definitions.csv', 'w') do |csv|
32
- csv << @columns
33
- generate_steps_document(csv)
34
- end
35
- alert "SUCCESS::Documentation generated in step_definitions.csv"
36
- elsif format == 'html'
37
- @html = true
38
- initialize_html_variables
39
- @html_content = @html_content.gsub('@header_row', generate_table_row_from(@columns, true))
40
- generate_steps_document
41
- FileUtils.cp(@html_document, @new_project_documentation_dir)
42
- alert "SUCCESS::Documentation generated in step_definitions.html"
43
- else
44
- if hirb_installed?
45
- require 'hirb'
46
- extend Hirb::Console
47
- generate_steps_document
48
- else
49
- puts "Please either pass a format identifier like 'document[html] document[csv] or gem install hirb for console output'"
50
- end
51
- end
52
- end
53
-
54
- def initialize_variables
55
- #@potential_step = /^\s*(?:Given|When|Then|And)\s+|\//
56
- @gem_dir = SimpliTest.path_to_gem_dir
57
- @step_regex = /(?:Given|When|Then|And)[\s\(]*\/(.*)\/([imxo]*)[\s\)]*do\s*(?:$|\|(.*)\|)/
58
- @step_definition_dir = SimpliTest.path_to_steps_dir
59
- @example_regex = /#Example:(.*)/
60
- @columns = [:category, :step, :example, :arguments]
61
- end
62
-
63
- def initialize_html_variables
64
- @templates_dir = SimpliTest.path_to_templates_dir
65
- @new_project_documentation_dir = File.join(@templates_dir, 'NewSimpliTestProject', 'documentation')
66
- @html_template = File.join(@templates_dir, "document/index.html")
67
- @html_dir = File.join(@templates_dir, "document")
68
- @html_content = File.join(@gem_dir, File.read(@html_template))
69
- @css_file = File.join(@templates_dir, "document/css/style.css")
70
- @html_document = "step_definitions.html"
71
- @table_body = ''
72
- end
73
-
74
- def generate_steps_document(csv=nil)
75
- print_heading_on_console
76
- Dir.glob(File.join(@step_definition_dir,'*.rb')).each do |step_file|
77
- print_file_name_for(step_file, csv)
78
- results = []
79
- File.new(step_file).read.each_line.each_cons(3) do |previous_line, line, next_line|
80
- #next unless line =~ @potential_step
81
- step_match = @step_regex.match(line)
82
- next unless step_match
83
- example_match = @example_regex.match(previous_line)
84
- example = example_match ? example_match[1] : 'N/A'
85
- matches = step_match.captures
86
- results << capture_row_with(matches, example, csv, @category)
87
- end
88
- print_on_console(results)
89
- generate_html_document if @html
90
- end
91
- end
92
-
93
-
94
- def print_heading_on_console
95
- return if @csv || @html
96
- puts "CUCUMBER steps:"
97
- puts ""
98
- end
99
-
100
- def print_file_name_for(step_file, csv)
101
- @category = category_from(step_file)
102
- if csv
103
- elsif @html
104
- else
105
- puts "Category: #{@category}"
106
- puts ""
107
- end
108
- end
109
-
110
- def print_on_console(results)
111
- return if @csv || @html
112
- table results, :resize => false, :fields => [:step, :example, :arguments]
113
- puts ""
114
- puts ""
115
- end
116
-
117
- def capture_row_with(matches, example, csv, file_name)
118
- step_elements = value_of([file_name, matches[0], example, matches[2]])
119
- if csv
120
- csv << step_elements
121
- elsif @html
122
- @table_body << generate_table_row_from(step_elements)
123
- else
124
- OpenStruct.new(
125
- :step => value_of(matches[0]),
126
- :example => value_of(example),
127
- :arguments => value_of(matches[2])
128
- )
129
- end
130
- end
131
-
132
- def generate_table_row_from(array, header=false)
133
- tag = header ? 'th' : 'td'
134
- row = array.map{|x| "<#{tag}>#{x}</#{tag}>"}.join
135
- "<tr>#{row}</tr>"
136
- end
137
-
138
- def generate_html_document
139
- content = @html_content.gsub('@table_body', @table_body)
140
- content_with_responsive_label = content.gsub('@responsive_label', responsive_labels_for(@columns))
141
- css = File.read(@css_file)
142
- content_with_css = content_with_responsive_label.gsub('@css', css)
143
- content_with_version_number = content_with_css.gsub('@version', SimpliTest::VERSION)
144
- document = File.open(@html_document, "w") {|file| file.write(content_with_version_number)}
145
- end
146
-
147
- def responsive_labels_for(array)
148
- label = ''
149
- array.each_with_index.collect do |header, index|
150
- label << "td:nth-of-type(#{index+1}):before { content: '#{header}'; }"
151
- end
152
- label
153
- end
154
-
155
- def value_of(value)
156
- return value.map {|member| value_of(member) } if value.is_a?(Array)
157
- (value.nil? || value.empty?) ? 'N/A' : value
158
- end
159
-
160
- def category_from(file_name)
161
- File.basename(file_name).gsub(/\.rb/,'').gsub(/_/,' ').gsub(/steps/,'')
162
- end
163
-
164
- def hirb_installed?
165
- dep = Gem::Dependency.new('hirb')
166
- hirb = dep.matching_specs
167
- !hirb.empty?
168
- end
169
-
1
+
2
+ =begin
3
+ ##########Background###############
4
+ This file adds a rake task to generate documentation for the Step Definitions available
5
+ in this gem
6
+ It basically reads each file in the web steps folder, looks for a step definition pattern and parses them
7
+ into three columns:
8
+ Step(Regex): The regular expression used by the Step Definition
9
+ Example step in plain language: Exactly as you would use in your feature files
10
+ Arguments the step definition accepts
11
+
12
+ ################Usage:###############
13
+ To print this on a Mac or a Linux system with the hirb gem installed: 'gem install hirb'
14
+ simply type
15
+ rake document
16
+
17
+ On lesser systems :) (and of course of Mac and Linux too), generate a csv with:
18
+ rake document[csv]
19
+
20
+ ZSH(and some other shell) users, escape the argument with:
21
+ rake document\[csv\]
22
+ =end
23
+
24
+ desc 'List all defined steps'
25
+ task :document, :format do |t, args|
26
+ format = args[:format]
27
+ initialize_variables
28
+ if format == 'csv'
29
+ @csv = true
30
+ require 'csv'
31
+ CSV.open('step_definitions.csv', 'w') do |csv|
32
+ csv << @columns
33
+ generate_steps_document(csv)
34
+ end
35
+ alert "SUCCESS::Documentation generated in step_definitions.csv"
36
+ elsif format == 'html'
37
+ @html = true
38
+ initialize_html_variables
39
+ @html_content = @html_content.gsub('@header_row', generate_table_row_from(@columns, true))
40
+ generate_steps_document
41
+ FileUtils.cp(@html_document, @new_project_documentation_dir)
42
+ alert "SUCCESS::Documentation generated in step_definitions.html"
43
+ else
44
+ if hirb_installed?
45
+ require 'hirb'
46
+ extend Hirb::Console
47
+ generate_steps_document
48
+ else
49
+ puts "Please either pass a format identifier like 'document[html] document[csv] or gem install hirb for console output'"
50
+ end
51
+ end
52
+ end
53
+
54
+ def initialize_variables
55
+ #@potential_step = /^\s*(?:Given|When|Then|And)\s+|\//
56
+ @gem_dir = SimpliTest.path_to_gem_dir
57
+ @step_regex = /(?:Given|When|Then|And)[\s\(]*\/(.*)\/([imxo]*)[\s\)]*do\s*(?:$|\|(.*)\|)/
58
+ @step_definition_dir = SimpliTest.path_to_steps_dir
59
+ @example_regex = /#Example:(.*)/
60
+ @columns = [:category, :step, :example, :arguments]
61
+ end
62
+
63
+ def initialize_html_variables
64
+ @templates_dir = SimpliTest.path_to_templates_dir
65
+ @new_project_documentation_dir = File.join(@templates_dir, 'NewSimpliTestProject', 'documentation')
66
+ @html_template = File.join(@templates_dir, "document/index.html")
67
+ @html_dir = File.join(@templates_dir, "document")
68
+ @html_content = File.join(@gem_dir, File.read(@html_template))
69
+ @css_file = File.join(@templates_dir, "document/css/style.css")
70
+ @html_document = "step_definitions.html"
71
+ @table_body = ''
72
+ end
73
+
74
+ def generate_steps_document(csv=nil)
75
+ print_heading_on_console
76
+ Dir.glob(File.join(@step_definition_dir,'*.rb')).each do |step_file|
77
+ print_file_name_for(step_file, csv)
78
+ results = []
79
+ File.new(step_file).read.each_line.each_cons(3) do |previous_line, line, next_line|
80
+ #next unless line =~ @potential_step
81
+ step_match = @step_regex.match(line)
82
+ next unless step_match
83
+ example_match = @example_regex.match(previous_line)
84
+ example = example_match ? example_match[1] : 'N/A'
85
+ matches = step_match.captures
86
+ results << capture_row_with(matches, example, csv, @category)
87
+ end
88
+ print_on_console(results)
89
+ generate_html_document if @html
90
+ end
91
+ end
92
+
93
+
94
+ def print_heading_on_console
95
+ return if @csv || @html
96
+ puts "CUCUMBER steps:"
97
+ puts ""
98
+ end
99
+
100
+ def print_file_name_for(step_file, csv)
101
+ @category = category_from(step_file)
102
+ if csv
103
+ elsif @html
104
+ else
105
+ puts "Category: #{@category}"
106
+ puts ""
107
+ end
108
+ end
109
+
110
+ def print_on_console(results)
111
+ return if @csv || @html
112
+ table results, :resize => false, :fields => [:step, :example, :arguments]
113
+ puts ""
114
+ puts ""
115
+ end
116
+
117
+ def capture_row_with(matches, example, csv, file_name)
118
+ step_elements = value_of([file_name, matches[0], example, matches[2]])
119
+ if csv
120
+ csv << step_elements
121
+ elsif @html
122
+ @table_body << generate_table_row_from(step_elements)
123
+ else
124
+ OpenStruct.new(
125
+ :step => value_of(matches[0]),
126
+ :example => value_of(example),
127
+ :arguments => value_of(matches[2])
128
+ )
129
+ end
130
+ end
131
+
132
+ def generate_table_row_from(array, header=false)
133
+ tag = header ? 'th' : 'td'
134
+ row = array.map{|x| "<#{tag}>#{x}</#{tag}>"}.join
135
+ "<tr>#{row}</tr>"
136
+ end
137
+
138
+ def generate_html_document
139
+ content = @html_content.gsub('@table_body', @table_body)
140
+ content_with_responsive_label = content.gsub('@responsive_label', responsive_labels_for(@columns))
141
+ css = File.read(@css_file)
142
+ content_with_css = content_with_responsive_label.gsub('@css', css)
143
+ content_with_version_number = content_with_css.gsub('@version', SimpliTest::VERSION)
144
+ document = File.open(@html_document, "w") {|file| file.write(content_with_version_number)}
145
+ end
146
+
147
+ def responsive_labels_for(array)
148
+ label = ''
149
+ array.each_with_index.collect do |header, index|
150
+ label << "td:nth-of-type(#{index+1}):before { content: '#{header}'; }"
151
+ end
152
+ label
153
+ end
154
+
155
+ def value_of(value)
156
+ return value.map {|member| value_of(member) } if value.is_a?(Array)
157
+ (value.nil? || value.empty?) ? 'N/A' : value
158
+ end
159
+
160
+ def category_from(file_name)
161
+ File.basename(file_name).gsub(/\.rb/,'').gsub(/_/,' ').gsub(/steps/,'')
162
+ end
163
+
164
+ def hirb_installed?
165
+ dep = Gem::Dependency.new('hirb')
166
+ hirb = dep.matching_specs
167
+ !hirb.empty?
168
+ end
169
+
@@ -1,18 +1,18 @@
1
- drivers = %w(selenium phantom chrome)
2
- drivers_with_parallel = drivers + ["parallel"]
3
-
4
- task :default => drivers_with_parallel.map { |d| "examples:#{d}" }.flatten
5
-
6
- namespace :examples do
7
- drivers.each do |driver|
8
- Cucumber::Rake::Task.new(driver,"run features using #{driver}") do |t|
9
- t.profile=driver
10
- end
11
- end
12
- desc "run features using parallel_cucumber"
13
- task :parallel do
14
- puts "run features in parallel"
15
- `bundle exec parallel_cucumber features`
16
- end
17
- end
18
-
1
+ drivers = %w(selenium phantom chrome)
2
+ drivers_with_parallel = drivers + ["parallel"]
3
+
4
+ task :default => drivers_with_parallel.map { |d| "examples:#{d}" }.flatten
5
+
6
+ namespace :examples do
7
+ drivers.each do |driver|
8
+ Cucumber::Rake::Task.new(driver,"run features using #{driver}") do |t|
9
+ t.profile=driver
10
+ end
11
+ end
12
+ desc "run features using parallel_cucumber"
13
+ task :parallel do
14
+ puts "run features in parallel"
15
+ `bundle exec parallel_cucumber features`
16
+ end
17
+ end
18
+
@@ -1,5 +1,5 @@
1
- include ProjectSetupHelpers
2
- desc "Returns a message if the gem is installed"
3
- task :testinstall do
4
- alert framework_correctly_installed_message
5
- end
1
+ include ProjectSetupHelpers
2
+ desc "Returns a message if the gem is installed"
3
+ task :testinstall do
4
+ alert framework_correctly_installed_message
5
+ end
@@ -1,5 +1,5 @@
1
- SimpliTest- Readme
2
-
3
- Thanks for using SimpliTest!
4
-
1
+ SimpliTest- Readme
2
+
3
+ Thanks for using SimpliTest!
4
+
5
5
 
@@ -1,26 +1,26 @@
1
- # This file lets you create shortcuts for running your test suite.
2
- # The simplest use case for this would be when you have multiple environments (in the environments.yml file)
3
- # then you might want to create different profiles for each environment as such:
4
- # production: "ENVIRONMENT=Production -r features/support features"
5
- # testing: "ENVIRONMENT=Testing -r features/support features"
6
- # devb1: "ENVIRONMENT=DEVB1 -r features/support features"
7
- # Then you can run your tests against those environments with commands like these:
8
- # cucumber --profile testing
9
- # cucumber --profile devb1
10
- #
11
- # For a full description of options available here check out: https://github.com/cucumber/cucumber/wiki/cucumber.yml
12
- #
13
- <% common = '-r features/support features ' %>
14
- <% html = '--format html -o results.html ' %>
15
- <% test_number = ENV['TEST_ENV_NUMBER'].nil? || ENV['TEST_ENV_NUMBER'].empty? ? '1' : ENV['TEST_ENV_NUMBER'] %>
16
- <% parallel = "--format json -o results-#{test_number}.json " %>
17
- <% without_wip = '--tags ~@wip ' %>
18
- parallel: <%= parallel + without_wip + common %>
19
-
20
- # *********************************************************************************************
21
- # DO NOT DELETE OR MODIFY ANYTHING ABOVE THIS LINE
22
- # *********************************************************************************************
23
- default: <%= without_wip + html + common %>
24
- production: ENVIRONMENT=Production <%= without_wip + html + common %>
25
- test: ENVIRONMENT=Test <%= without_wip + html + common %>
26
- dev: ENVIRONMENT=Dev <%= without_wip + html + common %>
1
+ # This file lets you create shortcuts for running your test suite.
2
+ # The simplest use case for this would be when you have multiple environments (in the environments.yml file)
3
+ # then you might want to create different profiles for each environment as such:
4
+ # production: "ENVIRONMENT=Production -r features/support features"
5
+ # testing: "ENVIRONMENT=Testing -r features/support features"
6
+ # devb1: "ENVIRONMENT=DEVB1 -r features/support features"
7
+ # Then you can run your tests against those environments with commands like these:
8
+ # cucumber --profile testing
9
+ # cucumber --profile devb1
10
+ #
11
+ # For a full description of options available here check out: https://github.com/cucumber/cucumber/wiki/cucumber.yml
12
+ #
13
+ <% common = '-r features/support features ' %>
14
+ <% html = '--format html -o results.html ' %>
15
+ <% test_number = ENV['TEST_ENV_NUMBER'].nil? || ENV['TEST_ENV_NUMBER'].empty? ? '1' : ENV['TEST_ENV_NUMBER'] %>
16
+ <% parallel = "--format json -o results-#{test_number}.json " %>
17
+ <% without_wip = '--tags ~@wip ' %>
18
+ parallel: <%= parallel + without_wip + common %>
19
+
20
+ # *********************************************************************************************
21
+ # DO NOT DELETE OR MODIFY ANYTHING ABOVE THIS LINE
22
+ # *********************************************************************************************
23
+ default: <%= without_wip + html + common %>
24
+ production: ENVIRONMENT=Production <%= without_wip + html + common %>
25
+ test: ENVIRONMENT=Test <%= without_wip + html + common %>
26
+ dev: ENVIRONMENT=Dev <%= without_wip + html + common %>