howitzer 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +32 -0
  4. data/.travis.yml +1 -4
  5. data/.yardopts +1 -2
  6. data/CHANGELOG.md +28 -1
  7. data/Gemfile +6 -0
  8. data/LICENSE +1 -1
  9. data/README.md +55 -85
  10. data/Rakefile +7 -7
  11. data/bin/howitzer +56 -31
  12. data/features/cli_new.feature +162 -79
  13. data/features/cli_update.feature +114 -21
  14. data/features/step_definitions/common_steps.rb +29 -9
  15. data/features/support/env.rb +1 -1
  16. data/features/support/transformers.rb +2 -2
  17. data/generators/base_generator.rb +121 -49
  18. data/generators/config/config_generator.rb +8 -5
  19. data/generators/config/templates/boot.rb +14 -0
  20. data/generators/config/templates/capybara.rb +156 -0
  21. data/generators/config/templates/custom.yml +2 -3
  22. data/generators/config/templates/default.yml +50 -82
  23. data/generators/cucumber/cucumber_generator.rb +9 -9
  24. data/generators/cucumber/templates/common_steps.rb +4 -4
  25. data/generators/cucumber/templates/cucumber.rake +63 -54
  26. data/generators/cucumber/templates/env.rb +24 -23
  27. data/generators/cucumber/templates/transformers.rb +23 -15
  28. data/generators/emails/emails_generator.rb +4 -2
  29. data/generators/emails/templates/example_email.rb +4 -4
  30. data/generators/prerequisites/prerequisites_generator.rb +24 -0
  31. data/generators/prerequisites/templates/base.rb +22 -0
  32. data/generators/prerequisites/templates/factory_girl.rb +30 -0
  33. data/generators/prerequisites/templates/user.rb +7 -0
  34. data/generators/prerequisites/templates/users.rb +12 -0
  35. data/generators/root/root_generator.rb +11 -7
  36. data/generators/root/templates/.rubocop.yml +32 -0
  37. data/generators/root/templates/Gemfile.erb +27 -0
  38. data/generators/root/templates/Rakefile +6 -8
  39. data/generators/rspec/rspec_generator.rb +7 -7
  40. data/generators/rspec/templates/example_spec.rb +1 -1
  41. data/generators/rspec/templates/rspec.rake +48 -29
  42. data/generators/rspec/templates/spec_helper.rb +33 -32
  43. data/generators/tasks/tasks_generator.rb +4 -2
  44. data/generators/tasks/templates/common.rake +1 -16
  45. data/generators/turnip/templates/.rspec +1 -0
  46. data/generators/turnip/templates/common_steps.rb +25 -0
  47. data/generators/turnip/templates/example.feature +8 -0
  48. data/generators/turnip/templates/spec_helper.rb +56 -0
  49. data/generators/turnip/templates/turnip.rake +61 -0
  50. data/generators/turnip/templates/turnip_helper.rb +6 -0
  51. data/generators/turnip/turnip_generator.rb +26 -0
  52. data/generators/web/templates/example_page.rb +15 -0
  53. data/generators/web/templates/menu_section.rb +13 -0
  54. data/generators/web/web_generator.rb +22 -0
  55. data/howitzer.gemspec +14 -21
  56. data/lib/howitzer.rb +47 -7
  57. data/lib/howitzer/cache.rb +70 -0
  58. data/lib/howitzer/capybara_helpers.rb +194 -0
  59. data/lib/howitzer/email.rb +96 -104
  60. data/lib/howitzer/exceptions.rb +10 -6
  61. data/lib/howitzer/log.rb +120 -0
  62. data/lib/howitzer/mail_adapters.rb +7 -0
  63. data/lib/howitzer/mail_adapters/abstract.rb +84 -0
  64. data/lib/howitzer/mail_adapters/mailgun.rb +115 -0
  65. data/lib/howitzer/mailgun_api.rb +9 -0
  66. data/lib/howitzer/mailgun_api/client.rb +79 -0
  67. data/lib/howitzer/mailgun_api/connector.rb +37 -0
  68. data/lib/howitzer/mailgun_api/response.rb +28 -0
  69. data/lib/howitzer/tasks/framework.rake +2 -2
  70. data/lib/howitzer/utils.rb +7 -1
  71. data/lib/howitzer/utils/string_extensions.rb +66 -0
  72. data/lib/howitzer/version.rb +2 -1
  73. data/lib/howitzer/web.rb +11 -0
  74. data/lib/howitzer/web/base_section.rb +27 -0
  75. data/lib/howitzer/web/blank_page.rb +12 -0
  76. data/lib/howitzer/web/capybara_methods_proxy.rb +29 -0
  77. data/lib/howitzer/web/element_dsl.rb +109 -0
  78. data/lib/howitzer/web/iframe_dsl.rb +93 -0
  79. data/lib/howitzer/web/page.rb +173 -0
  80. data/lib/howitzer/web/page_dsl.rb +64 -0
  81. data/lib/howitzer/web/page_validator.rb +118 -0
  82. data/lib/howitzer/web/section.rb +27 -0
  83. data/lib/howitzer/web/section_dsl.rb +154 -0
  84. data/spec/config/custom.yml +10 -1
  85. data/spec/spec_helper.rb +37 -19
  86. data/spec/support/generator_helper.rb +12 -11
  87. data/spec/support/logger_helper.rb +10 -9
  88. data/spec/support/mailgun_unit_client.rb +52 -44
  89. data/spec/support/shared_examples/capybara_context_holder.rb +33 -0
  90. data/spec/support/shared_examples/capybara_methods_proxy.rb +94 -0
  91. data/spec/support/shared_examples/dynamic_section_methods.rb +35 -0
  92. data/spec/support/shared_examples/element_dsl.rb +119 -0
  93. data/spec/unit/generators/base_generator_spec.rb +64 -33
  94. data/spec/unit/generators/config_generator_spec.rb +11 -7
  95. data/spec/unit/generators/cucumber_generator_spec.rb +26 -17
  96. data/spec/unit/generators/emails_generator_spec.rb +10 -6
  97. data/spec/unit/generators/prerequisites_generator_spec.rb +53 -0
  98. data/spec/unit/generators/root_generator_spec.rb +50 -13
  99. data/spec/unit/generators/rspec_generator_spec.rb +9 -9
  100. data/spec/unit/generators/tasks_generator_spec.rb +6 -6
  101. data/spec/unit/generators/turnip_generator_spec.rb +52 -0
  102. data/spec/unit/generators/web_generator_spec.rb +52 -0
  103. data/spec/unit/lib/cache_spec.rb +85 -0
  104. data/spec/unit/lib/capybara_helpers_spec.rb +696 -0
  105. data/spec/unit/lib/email_spec.rb +104 -91
  106. data/spec/unit/lib/howitzer.rb +31 -0
  107. data/spec/unit/lib/init_spec.rb +0 -1
  108. data/spec/unit/lib/log_spec.rb +122 -0
  109. data/spec/unit/lib/mail_adapters/abstract_spec.rb +62 -0
  110. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +163 -0
  111. data/spec/unit/lib/mailgun_api/client_spec.rb +58 -0
  112. data/spec/unit/lib/mailgun_api/connector_spec.rb +54 -0
  113. data/spec/unit/lib/mailgun_api/response_spec.rb +28 -0
  114. data/spec/unit/lib/utils/string_extensions_spec.rb +77 -0
  115. data/spec/unit/lib/web/base_section_spec.rb +41 -0
  116. data/spec/unit/lib/web/element_dsl_spec.rb +17 -0
  117. data/spec/unit/lib/web/iframe_dsl_spec.rb +99 -0
  118. data/spec/unit/lib/web/page_dsl_spec.rb +52 -0
  119. data/spec/unit/lib/web/page_spec.rb +304 -0
  120. data/spec/unit/lib/web/page_validator_spec.rb +218 -0
  121. data/spec/unit/lib/web/section_dsl_spec.rb +165 -0
  122. data/spec/unit/lib/web/section_spec.rb +61 -0
  123. data/spec/unit/version_spec.rb +1 -1
  124. metadata +116 -203
  125. data/GETTING_STARTED.md +0 -774
  126. data/generators/cucumber/templates/cucumber.yml +0 -10
  127. data/generators/pages/pages_generator.rb +0 -21
  128. data/generators/pages/templates/example_menu.rb +0 -15
  129. data/generators/pages/templates/example_page.rb +0 -15
  130. data/generators/root/templates/Gemfile +0 -7
  131. data/generators/root/templates/boot.rb +0 -10
  132. data/lib/howitzer/blank_page.rb +0 -6
  133. data/lib/howitzer/capybara/dsl_ex.rb +0 -15
  134. data/lib/howitzer/capybara/settings.rb +0 -343
  135. data/lib/howitzer/helpers.rb +0 -230
  136. data/lib/howitzer/init.rb +0 -1
  137. data/lib/howitzer/mailgun/client.rb +0 -65
  138. data/lib/howitzer/mailgun/connector.rb +0 -34
  139. data/lib/howitzer/mailgun/response.rb +0 -28
  140. data/lib/howitzer/patches/rawler_patched.rb +0 -86
  141. data/lib/howitzer/settings.rb +0 -27
  142. data/lib/howitzer/utils/data_generator/data_storage.rb +0 -88
  143. data/lib/howitzer/utils/data_generator/gen.rb +0 -135
  144. data/lib/howitzer/utils/locator_store.rb +0 -217
  145. data/lib/howitzer/utils/log.rb +0 -139
  146. data/lib/howitzer/utils/page_validator.rb +0 -133
  147. data/lib/howitzer/vendor/firebug-1.12.1-fx.xpi +0 -0
  148. data/lib/howitzer/vendor/firepath-0.9.7-fx.xpi +0 -0
  149. data/lib/howitzer/web_page.rb +0 -253
  150. data/spec/active_resource.rb +0 -0
  151. data/spec/config/default.yml +0 -26
  152. data/spec/support/boot_helper.rb +0 -15
  153. data/spec/unit/generators/pages_generator_spec.rb +0 -33
  154. data/spec/unit/lib/capybara/dsl_ex_spec.rb +0 -60
  155. data/spec/unit/lib/capybara/settings_spec.rb +0 -441
  156. data/spec/unit/lib/helpers_spec.rb +0 -1129
  157. data/spec/unit/lib/mailgun/client_spec.rb +0 -36
  158. data/spec/unit/lib/mailgun/connector_spec.rb +0 -70
  159. data/spec/unit/lib/mailgun/response_spec.rb +0 -28
  160. data/spec/unit/lib/settings_spec.rb +0 -17
  161. data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +0 -80
  162. data/spec/unit/lib/utils/data_generator/gen_spec.rb +0 -90
  163. data/spec/unit/lib/utils/locator_store_spec.rb +0 -157
  164. data/spec/unit/lib/utils/log_spec.rb +0 -107
  165. data/spec/unit/lib/utils/page_validator_spec.rb +0 -265
  166. data/spec/unit/lib/web_page_spec.rb +0 -346
@@ -1,5 +1,4 @@
1
1
  app_host: localhost:3000
2
- maximized_window: true
3
2
  driver: selenium
4
- sel_browser: chrome
5
- debug_mode: true
3
+ selenium_browser: chrome
4
+ debug_mode: true
@@ -1,8 +1,3 @@
1
- ###########################################################
2
- # COMMON SETTINGS #
3
- ###########################################################
4
- debug_mode: false
5
-
6
1
  ###########################################################
7
2
  # APPLICATION SETTINGS #
8
3
  ###########################################################
@@ -11,109 +6,82 @@
11
6
  app_protocol: http
12
7
  app_host: my.website.com
13
8
 
14
- def_test_user: test@test.com
15
- def_test_pass: mypass
16
- def_test_name: Auto Tester
9
+ app_test_user: test@test.com
10
+ app_test_pass: mypass
11
+ app_test_user_name: Auto Tester
12
+
13
+ app_api_token:
14
+ app_api_end_point: "api/v1"
17
15
 
18
16
  ###########################################################
19
17
  # TEST ENVIRONMENTS SETTINGS #
20
18
  ###########################################################
19
+ page_load_idle_timeout: 20
20
+ maximized_window: true # Specify maximized browser window size
21
21
 
22
- # Specify maximized browser window size
23
- maximized_window: false
24
-
25
- # Specify one of the following drivers: selenium, selenium_dev, selenium_grid, webkit, poltergeist, phantomjs, sauce, testingbot, browserstack
22
+ # Specify one of the following drivers: selenium, selenium_grid, webkit, poltergeist, phantomjs, sauce,
23
+ # testingbot, browserstack
26
24
  driver: phantomjs
27
25
 
28
26
  # -Selenium-
29
- # specify one of next browsers: iexplore (ie), firefox (ff), chrome, opera, safari
30
- sel_browser: ff
27
+ # specify one of next browsers: iexplore (ie), firefox (ff), chrome, safari
28
+ selenium_browser: ff
31
29
 
32
30
  # -Selenium Grid-
33
- sel_hub_url: "http://example.com:4444/wd/hub"
31
+ selenium_hub_url: "http://example.com:4444/wd/hub"
34
32
 
35
- # -PhantomJS-
33
+ # -PhantomJS/Poltergeist-
36
34
  # specify settings for poltergeist
37
- pjs_ignore_js_errors: false
38
- pjs_ignore_ssl_errors: true
39
-
40
- # -SauceLabs-
41
- sl_user: some_user
42
- sl_api_key: some_api_key
43
- sl_url: "http://${sl_user}:${sl_api_key}@ondemand.saucelabs.com:80/wd/hub"
44
- sl_platform: :VISTA
45
- sl_browser_name: firefox
46
- sl_selenium_version: "2.18.0"
47
- sl_max_duration: '1800'
48
- sl_idle_timeout: '180'
49
-
50
- # -TestingBot- browsers that are supported: firefox => '8', googlechrome, iexplore => '9'
51
- tb_api_key: client_key
52
- tb_api_secret: client_secret
53
- tb_url: "http://${tb_api_key}:${tb_api_secret}@hub.testingbot.com:80/wd/hub"
54
- tb_platform: :WIN8
55
- tb_browser_name: firefox
56
- tb_browser_version: 8
57
- tb_selenium_version: "2.18.0"
58
- tb_max_duration: '1800'
59
- tb_idle_timeout: '180'
60
- tb_record_screenshot: false
61
-
62
- # -BrowserStack
63
- bs_user_name: bs_user
64
- bs_password: bs_password
65
- bs_url: "http://${bs_user_name}:${bs_password}@hub.browserstack.com/wd/hub"
66
- bs_os_name: 'Windows'
67
- bs_os_version: '8'
68
- bs_browser_name: 'Firefox'
69
- bs_browser_version: '16.0'
70
- bs_resolution: '1024x768'
71
- bs_max_duration: '1800'
72
- bs_idle_timeout: '180'
73
-
74
- # Run tests on mobile browsers
75
- bs_mobile: false
76
- bs_m_browser: 'iPhone'
77
- bs_m_platform: 'MAC'
78
- bs_m_device: 'iPhone 5'
79
-
80
- bs_local: 'false'
81
- bs_local_ID: 'Testing123'
82
- bs_build: 'v1'
83
- bs_project: 'Test Project'
84
- bs_ssl: 'true'
85
- bs_debug: 'false'
35
+ phantom_ignore_js_errors: false
36
+ phantom_ignore_ssl_errors: true
86
37
 
87
38
  ###########################################################
88
- # DATABASE SETTINGS #
39
+ # Cloud-based Cross-browser Services #
89
40
  ###########################################################
41
+ cloud_auth_login: some_user_or_client_key
42
+ cloud_auth_pass: api_key_or_api_secret_or_access_key
43
+ cloud_platform: any
44
+ cloud_browser_name: Chrome
45
+ cloud_browser_version: '31'
46
+ cloud_max_duration: '1800'
47
+ cloud_http_idle_timeout: 40
48
+
49
+ # -SauceLabs- (https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options)
50
+ cloud_sauce_record_screenshots: false
51
+ cloud_sauce_idle_timeout: '180'
52
+ cloud_sauce_video_upload_on_pass: false
53
+
54
+ # -TestingBot- (https://testingbot.com/support/other/test-options)
55
+ cloud_testingbot_idle_timeout: '180'
56
+ cloud_testingbot_screenshots: false
57
+
58
+ # -BrowserStack (https://www.browserstack.com/automate/capabilities)
59
+ cloud_bstack_resolution: '1024x768'
60
+ cloud_bstack_project: 'Howitzer Example'
61
+ cloud_bstack_build: 'v1'
62
+ cloud_bstack_resolution: '1024x768'
63
+ cloud_bstack_mobile_device:
90
64
 
91
-
65
+ ###########################################################
66
+ # CAPYBARA SETTINGS #
67
+ ###########################################################
68
+ capybara_wait_time: 20
92
69
 
93
70
  ###########################################################
94
71
  # LOGGER SETTINGS #
95
72
  ###########################################################
96
73
  log_dir: "log"
97
- txt_log: log.txt
74
+ debug_mode: false
98
75
  html_log: log.html
99
76
  selenium_server_log: selenium-server.log
100
77
  required_clean_logs: true
101
- rawler_log: rawler_log.txt
102
- add_rawler_xml_log: false
103
- rawler_xml_log: rawler_log.xml
104
- add_rawler_html_log: false # not implemented yet
105
- rawler_html_log: rawler_log.html # not implemented yet
78
+ hide_datetime_from_log: false
106
79
 
107
80
  ###########################################################
108
- # MAILGUN SETTINGS #
81
+ # MAIL SETTINGS #
109
82
  ###########################################################
83
+ mail_adapter: mailgun
110
84
  mailgun_key: mailgun_account_private_key
111
85
  mailgun_domain: mailgun_domain_with_stored_method
112
-
113
- ############################################################
114
- # TIMEOUTS #
115
- ############################################################
116
- timeout_tiny: 1
117
- timeout_short: 3
118
- timeout_small: 20
119
- timeout_medium: 60
86
+ mailgun_idle_timeout: 60
87
+ mailgun_sleep_time: 3
@@ -1,25 +1,25 @@
1
1
  require_relative '../base_generator'
2
2
 
3
3
  module Howitzer
4
+ # This class responsible for Cucumber based files generation
4
5
  class CucumberGenerator < BaseGenerator
5
6
  def manifest
6
7
  { files:
7
8
  [
8
- { source: 'common_steps.rb', destination: 'features/step_definitions/common_steps.rb'},
9
- { source: 'env.rb', destination: 'features/support/env.rb'},
10
- { source: 'transformers.rb', destination: 'features/support/transformers.rb'},
11
- { source: 'example.feature', destination: 'features/example.feature'},
12
- { source: 'cucumber.rake', destination: 'tasks/cucumber.rake'},
13
- { source: 'cucumber.yml', destination: 'config/cucumber.yml'}
14
- ]
15
- }
9
+ { source: 'common_steps.rb', destination: 'features/step_definitions/common_steps.rb' },
10
+ { source: 'env.rb', destination: 'features/support/env.rb' },
11
+ { source: 'transformers.rb', destination: 'features/support/transformers.rb' },
12
+ { source: 'example.feature', destination: 'features/example.feature' },
13
+ { source: 'cucumber.rake', destination: 'tasks/cucumber.rake' }
14
+ ] }
16
15
  end
17
16
 
18
17
  protected
18
+
19
19
  def banner
20
20
  <<-EOS
21
21
  * Cucumber integration to the framework ...
22
22
  EOS
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -2,7 +2,7 @@
2
2
  # PREREQUISITES #
3
3
  #############################################################
4
4
 
5
- Given /^I have entered (.*) into the calculator$/ do |input_|
5
+ Given /^I have entered (.*) into the calculator$/ do |_input_|
6
6
  pending
7
7
  end
8
8
 
@@ -10,7 +10,7 @@ end
10
10
  # ACTIONS #
11
11
  ####################################
12
12
 
13
- When /^I press (.*)$/ do |button|
13
+ When /^I press (.*)$/ do |_button|
14
14
  pending
15
15
  end
16
16
 
@@ -18,6 +18,6 @@ end
18
18
  # CHECKS #
19
19
  ####################################
20
20
 
21
- Then /^the result should be (.*) on the screen$/ do |output|
21
+ Then /^the result should be (.*) on the screen$/ do |_output|
22
22
  pending
23
- end
23
+ end
@@ -1,57 +1,66 @@
1
+ require 'cucumber'
2
+ require 'cucumber/rake/task'
1
3
 
2
- unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
3
- begin
4
- require 'cucumber'
5
- require 'cucumber/rake/task'
6
-
7
- namespace :cucumber do
8
- Cucumber::Rake::Task.new({ok: 'db:test:prepare'}, 'Run features that should pass') do |t|
9
- t.fork = false # You may get faster startup if you set this to false
10
- t.profile = 'default'
11
- end
12
-
13
- Cucumber::Rake::Task.new({wip: 'db:test:prepare'}, 'Run features that are being worked on') do |t|
14
- t.fork = false # You may get faster startup if you set this to false
15
- t.profile = 'wip'
16
- end
17
-
18
- Cucumber::Rake::Task.new({bug: 'db:test:prepare'}, 'Run features with known bugs') do |t|
19
- t.fork = false # You may get faster startup if you set this to false
20
- t.profile = 'bug'
21
- end
22
-
23
- Cucumber::Rake::Task.new({demo: 'db:test:prepare'}, 'Run demo feature') do |t|
24
- t.fork = false # You may get faster startup if you set this to false
25
- t.profile = 'demo'
26
- end
27
-
28
- Cucumber::Rake::Task.new({rerun: 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
29
- t.fork = false # You may get faster startup if you set this to false
30
- t.profile = 'rerun'
31
- end
32
-
33
- desc 'Run all features'
34
- task all: [:ok, :wip]
35
-
36
- end
37
- desc 'Alias for cucumber:ok'
38
- task cucumber: 'cucumber:ok'
39
-
40
- task default: :cucumber
41
-
42
- task features: :cucumber do
43
- STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
44
- end
45
-
46
- # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
47
- task 'db:test:prepare' do
48
- end
49
-
50
- rescue LoadError
51
- desc 'cucumber rake task not available (cucumber not installed)'
52
- task :cucumber do
53
- abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
54
- end
4
+ opts = lambda do |task_name|
5
+ [
6
+ '-r features',
7
+ '-v',
8
+ '-x',
9
+ "-f html -o ./#{Howitzer.log_dir}/#{Howitzer.driver}_#{task_name}_#{Howitzer.html_log}",
10
+ "-f junit -o ./#{Howitzer.log_dir}",
11
+ '-f pretty'
12
+ ].join(' ').freeze
13
+ end
14
+
15
+ Cucumber::Rake::Task.new(:cucumber, 'Run all cucumber scenarios') do |t|
16
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
17
+ t.fork = false
18
+ t.cucumber_opts = opts.call(t.instance_variable_get(:@task_name))
19
+ end
20
+
21
+ Cucumber::Rake::Task.new(:features, 'Run all workable scenarios (without @wip and @bug tags)') do |t|
22
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
23
+ t.fork = false
24
+ t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags ~@wip --tags ~@bug"
25
+ end
26
+
27
+ namespace :features do
28
+ Cucumber::Rake::Task.new(:wip, 'Run scenarios in progress (with @wip tag)') do |t|
29
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
30
+ t.fork = false
31
+ t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags @wip"
32
+ end
33
+
34
+ Cucumber::Rake::Task.new(:bug, 'Run scenarios with known bugs (with @bug tag)') do |t|
35
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
36
+ t.fork = false
37
+ t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags @bug"
38
+ end
39
+
40
+ Cucumber::Rake::Task.new(:smoke, 'Run workable smoke scenarios (with @smoke tag)') do |t|
41
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
42
+ t.fork = false
43
+ t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags @smoke --tags ~@wip --tags ~@bug"
44
+ end
45
+
46
+ Cucumber::Rake::Task.new(:bvt, 'Run workable build verification test scenarios') do |t|
47
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
48
+ t.fork = false
49
+ t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))}
50
+ --tags ~@wip --tags ~@bug --tags ~@smoke --tags ~@p1 --tags ~@p2"
51
+ end
52
+
53
+ Cucumber::Rake::Task.new(:p1, 'Run workable scenarios with normal priority (with @p1 tag)') do |t|
54
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
55
+ t.fork = false
56
+ t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags ~@wip --tags ~@bug --tags @p1"
57
+ end
58
+
59
+ Cucumber::Rake::Task.new(:p2, 'Run workable scenarios with low priority (with @p2 tag)') do |t|
60
+ Howitzer.current_rake_task = t.instance_variable_get :@task_name
61
+ t.fork = false
62
+ t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags ~@wip --tags ~@bug --tags @p2"
55
63
  end
64
+ end
56
65
 
57
- end
66
+ task default: :features
@@ -1,39 +1,40 @@
1
1
  require 'cucumber'
2
- require 'capybara/cucumber'
3
- require_relative '../../boot'
2
+ require 'capybara-screenshot/cucumber'
3
+ require_relative '../../config/boot'
4
+ require_relative '../../config/capybara'
4
5
 
5
- World(Capybara::Settings)
6
- World(DataGenerator)
6
+ World(FactoryGirl::Syntax::Methods)
7
7
 
8
- log.settings_as_formatted_text
9
- DataStorage.store('sauce', :start_time, Time.now.utc)
10
- DataStorage.store('sauce', :status, true)
8
+ FileUtils.mkdir_p(Howitzer.log_dir)
11
9
 
12
- if sauce_driver?
13
- Capybara.drivers[:sauce][].options[:desired_capabilities][:name] = Capybara::Settings.suite_name
14
- end
10
+ Howitzer::Log.settings_as_formatted_text
11
+ Howitzer::Cache.store(:cloud, :start_time, Time.now.utc)
12
+ Howitzer::Cache.store(:cloud, :status, true)
15
13
 
16
14
  Before do |scenario|
17
- log.print_feature_name(scenario.feature.name)
18
- log.print_scenario_name(scenario.name)
19
- @session_start = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
15
+ Capybara.use_default_driver
16
+ Howitzer::Log.print_feature_name(scenario.feature.name)
17
+ Howitzer::Log.print_scenario_name(scenario.name)
18
+ @session_start = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
20
19
  end
21
20
 
22
21
  After do |scenario|
23
- if sauce_driver?
24
- DataStorage.store('sauce', :status, false) if scenario.failed?
25
- session_end = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
26
- log.info "SAUCE VIDEO #@session_start - #{session_end} URL: #{sauce_resource_path('video.flv')}"
27
- elsif ie_browser?
28
- log.info 'IE reset session'
22
+ if CapybaraHelpers.cloud_driver?
23
+ Howitzer::Cache.store(:cloud, :status, false) if scenario.failed?
24
+ session_end = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
25
+ Howitzer::Log.info "CLOUD VIDEO #{@session_start} - #{session_end}" \
26
+ " URL: #{CapybaraHelpers.cloud_resource_path(:video)}"
27
+ elsif CapybaraHelpers.ie_browser?
28
+ Howitzer::Log.info 'IE reset session'
29
29
  page.execute_script("void(document.execCommand('ClearAuthenticationCache', false));")
30
30
  end
31
- DataStorage.clear_all_ns
31
+ Howitzer::Cache.clear_all_ns
32
+ Capybara.reset_sessions!
32
33
  end
33
34
 
34
35
  at_exit do
35
- if sauce_driver?
36
- log.info "SAUCE SERVER LOG URL: #{Capybara::Settings.sauce_resource_path('selenium-server.log')}"
37
- Capybara::Settings.update_sauce_job_status(passed: DataStorage.extract('sauce', :status))
36
+ if CapybaraHelpers.cloud_driver?
37
+ Howitzer::Log.info "CLOUD SERVER LOG URL: #{CapybaraHelpers.cloud_resource_path(:server_log)}"
38
+ CapybaraHelpers.update_cloud_job_status(passed: Howitzer::Cache.extract(:cloud, :status))
38
39
  end
39
40
  end
@@ -1,30 +1,38 @@
1
1
  #############################################################
2
2
  # TRANSFORMERS #
3
3
  #############################################################
4
- Transform /UNIQ_USER(\d*)(?:\[\:(.+)\])?/ do |num, property|
5
- res = Gen::given_user_by_number(num)
4
+
5
+ # Revives factory or factory property from step to real value
6
+ # @note any factory is building once per scenario for the same number.
7
+ # if number is ommited, then it is assigned to 0 number.
8
+ # Built factories are stored in Howitzer::Cache and cleared after each
9
+ # scenario automatically
10
+ # @example
11
+ # 'When I fill first name field with FACTORY_USER1[:first_name] value'
12
+ # #=> build(:user).first_name
13
+ Transform /FACTORY_([a-z_]+)(\d*)(?:\[\:(.+)\])?/i do |factory, num, property|
14
+ res = FactoryGirl.given_by_number(factory.downcase, num)
6
15
  res = res.send(property) if property
7
16
  res
8
17
  end
9
18
 
19
+ # Revives factories or factory properties from table to real values
20
+ # @example
21
+ # When I sign up with following data:
22
+ # | name | email |
23
+ # | FACTORY_USER1[:name] | FACTORY_USER1[:email] |
24
+ # #=> build(:user).name and build(:user).email
10
25
  Transform /^table:.*$/ do |table|
11
26
  raw = table.raw.map do |array|
12
27
  array.map do |el|
13
- res = el
14
-
15
- # UNIQ_USER
16
- data = /UNIQ_USER(?<num>\d*)(?:\[\:(?<property>.+)\])?/.match(el)
17
- if data
18
- res = Gen::given_user_by_number(data[:num])
19
- if data[:property]
20
- res = res.send(data[:property])
21
- end
22
- end
23
-
24
- res
28
+ data = /FACTORY_(?<factory>[a-z_]+)(?<num>\d*)(?:\[\:(?<property>.+)\])?/i.match(el)
29
+ next(el) unless data
30
+ res = FactoryGirl.given_by_number(data[:factory].downcase, data[:num])
31
+ next(res) if data[:property].blank?
32
+ res.send(data[:property])
25
33
  end
26
34
  end
27
35
  location = Cucumber::Core::Ast::Location.of_caller
28
36
  ast_table = Cucumber::Core::Ast::DataTable.new(raw, location)
29
37
  Cucumber::MultilineArgument::DataTable.new(ast_table)
30
- end
38
+ end