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 rake tasks generation
4
5
  class TasksGenerator < BaseGenerator
5
6
  def manifest
6
- { files: [ source: 'common.rake', destination: 'tasks/common.rake' ] }
7
+ { files: [source: 'common.rake', destination: 'tasks/common.rake'] }
7
8
  end
8
9
 
9
10
  protected
11
+
10
12
  def banner
11
13
  <<-EOF
12
14
  * Base rake task generation ...
13
15
  EOF
14
16
  end
15
17
  end
16
- end
18
+ end
@@ -1,16 +1 @@
1
- desc "Check broken links"
2
- task :check_links do
3
- require 'rawler'
4
- require 'active_support'
5
- require 'active_support/core_ext'
6
- require 'howitzer/helpers'
7
-
8
- log.settings_as_formatted_text
9
- opts = {
10
- wait: 0.1,
11
- logfile: File.expand_path(settings.rawler_log, settings.log_dir)
12
- }
13
- opts[:username] = settings.app_base_auth_login unless settings.app_base_auth_login.blank?
14
- opts[:password] = settings.app_base_auth_pass unless settings.app_base_auth_pass.blank?
15
- Rawler::Base.new(app_base_url, $stdout, opts).validate
16
- end
1
+ # Put here any common rake tasks
@@ -0,0 +1 @@
1
+ -r turnip/rspec
@@ -0,0 +1,25 @@
1
+ module Turnip
2
+ # In this module should be combined common turnip steps
3
+ module Steps
4
+ # PUT GLOBAL STEPS HERE
5
+ end
6
+ end
7
+
8
+ # This module combines turnip steps for example.feature
9
+ module MonsterSteps
10
+ attr_accessor :monster
11
+
12
+ step 'there is a monster' do
13
+ self.monster = 1
14
+ end
15
+
16
+ step 'I attack it' do
17
+ self.monster -= 1
18
+ end
19
+
20
+ step 'it should die' do
21
+ expect(self.monster).to eq(0)
22
+ end
23
+ end
24
+
25
+ RSpec.configure { |c| c.include MonsterSteps, monster_steps: true }
@@ -0,0 +1,8 @@
1
+ @monster_steps
2
+ Feature: Attacking a monster
3
+ Background:
4
+ Given there is a monster
5
+
6
+ Scenario: attack the monster
7
+ When I attack it
8
+ Then it should die
@@ -0,0 +1,56 @@
1
+ require 'capybara-screenshot/rspec'
2
+ require_relative '../config/boot'
3
+ require_relative '../config/capybara'
4
+
5
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
6
+
7
+ RSpec.configure do |config|
8
+ Howitzer::Log.settings_as_formatted_text
9
+
10
+ Howitzer::Cache.store(:cloud, :start_time, Time.now.utc)
11
+ Howitzer::Cache.store(:cloud, :status, true)
12
+
13
+ config.include FactoryGirl::Syntax::Methods
14
+
15
+ config.disable_monkey_patching = true
16
+ config.color = true
17
+
18
+ config.before(:each) do
19
+ scenario_name =
20
+ if RSpec.current_example.description.blank?
21
+ RSpec.current_example.metadata[:full_description]
22
+ else
23
+ RSpec.current_example.description
24
+ end
25
+ Howitzer::Log.print_scenario_name(scenario_name)
26
+ @session_start = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
27
+ end
28
+
29
+ config.after(:each) do
30
+ Howitzer::Cache.clear_all_ns
31
+ if CapybaraHelpers.cloud_driver?
32
+ session_end = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
33
+ Howitzer::Log.info "CLOUD VIDEO #{@session_start} - #{session_end}" \
34
+ " URL: #{CapybaraHelpers.cloud_resource_path(:video)}"
35
+ elsif CapybaraHelpers.ie_browser?
36
+ Howitzer::Log.info 'IE reset session'
37
+ page.execute_script("void(document.execCommand('ClearAuthenticationCache', false));")
38
+ end
39
+ Capybara.reset_sessions!
40
+ Capybara.use_default_driver
41
+ end
42
+
43
+ config.after(:suite) do
44
+ if CapybaraHelpers.cloud_driver?
45
+ report_failures_count = config.reporter.failed_examples.count
46
+ Howitzer::Cache.store(:cloud, :status, report_failures_count.zero?)
47
+ end
48
+ end
49
+
50
+ at_exit do
51
+ if CapybaraHelpers.cloud_driver?
52
+ Howitzer::Log.info "CLOUD SERVER LOG URL: #{CapybaraHelpers.cloud_resource_path(:server_log)}"
53
+ CapybaraHelpers.update_cloud_job_status(passed: Howitzer::Cache.extract(:cloud, :status))
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,61 @@
1
+ require 'rspec/core/rake_task'
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 turnip scenarios') do |t|
12
+ Howitzer.current_rake_task = t.name
13
+ t.pattern = './spec{,/*/**}/*.feature'
14
+ t.rspec_opts = opts.call(t.name)
15
+ end
16
+
17
+ RSpec::Core::RakeTask.new(:features, 'Run all workable scenarios (without @wip and @bug tags)') do |t|
18
+ Howitzer.current_rake_task = t.name
19
+ t.pattern = './spec{,/*/**}/*.feature'
20
+ t.rspec_opts = "#{opts.call(t.name)} --tag ~wip --tag ~bug"
21
+ end
22
+
23
+ namespace :features do
24
+ RSpec::Core::RakeTask.new(:wip, 'Run scenarios in progress (with @wip tag)') do |t|
25
+ Howitzer.current_rake_task = t.name
26
+ t.pattern = './spec{,/*/**}/*.feature'
27
+ t.rspec_opts = "#{opts.call(t.name)} --tag wip"
28
+ end
29
+
30
+ RSpec::Core::RakeTask.new(:bug, 'Run scenarios with known bugs (with @bug tag)') do |t|
31
+ Howitzer.current_rake_task = t.name
32
+ t.pattern = './spec{,/*/**}/*.feature'
33
+ t.rspec_opts = "#{opts.call(t.name)} --tag bug"
34
+ end
35
+
36
+ RSpec::Core::RakeTask.new(:smoke, 'Run workable smoke scenarios (with @smoke tag)') do |t|
37
+ Howitzer.current_rake_task = t.name
38
+ t.pattern = './spec{,/*/**}/*.feature'
39
+ t.rspec_opts = "#{opts.call(t.name)} --tag smoke --tag ~wip --tag ~bug"
40
+ end
41
+
42
+ RSpec::Core::RakeTask.new(:bvt, 'Run workable build verification test scenarios') do |t|
43
+ Howitzer.current_rake_task = t.name
44
+ t.pattern = './spec{,/*/**}/*.feature'
45
+ t.rspec_opts = "#{opts.call(t.name)} --tag ~wip --tag ~bug --tag ~p1 --tag ~p2 --tag ~smoke"
46
+ end
47
+
48
+ RSpec::Core::RakeTask.new(:p1, 'Run workable scenarios with normal priority (with @p1 tag)') do |t|
49
+ Howitzer.current_rake_task = t.name
50
+ t.pattern = './spec{,/*/**}/*.feature'
51
+ t.rspec_opts = "#{opts.call(t.name)} --tag p1 --tag ~wip --tag ~bug"
52
+ end
53
+
54
+ RSpec::Core::RakeTask.new(:p2, 'Run workable scenarios with low priority (with @p2 tag)') do |t|
55
+ Howitzer.current_rake_task = t.name
56
+ t.pattern = './spec{,/*/**}/*.feature'
57
+ t.rspec_opts = "#{opts.call(t.name)} --tag p2 --tag ~wip --tag ~bug"
58
+ end
59
+ end
60
+
61
+ task default: :features
@@ -0,0 +1,6 @@
1
+ require 'turnip'
2
+ Dir.glob('spec/steps/**/*steps.rb') { |f| load f, true }
3
+
4
+ RSpec.configure do |config|
5
+ config.raise_error_for_unimplemented_steps = true
6
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../base_generator'
2
+
3
+ module Howitzer
4
+ # This class responsible for turnip based files generation
5
+ class TurnipGenerator < BaseGenerator
6
+ def manifest
7
+ { files:
8
+ [
9
+ { source: '.rspec', destination: '.rspec' },
10
+ { source: 'spec_helper.rb', destination: 'spec/spec_helper.rb' },
11
+ { source: 'turnip_helper.rb', destination: 'spec/turnip_helper.rb' },
12
+ { source: 'example.feature', destination: 'spec/acceptance/example.feature' },
13
+ { source: 'common_steps.rb', destination: 'spec/steps/common_steps.rb' },
14
+ { source: 'turnip.rake', destination: 'tasks/turnip.rake' }
15
+ ] }
16
+ end
17
+
18
+ protected
19
+
20
+ def banner
21
+ <<-EOS
22
+ * Turnip integration to the framework ...
23
+ EOS
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'example_menu'
2
+ # This class is example of web page
3
+ class ExamplePage < Howitzer::Web::Page
4
+ path '/'
5
+ validate :url, %r{\A(?:.*?:\/\/)?[^\/]*\/?\z}
6
+
7
+ section :menu
8
+
9
+ element :search_input, :fillable_field, 'lst-ib'
10
+ element :search_btn, :button, 'btnK'
11
+
12
+ def fill_keyword(data)
13
+ search_input_element.set(data)
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # This class is example of section
2
+ class MenuSection < Howitzer::Web::Section
3
+ me :id, 'metaMenu'
4
+
5
+ element :menu_button, '.menuButton'
6
+ element :account, :xpath, ".//*[@id='metaMenu']//a[contains(., 'Account')]"
7
+ element :log_out, :xpath, ".//*[@id='metaMenu']//a[contains(., 'Log Out')]"
8
+
9
+ def logout
10
+ Howitzer::Log.info 'Log out'
11
+ log_out_element.click
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../base_generator'
2
+
3
+ module Howitzer
4
+ # This class responsible for page object pattern generation
5
+ class WebGenerator < BaseGenerator
6
+ def manifest
7
+ { files:
8
+ [
9
+ { source: 'example_page.rb', destination: 'web/pages/example_page.rb' },
10
+ { source: 'menu_section.rb', destination: 'web/sections/menu_section.rb' }
11
+ ] }
12
+ end
13
+
14
+ protected
15
+
16
+ def banner
17
+ <<-EOS
18
+ * PageOriented pattern structure generation ...
19
+ EOS
20
+ end
21
+ end
22
+ end
@@ -1,45 +1,38 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  require File.expand_path('../lib/howitzer/version', __FILE__)
3
4
 
4
5
  Gem::Specification.new do |gem|
5
6
  gem.author = 'Roman Parashchenko'
6
7
  gem.email = 'howitzer@strongqa.com'
7
- gem.description = %q{Howitzer uses the best practices and design patterns allowing to generate a test project in less than 5 minutes. It has out-of-the-box configurations for parallel cross-browser testing in the Cloud.}
8
- gem.summary = %q{Ruby based framework for acceptance testing}
8
+ gem.description = 'Howitzer uses the best practices and design patterns allowing to generate a test project in' \
9
+ ' less than 5 minutes. It has out-of-the-box configurations for parallel cross-browser testing in the cloud.'
10
+ gem.summary = 'Ruby based framework for acceptance testing'
9
11
  gem.homepage = 'http://strongqa.github.io/howitzer/'
10
12
  gem.license = 'MIT'
11
13
 
12
14
  gem.bindir = 'bin'
13
- gem.files = `git ls-files`.split($\)
14
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
15
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
18
  gem.name = 'howitzer'
17
19
  gem.require_paths = ['lib']
18
20
  gem.version = Howitzer::VERSION
19
- gem.required_ruby_version = '>= 1.9.3'
21
+ gem.required_ruby_version = '>= 2.2.2'
20
22
 
21
- gem.add_runtime_dependency 'nokogiri', '~> 1.6' if gem.platform.to_s =~ /mswin|mingw/
22
- gem.add_runtime_dependency 'rack', '~> 1.0'
23
- gem.add_runtime_dependency 'tins', '1.6.0'
24
- gem.add_runtime_dependency 'rake'
23
+ gem.add_runtime_dependency 'activesupport', '~>5.0'
24
+ gem.add_runtime_dependency 'capybara', ['>= 2.1', '< 3.0']
25
25
  gem.add_runtime_dependency 'gli'
26
- gem.add_runtime_dependency 'syntax'
27
- gem.add_runtime_dependency 'cucumber', '~>2.0'
28
- gem.add_runtime_dependency 'rspec', '~>3.2'
29
- gem.add_runtime_dependency 'sexy_settings'
30
- gem.add_runtime_dependency 'repeater'
31
26
  gem.add_runtime_dependency 'launchy'
32
27
  gem.add_runtime_dependency 'log4r', '~>1.1.10'
33
- gem.add_runtime_dependency 'rest-client', '~>1.8'
34
- gem.add_runtime_dependency 'poltergeist'
35
- gem.add_runtime_dependency 'rawler'
36
- gem.add_runtime_dependency 'capybara'
28
+ gem.add_runtime_dependency 'nokogiri', '~> 1.6' if gem.platform.to_s =~ /mswin|mingw/
29
+ gem.add_runtime_dependency 'rake'
30
+ gem.add_runtime_dependency 'rspec', '~>3.2'
37
31
  gem.add_runtime_dependency 'selenium-webdriver'
38
- gem.add_runtime_dependency 'activesupport', '~>4.2'
39
- gem.add_runtime_dependency 'testingbot'
32
+ gem.add_runtime_dependency 'sexy_settings'
40
33
 
41
34
  gem.add_development_dependency('aruba')
42
- gem.add_development_dependency('fuubar')
43
35
  gem.add_development_dependency('ffaker')
36
+ gem.add_development_dependency('fuubar')
44
37
  gem.add_development_dependency('yard')
45
38
  end
@@ -1,9 +1,49 @@
1
- require "howitzer/version"
2
- require "howitzer/settings"
3
- require 'howitzer/capybara/settings'
1
+ require 'selenium-webdriver'
2
+ require 'capybara'
3
+ require 'sexy_settings'
4
+
5
+ SexySettings.configure do |config|
6
+ config.path_to_default_settings = File.expand_path('config/default.yml', Dir.pwd)
7
+ config.path_to_custom_settings = File.expand_path('config/custom.yml', Dir.pwd)
8
+ end
9
+
10
+ # This is main namespace for the library
11
+ module Howitzer
12
+ class << self
13
+ # Defines methods for all known settings
14
+ # @example
15
+ # Howtzer.app_host
16
+ # Howitzer.driver
17
+
18
+ ::SexySettings::Base.instance.all.each do |key, value|
19
+ define_method(key) { value }
20
+ end
21
+
22
+ attr_accessor :current_rake_task
23
+ end
24
+
25
+ # @return an application uri
26
+ #
27
+ # @example returns url with auth
28
+ # app_uri.site
29
+ # @example returns url without auth
30
+ # app_uri.origin
31
+
32
+ def self.app_uri
33
+ ::Addressable::URI.new(
34
+ user: Howitzer.app_base_auth_login,
35
+ password: Howitzer.app_base_auth_pass,
36
+ host: Howitzer.app_host,
37
+ scheme: Howitzer.app_protocol || 'http'
38
+ )
39
+ end
40
+ end
41
+
42
+ require 'howitzer/version'
43
+ require 'howitzer/exceptions'
44
+ require 'howitzer/log'
4
45
  require 'howitzer/utils'
5
- require 'howitzer/init'
6
- require 'howitzer/helpers'
46
+ require 'howitzer/cache'
7
47
  require 'howitzer/email'
8
- require 'howitzer/web_page'
9
- require 'howitzer/blank_page'
48
+ require 'howitzer/web'
49
+ require 'howitzer/capybara_helpers'
@@ -0,0 +1,70 @@
1
+ module Howitzer
2
+ ##
3
+ #
4
+ # Data can be stored in memory using this class
5
+ #
6
+ module Cache
7
+ SPECIAL_NS_LIST = [:cloud].freeze
8
+ @data ||= {}
9
+
10
+ class << self
11
+ attr_reader :data
12
+
13
+ # Saves data into memory. Marking by a namespace and a key
14
+ #
15
+ # @param ns [String] a namespace
16
+ # @param key [String] a key that should be uniq within the namespace
17
+ # @param value [Object] everything you want to store in Memory
18
+ # @raise [NoDataError] if the namespace missing
19
+
20
+ def store(ns, key, value)
21
+ check_ns(ns)
22
+ @data[ns][key] = value
23
+ end
24
+
25
+ # Gets data from memory. Can get all namespace or single data value in namespace using key
26
+ #
27
+ # @param ns [String] a namespace
28
+ # @param key [String] key that isn't necessary required
29
+ # @return [Object, Hash] all data from the namespace if the key is ommited, otherwise returs
30
+ # all data for the namespace
31
+ # @raise [NoDataError] if the namespace missing
32
+
33
+ def extract(ns, key = nil)
34
+ check_ns(ns)
35
+ key ? @data[ns][key] : @data[ns]
36
+ end
37
+
38
+ # Deletes all data from a namespace
39
+ #
40
+ # @param ns [String] a namespace
41
+
42
+ def clear_ns(ns)
43
+ init_ns(ns)
44
+ end
45
+
46
+ # Deletes all namespaces with data
47
+ #
48
+ # @param exception_list [Array] a namespace list for excluding
49
+
50
+ def clear_all_ns(exception_list = SPECIAL_NS_LIST)
51
+ (@data.keys - exception_list).each { |ns| clear_ns(ns) }
52
+ end
53
+
54
+ private
55
+
56
+ def check_ns(ns)
57
+ raise Howitzer::NoDataError, 'Data storage namespace can not be empty' unless ns
58
+ init_ns(ns) if ns_absent?(ns)
59
+ end
60
+
61
+ def ns_absent?(ns)
62
+ !@data.key?(ns)
63
+ end
64
+
65
+ def init_ns(ns)
66
+ @data[ns] = {}
67
+ end
68
+ end
69
+ end
70
+ end