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,16 +1,18 @@
1
1
  require_relative '../base_generator'
2
2
 
3
3
  module Howitzer
4
+ # This class responsible for email examples generation
4
5
  class EmailsGenerator < BaseGenerator
5
6
  def manifest
6
- { files: [ source: 'example_email.rb', destination: '/emails/example_email.rb' ] }
7
+ { files: [source: 'example_email.rb', destination: '/emails/example_email.rb'] }
7
8
  end
8
9
 
9
10
  protected
11
+
10
12
  def banner
11
13
  <<-EOS
12
14
  * Email example generation ...
13
15
  EOS
14
16
  end
15
17
  end
16
- end
18
+ end
@@ -1,8 +1,8 @@
1
- class TestEmail < Email
2
- SUBJECT = "Test email"
3
-
1
+ # This class is example of test email
2
+ class TestEmail < Howitzer::Email
3
+ subject 'Test email'
4
4
 
5
5
  def addressed_to?(new_user)
6
6
  /Hi #{new_user}/ === plain_text_body
7
7
  end
8
- end
8
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../base_generator'
2
+
3
+ module Howitzer
4
+ # This class responsible for prerequisites files generation
5
+ class PrerequisitesGenerator < BaseGenerator
6
+ def manifest
7
+ { files:
8
+ [
9
+ { source: 'factory_girl.rb', destination: 'prerequisites/factory_girl.rb' },
10
+ { source: 'users.rb', destination: 'prerequisites/factories/users.rb' },
11
+ { source: 'base.rb', destination: 'prerequisites/models/base.rb' },
12
+ { source: 'user.rb', destination: 'prerequisites/models/user.rb' }
13
+ ] }
14
+ end
15
+
16
+ protected
17
+
18
+ def banner
19
+ <<-EOS
20
+ * Pre-requisites integration to the framework ...
21
+ EOS
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ # The base model. Models allow to communicate with
2
+ # AUT (application under test) api endpoints. They are used by
3
+ # FactoryGirl on create
4
+ #
5
+ # To implement a custom model, override the following methods:
6
+ # * {Base.find}
7
+ # * {Base.where}
8
+ # * {Base.save!}
9
+ #
10
+ class Base
11
+ def self.find(_id)
12
+ raise NotImplementedError
13
+ end
14
+
15
+ def self.where(_params)
16
+ raise NotImplementedError
17
+ end
18
+
19
+ def save!
20
+ raise NotImplementedError
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ # @see http://www.rubydoc.info/gems/factory_girl/file/GETTING_STARTED.md
2
+ require 'factory_girl'
3
+
4
+ FactoryGirl.definition_file_paths = [File.join(__dir__, 'factories')]
5
+ FactoryGirl.find_definitions
6
+
7
+ # This module holds custom FactoryGirl methods
8
+ module FactoryGirl
9
+ # Fetches data from the cache, using factory name and number.
10
+ # If there is data in the cache with the given name and number,
11
+ # then that data is returned. Otherwise it stores firstly and then returns
12
+ # @param factory [String] underscored factory name
13
+ # @param num [Integer] a factory number
14
+ # @return [Object] the factory
15
+ def self.given_by_number(factory, num)
16
+ data = Howitzer::Cache.extract(factory, num.to_i)
17
+ return data if data.present?
18
+ Howitzer::Cache.store(factory, num.to_i, build(factory))
19
+ end
20
+ end
21
+
22
+ # This module holds data generators
23
+ module Gen
24
+ # Generates unique string
25
+ # @return [String]
26
+ def self.serial
27
+ a = [('a'..'z').to_a, (0..9).to_a].flatten.shuffle
28
+ "#{Time.now.utc.strftime('%j%H%M%S')}#{a[0..4].join}"
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'base'
2
+ # Example User Model
3
+ class User < Base
4
+ def self.default
5
+ where(email: Howitzer.app_test_user).first
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ FactoryGirl.define do
2
+ factory :user do
3
+ email { "u#{serial}@#{Howitzer.mailgun_domain}" }
4
+ name { "FirstName LastName #{serial}" }
5
+ password { Howitzer.app_test_pass }
6
+ password_confirmation { Howitzer.app_test_pass }
7
+
8
+ trait :default do
9
+ initialize_with { User.default || User.new }
10
+ end
11
+ end
12
+ end
@@ -1,23 +1,27 @@
1
1
  require_relative '../base_generator'
2
2
 
3
3
  module Howitzer
4
+ # This class responsible for project root files generation
4
5
  class RootGenerator < BaseGenerator
5
6
  def manifest
6
7
  { files:
7
8
  [
8
- { source: '.gitignore', destination: '.gitignore'},
9
- { source: 'Gemfile', destination: 'Gemfile'},
10
- { source: 'Rakefile', destination: 'Rakefile'},
11
- { source: 'boot.rb', destination: 'boot.rb'}
12
- ]
13
- }
9
+ { source: '.gitignore', destination: '.gitignore' },
10
+ { source: '.rubocop.yml', destination: '.rubocop.yml' },
11
+ { source: 'Rakefile', destination: 'Rakefile' }
12
+ ],
13
+ templates:
14
+ [
15
+ { source: 'Gemfile.erb', destination: 'Gemfile' }
16
+ ] }
14
17
  end
15
18
 
16
19
  protected
20
+
17
21
  def banner
18
22
  <<-EOF
19
23
  * Root files generation ...
20
24
  EOF
21
25
  end
22
26
  end
23
- end
27
+ end
@@ -0,0 +1,32 @@
1
+ # See full list of defaults here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+ # To see all cops used see here: https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.3
6
+ Include:
7
+ - Rakefile
8
+ - Gemfile
9
+
10
+ LineLength:
11
+ Max: 120
12
+
13
+ Style/CaseIndentation:
14
+ Enabled: false
15
+
16
+ Style/EmptyElse:
17
+ Enabled: false
18
+
19
+ Lint/AmbiguousRegexpLiteral:
20
+ Enabled: false
21
+
22
+ Style/CaseEquality:
23
+ Enabled: false
24
+
25
+ Documentation:
26
+ Enabled: false
27
+
28
+ Style/FrozenStringLiteralComment:
29
+ Enabled: false
30
+
31
+ Metrics/ModuleLength:
32
+ Max: 150
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Uncomment it if you are going to use 'webkit' driver. QT library should be installed.
4
+ # See https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
5
+ #
6
+ # gem 'capybara-webkit'
7
+
8
+ gem 'howitzer'
9
+ # Uncomment it if you are going to use 'poltergeist' driver. PhantomJS should be installed.
10
+ # See https://github.com/jnicklas/capybara#poltergeist
11
+ # gem 'poltergeist', github: 'teampoltergeist/poltergeist', branch: :master
12
+ gem 'rest-client'
13
+ gem 'repeater'
14
+ gem 'factory_girl'
15
+ gem 'capybara-screenshot'
16
+ <% if cucumber %>
17
+ gem 'syntax'
18
+ gem 'cucumber', '~>2.0'
19
+ <% elsif rspec %>
20
+ gem 'rspec', '~>3.2'
21
+ <% elsif turnip %>
22
+ gem 'rspec', '~>3.2'
23
+ gem 'turnip'
24
+ <% end %>
25
+ gem 'rubocop'
26
+ gem 'pry'
27
+ gem 'pry-byebug'
@@ -1,16 +1,14 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'howitzer/settings'
4
- require 'howitzer/utils/log'
3
+ require 'howitzer'
4
+ require 'rubocop/rake_task'
5
5
 
6
6
  load 'howitzer/tasks/framework.rake'
7
+ RuboCop::RakeTask.new
7
8
 
8
- Dir.chdir(File.join(File.dirname(__FILE__), '.'))
9
-
10
- if settings.required_clean_logs
11
- CLEAN.include("#{settings.log_dir}/*")
9
+ if Howitzer.required_clean_logs
10
+ CLEAN.include("#{Howitzer.log_dir}/*")
12
11
  Rake::Task[:clean].invoke
13
12
  end
14
13
 
15
- Dir['tasks/**/*.rake'].each { |rake| load rake }
16
- ENV['RAKE_TASK'] = ARGV[0] if /^(?:r?spec|cucumber)/ === ARGV[0]
14
+ Dir['./tasks/**/*.rake'].each { |rake| load rake }
@@ -1,23 +1,23 @@
1
1
  require_relative '../base_generator'
2
2
 
3
3
  module Howitzer
4
+ # This class responsible for rspec based files generation
4
5
  class RspecGenerator < BaseGenerator
5
6
  def manifest
6
7
  { files:
7
8
  [
8
- { source: 'spec_helper.rb', destination: 'spec/spec_helper.rb'},
9
- { source: 'example_spec.rb', destination: 'spec/example_spec.rb'},
10
- { source: 'rspec.rake', destination: 'tasks/rspec.rake'}
11
- ]
12
- }
9
+ { source: 'spec_helper.rb', destination: 'spec/spec_helper.rb' },
10
+ { source: 'example_spec.rb', destination: 'spec/example_spec.rb' },
11
+ { source: 'rspec.rake', destination: 'tasks/rspec.rake' }
12
+ ] }
13
13
  end
14
14
 
15
15
  protected
16
+
16
17
  def banner
17
18
  <<-EOS
18
19
  * RSpec integration to the framework ...
19
20
  EOS
20
21
  end
21
-
22
22
  end
23
- end
23
+ end
@@ -4,4 +4,4 @@ RSpec.feature 'Some feature' do
4
4
  scenario 'test scenario' do
5
5
  expect(true).to be_truthy
6
6
  end
7
- end
7
+ end
@@ -1,34 +1,53 @@
1
- require 'rspec'
2
1
  require 'rspec/core/rake_task'
3
- include RSpec::Core
4
-
5
- # Specify here your group tests
6
- TEST_TYPES = [:all, :health, :bvt, :p1]
7
-
8
- # Specify here your business areas, ex. [:accounts, :blog, :news]
9
- TEST_AREAS = []
10
-
11
- namespace :rspec do
12
- std_opts = "--format html --out=./#{settings.log_dir}/#{settings.html_log} --format documentation --color"
13
- TEST_TYPES.each do |type|
14
- RakeTask.new(type) do |s|
15
- s.send :desc, "Run all #{"'#{s.name}' " unless type == :all}tests"
16
- s.pattern = "./spec/#{type == :all ? '**': s.name}/**/*_spec.rb"
17
- s.rspec_opts = std_opts
18
- s.verbose = true
19
- end
20
- TEST_AREAS.each do |group|
21
- type_text = type == :all ? '**': type
22
- pattern = "./spec/#{type_text}/#{group}/**/*_spec.rb"
23
- RakeTask.new("#{"#{type}:" unless type == :all}#{group}") do |s|
24
- s.send :desc, "Run all '#{s.name}' tests"
25
- s.pattern = pattern
26
- s.rspec_opts = std_opts
27
- s.verbose = true
28
- end
29
- end
2
+
3
+ opts = lambda do |task_name|
4
+ [
5
+ "--format html --out ./#{Howitzer.log_dir}/#{Howitzer.driver}_#{task_name}_#{Howitzer.html_log}",
6
+ '--format documentation',
7
+ '--color'
8
+ ].join(' ').freeze
9
+ end
10
+
11
+ RSpec::Core::RakeTask.new(:rspec, 'Run all rspec scenarios') do |t|
12
+ Howitzer.current_rake_task = t.name
13
+ t.opts = opts.call(t.name)
14
+ end
15
+
16
+ RSpec::Core::RakeTask.new(:features, 'Run all workable scenarios (without @wip and @bug tags)') do |t|
17
+ Howitzer.current_rake_task = t.name
18
+ t.opts = "#{opts.call(t.name)} --tag ~wip --tag ~bug"
19
+ end
20
+
21
+ namespace :features do
22
+ RSpec::Core::RakeTask.new(:wip, 'Run scenarios in progress (with @wip tag)') do |t|
23
+ Howitzer.current_rake_task = t.name
24
+ t.opts = "#{opts.call(t.name)} --tag wip"
25
+ end
26
+
27
+ RSpec::Core::RakeTask.new(:bug, 'Run scenarios with known bugs (with @bug tag)') do |t|
28
+ Howitzer.current_rake_task = t.name
29
+ t.opts = "#{opts.call(t.name)} --tag bug"
30
+ end
31
+
32
+ RSpec::Core::RakeTask.new(:smoke, 'Run workable smoke scenarios (with @smoke tag)') do |t|
33
+ Howitzer.current_rake_task = t.name
34
+ t.opts = "#{opts.call(t.name)} --tag smoke --tag ~wip --tag ~bug"
35
+ end
36
+
37
+ RSpec::Core::RakeTask.new(:bvt, 'Run workable build verification test scenarios') do |t|
38
+ Howitzer.current_rake_task = t.name
39
+ t.opts = "#{opts.call(t.name)} --tag ~wip --tag ~bug --tag ~p1 --tag ~p2 --tag ~smoke"
40
+ end
41
+
42
+ RSpec::Core::RakeTask.new(:p1, 'Run workable scenarios with normal priority (with @p1 tag)') do |t|
43
+ Howitzer.current_rake_task = t.name
44
+ t.opts = "#{opts.call(t.name)} --tag p1 --tag ~wip --tag ~bug"
30
45
  end
31
46
 
47
+ RSpec::Core::RakeTask.new(:p2, 'Run workable scenarios with low priority (with @p2 tag)') do |t|
48
+ Howitzer.current_rake_task = t.name
49
+ t.opts = "#{opts.call(t.name)} --tag p2 --tag ~wip --tag ~bug"
50
+ end
32
51
  end
33
52
 
34
- task default: "rspec:all"
53
+ task default: :features
@@ -1,56 +1,57 @@
1
- require 'rspec'
2
- require 'capybara/rspec'
3
- require_relative '../boot'
1
+ require 'capybara-screenshot/rspec'
2
+ require 'capybara/rspec/features'
3
+ require_relative '../config/boot'
4
+ require_relative '../config/capybara'
4
5
 
5
- Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each{ |f| require f }
6
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
6
7
 
7
8
  RSpec.configure do |config|
8
- log.settings_as_formatted_text
9
+ Howitzer::Log.settings_as_formatted_text
9
10
 
10
- DataStorage.store('sauce', :start_time, Time.now.utc)
11
- DataStorage.store('sauce', :status, true)
11
+ Howitzer::Cache.store(:cloud, :start_time, Time.now.utc)
12
+ Howitzer::Cache.store(:cloud, :status, true)
12
13
 
13
- config.include Capybara::Settings
14
- config.include Capybara::RSpecMatchers
15
- config.include DataGenerator
14
+ config.include FactoryGirl::Syntax::Methods
16
15
 
17
16
  config.disable_monkey_patching = true
18
17
  config.color = true
19
18
 
20
- config.before(:all) do
21
- if sauce_driver?
22
- suite_name = "#{(ENV['RAKE_TASK'] || 'CUSTOM').sub('rspec:', '').upcase} #{settings.sl_browser_name.upcase}"
23
- Capybara.drivers[:sauce][].options[:desired_capabilities][:name] = suite_name
24
- end
25
- end
26
-
27
19
  config.before(:each) do
28
- log.print_scenario_name(RSpec.current_example.description.empty? ? RSpec.current_example.metadata[:full_description] : RSpec.current_example.description)
29
- @session_start = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
20
+ scenario_name =
21
+ if RSpec.current_example.description.blank?
22
+ RSpec.current_example.metadata[:full_description]
23
+ else
24
+ RSpec.current_example.description
25
+ end
26
+ Howitzer::Log.print_scenario_name(scenario_name)
27
+ @session_start = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
30
28
  end
31
29
 
32
30
  config.after(:each) do
33
- DataStorage.clear_all_ns
34
- if sauce_driver?
35
- session_end = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
36
- log.info "SAUCE VIDEO #@session_start - #{session_end} URL: #{sauce_resource_path('video.flv')}"
37
- elsif ie_browser?
38
- log.info 'IE reset session'
31
+ Howitzer::Cache.clear_all_ns
32
+ if CapybaraHelpers.cloud_driver?
33
+ session_end = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
34
+ Howitzer::Log.info "CLOUD VIDEO #{@session_start} - #{session_end}" \
35
+ " URL: #{CapybaraHelpers.cloud_resource_path(:video)}"
36
+ elsif CapybaraHelpers.ie_browser?
37
+ Howitzer::Log.info 'IE reset session'
39
38
  page.execute_script("void(document.execCommand('ClearAuthenticationCache', false));")
40
- end
39
+ end
40
+ Capybara.reset_sessions!
41
+ Capybara.use_default_driver
41
42
  end
42
43
 
43
44
  config.after(:suite) do
44
- if sauce_driver?
45
- report_failures_count = config.reporter.instance_variable_get(:@failure_count)
46
- DataStorage.store('sauce', :status, report_failures_count.zero?)
45
+ if CapybaraHelpers.cloud_driver?
46
+ report_failures_count = config.reporter.failed_examples.count
47
+ Howitzer::Cache.store(:cloud, :status, report_failures_count.zero?)
47
48
  end
48
49
  end
49
50
 
50
51
  at_exit do
51
- if sauce_driver?
52
- log.info "SAUCE SERVER LOG URL: #{CapybaraSettings.sauce_resource_path('selenium-server.log')}"
53
- CapybaraSettings.update_sauce_job_status(passed: DataStorage.extract('sauce', :status))
52
+ if CapybaraHelpers.cloud_driver?
53
+ Howitzer::Log.info "CLOUD SERVER LOG URL: #{CapybaraHelpers.cloud_resource_path(:server_log)}"
54
+ CapybaraHelpers.update_cloud_job_status(passed: Howitzer::Cache.extract(:cloud, :status))
54
55
  end
55
56
  end
56
57
  end