howitzer 0.0.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.gitignore +8 -0
  2. data/.rspec +3 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.md +32 -0
  5. data/GETTING_STARTED.md +529 -0
  6. data/Gemfile +4 -2
  7. data/LICENSE +2 -2
  8. data/README.md +57 -13
  9. data/Rakefile +9 -2
  10. data/bin/howitzer +79 -31
  11. data/generators/base_generator.rb +87 -0
  12. data/generators/config/config_generator.rb +16 -20
  13. data/generators/config/templates/default.yml +26 -7
  14. data/generators/cucumber/cucumber_generator.rb +20 -26
  15. data/generators/{tasks → cucumber}/templates/cucumber.rake +0 -0
  16. data/generators/{config → cucumber}/templates/cucumber.yml +0 -0
  17. data/generators/emails/emails_generator.rb +11 -18
  18. data/generators/emails/templates/example_email.rb +1 -0
  19. data/generators/pages/pages_generator.rb +16 -18
  20. data/generators/pages/templates/example_menu.rb +1 -0
  21. data/generators/pages/templates/example_page.rb +1 -1
  22. data/generators/root/root_generator.rb +18 -20
  23. data/generators/root/templates/.gitignore +2 -1
  24. data/generators/root/templates/Gemfile +3 -2
  25. data/generators/root/templates/Rakefile +10 -0
  26. data/generators/root/templates/boot.rb +3 -9
  27. data/generators/rspec/rspec_generator.rb +23 -0
  28. data/generators/rspec/templates/example_spec.rb +7 -0
  29. data/generators/rspec/templates/rspec.rake +34 -0
  30. data/generators/rspec/templates/spec_helper.rb +56 -0
  31. data/generators/tasks/tasks_generator.rb +11 -17
  32. data/generators/tasks/templates/common.rake +15 -0
  33. data/howitzer.gemspec +13 -2
  34. data/lib/howitzer.rb +1 -0
  35. data/lib/howitzer/helpers.rb +87 -2
  36. data/lib/howitzer/init.rb +0 -1
  37. data/lib/howitzer/patches/rawler_patched.rb +86 -0
  38. data/lib/howitzer/settings.rb +27 -0
  39. data/lib/howitzer/utils.rb +3 -12
  40. data/lib/howitzer/utils/capybara_patched.rb +3 -2
  41. data/lib/howitzer/utils/capybara_settings.rb +158 -24
  42. data/lib/howitzer/utils/data_generator/data_storage.rb +35 -1
  43. data/lib/howitzer/utils/data_generator/gen.rb +45 -3
  44. data/lib/howitzer/utils/email/email.rb +44 -5
  45. data/lib/howitzer/utils/email/mail_client.rb +28 -22
  46. data/lib/howitzer/utils/email/mailgun_helper.rb +30 -4
  47. data/lib/howitzer/utils/locator_store.rb +111 -19
  48. data/lib/howitzer/utils/log.rb +137 -0
  49. data/lib/howitzer/utils/page_validator.rb +86 -0
  50. data/lib/howitzer/vendor/firebug-1.12.1-fx.xpi +0 -0
  51. data/lib/howitzer/vendor/firepath-0.9.7-fx.xpi +0 -0
  52. data/lib/howitzer/version.rb +2 -2
  53. data/lib/howitzer/web_page.rb +159 -19
  54. data/spec/active_resource.rb +0 -0
  55. data/spec/config/custom.yml +1 -0
  56. data/spec/config/default.yml +28 -0
  57. data/spec/spec_helper.rb +46 -1
  58. data/spec/support/boot_helper.rb +15 -0
  59. data/spec/support/generator_helper.rb +13 -0
  60. data/spec/support/logger_helper.rb +12 -0
  61. data/spec/unit/bin/howitzer_spec.rb +175 -0
  62. data/spec/unit/generators/generators_spec.rb +175 -0
  63. data/spec/unit/lib/capybara_settings_spec.rb +170 -0
  64. data/spec/unit/lib/helpers_spec.rb +619 -0
  65. data/spec/unit/lib/init_spec.rb +14 -0
  66. data/spec/unit/lib/settings_spec.rb +17 -0
  67. data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +62 -0
  68. data/spec/unit/lib/utils/data_generator/gen_spec.rb +151 -0
  69. data/spec/unit/lib/utils/email/email_spec.rb +75 -0
  70. data/spec/unit/lib/utils/email/mail_client_spec.rb +115 -0
  71. data/spec/unit/lib/utils/email/mailgun_helper_spec.rb +95 -0
  72. data/spec/unit/lib/utils/locator_store_spec.rb +122 -0
  73. data/spec/unit/lib/utils/log_spec.rb +107 -0
  74. data/spec/unit/lib/utils/page_validator_spec.rb +142 -0
  75. data/spec/unit/lib/web_page_spec.rb +250 -0
  76. data/spec/unit/version_spec.rb +8 -0
  77. metadata +215 -15
  78. data/Gemfile.lock +0 -103
  79. data/History.md +0 -20
  80. data/lib/howitzer/utils/logger.rb +0 -108
  81. data/spec/howitzer/version_spec.rb +0 -8
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  # Specify your gem's dependencies in howitzer.gemspec
4
- gemspec
3
+ group :development, :test do
4
+ gem "simplecov", :require => false
5
+ end
6
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 StrongQA, Inc.
1
+ Copyright (c) 2013 StrongQA, Inc.
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Howitzer
2
2
 
3
+ [![Build Status](https://api.travis-ci.org/romikoops/howitzer.png)](http://travis-ci.org/romikoops/howitzer)
3
4
  [![Dependency Status](https://gemnasium.com/romikoops/howitzer.png)](https://gemnasium.com/romikoops/howitzer)
4
5
 
5
- Howitzer is Ruby based framework for acceptance testing.
6
+ Howitzer is Ruby based framework for acceptance testing.
6
7
 
7
8
  Initially it was developed for testing of web applications, but it is applicable to testing of web services or some API as well.
8
9
  The framework uses modern patterns, techniques and tools in automated testing area. For details, please see [Test Framework Design](https://github.com/romikoops/howitzer/wiki/Test-Framework-Design).
@@ -11,10 +12,20 @@ The framework uses modern patterns, techniques and tools in automated testing ar
11
12
  - Independent of test web application, its technologies and lanquage.
12
13
  - Deploy all test infrastructure for 5 minutes.
13
14
  - Flexible test framework configuration.
14
- - Ability to choose desired BDD tool (Cucumber for now only, but RSpec is coming soon)
15
- - Itegration with SauceLabs, Mailgun web services.
15
+ - Ability to choose desired BDD tool (Cucumber or RSpec)
16
+ - Itegration with SauceLabs, Testingbot and Mailgun web services.
16
17
  - Easy to support tests in actual state.
17
18
  - Ability to execute tests against to both browserless driver and actual browsers with no changes in your tests.
19
+ - Ability to check all links are valid
20
+
21
+
22
+ ## Documentation
23
+ See [GETTING_STARTED](https://github.com/romikoops/howitzer/blob/develop/GETTING_STARTED.md) how to work with *howitzer*.
24
+
25
+ Also you can find Rdoc documentation on [Rubygems](https://rubygems.org/gems/howitzer).
26
+
27
+ ## Requirements
28
+ Ruby 1.9.3+
18
29
 
19
30
  ## Setup
20
31
  To install, type
@@ -29,26 +40,46 @@ To deploy the framework, type:
29
40
  ```bash
30
41
  mkdir test_automation
31
42
  cd test_automation
43
+ ```
44
+
45
+ Then for Cucumber:
46
+
47
+ ```bash
32
48
  howitzer install --cucumber
33
49
  ```
34
50
 
51
+ For Rspec:
52
+
53
+ ```bash
54
+ howitzer install --rspec
55
+ ```
56
+
57
+ Or for both the ones:
58
+
59
+ ```bash
60
+ howitzer install --cucumber --rspec
61
+ ```
62
+
35
63
  This command will generate next folders and files:
36
64
  ```
37
65
  config/
38
- cucumber.yml
39
- default.yml
40
- custom.yml
66
+ cucumber.yml
67
+ default.yml
68
+ custom.yml
41
69
  tasks/
42
- cucumber.rake
70
+ common.rake
71
+ cucumber.rake
72
+ rspec.rake
43
73
  emails/
44
- example_email.rb
74
+ example_email.rb
45
75
  features/
46
- support/env.rb
47
- step_definitions/common_steps.rb
48
- example.feature
76
+ support/env.rb
77
+ step_definitions/common_steps.rb
78
+ example.feature
49
79
  pages/
50
- example_page.rb
51
- example_menu.rb
80
+ example_page.rb
81
+ example_menu.rb
82
+ boot.rb
52
83
  Gemfile
53
84
  Rakefile
54
85
  .gitignore
@@ -64,6 +95,19 @@ Learn and specify correct default settings in `config/default.yml` file. For det
64
95
  - Debug feature.
65
96
  - Enjoy it!
66
97
 
98
+ ## Rake tasks
99
+
100
+ You can list all available tasks with next command
101
+
102
+ ```bash
103
+ rake -T
104
+ ```
105
+
106
+ ## More information
107
+ * [Rubygems](https://rubygems.org/gems/howitzer)
108
+ * [Mailing list](https://groups.google.com/forum/#!forum/howitzer_ruby)
109
+ * [Issues](https://github.com/romikoops/howitzer/issues)
110
+
67
111
  ## Contributing
68
112
 
69
113
  1. Fork it
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ require 'rubygems'
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ require 'rake'
6
+ require 'rspec/core/rake_task'
7
+ Bundler::GemHelper.install_tasks
8
+ RSpec::Core::RakeTask.new(:spec) { |spec| }
9
+ task :default => :spec
data/bin/howitzer CHANGED
@@ -1,41 +1,89 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems' unless ENV['NO_RUBYGEMS']
4
- require 'rubigen'
5
4
 
6
- if %w(-v --version).include? ARGV.first
7
- require File.dirname(__FILE__) + "/../lib/howitzer"
8
- puts "#{File.basename($0)} #{Howitzer::VERSION}"
9
- exit(0)
5
+ Dir[File.join(File.dirname(__FILE__), '..', 'generators', '**', '*_generator.rb')].each{ |f| require File.expand_path(f) }
6
+
7
+ def check_arguments
8
+ expected_option_list = [
9
+ 'install --cucumber',
10
+ 'install --rspec',
11
+ 'install --cucumber --rspec',
12
+ 'install --rspec --cucumber',
13
+ '--version',
14
+ '--help'
15
+ ]
16
+
17
+ actual_options = ARGV.map(&:downcase).join(' ')
18
+ unless expected_option_list.include?(actual_options)
19
+ puts "ERROR: incorrect options. Please, see help for details"
20
+ show_help
21
+ exit 1
22
+ end
10
23
  end
11
24
 
12
- require 'rubigen/scripts/generate'
13
-
14
- require 'pp'
15
- RubiGen::Base.use_application_sources!
16
- RubiGen::Base.prepend_sources(*[
17
- RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "generators"))
18
- ])
19
-
20
- CORRECT_ARGS = %w[--cucumber --rspec]
21
-
22
- if ARGV[0] == "install"
23
- ARGV.delete 'install'
24
- ARGV.each do |option|
25
- if option == '--cucumber'
26
- RubiGen::Scripts::Generate.new.run(%w[cucumber])
27
- RubiGen::Scripts::Generate.new.run(%w[root])
28
- RubiGen::Scripts::Generate.new.run(%w[config])
29
- RubiGen::Scripts::Generate.new.run(%w[pages])
30
- RubiGen::Scripts::Generate.new.run(%w[tasks])
31
- RubiGen::Scripts::Generate.new.run(%w[emails])
32
- elsif option == '--rspec'
33
- #TODO add rspec generator
34
- puts "Rspec generator is not available"
25
+ def parse_options
26
+ first_option = ARGV.shift.to_s.downcase
27
+ case first_option
28
+ when 'install' then execute_generator(ARGV.map(&:downcase))
29
+ when '--version' then show_version
30
+ when '--help' then show_help
35
31
  else
36
- puts "ERROR: no such generator with name: '#{option}' is available"
32
+ puts "ERROR: incorrect first argument ('#{first_option}')"
33
+ show_help
34
+ exit 1
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def show_help
41
+ puts %{
42
+ howitzer [command {--cucumber, --rspec}] | {options}
43
+
44
+ Commands are ...
45
+ install Generate test framework units:
46
+ --rspec add RSpec integration with framework
47
+ --cucumber add Cucumber integration with framework
48
+ Options are ...
49
+ --help Display this help message.
50
+ --version Display the program version.
51
+ }
52
+ end
53
+
54
+ def show_version
55
+ require_relative "../lib/howitzer/version"
56
+ puts "Version: #{Howitzer::VERSION}"
57
+ exit 0
58
+ end
59
+
60
+ def execute_generator(options)
61
+ if %w[--cucumber --rspec].include?(options.first)
62
+ Howitzer::ConfigGenerator.new
63
+ Howitzer::PagesGenerator.new
64
+ Howitzer::TasksGenerator.new
65
+ Howitzer::EmailsGenerator.new
66
+ Howitzer::RootGenerator.new
67
+
68
+ options.each do |option|
69
+ case option
70
+ when '--cucumber' then Howitzer::CucumberGenerator.new
71
+ when '--rspec' then Howitzer::RspecGenerator.new
72
+ else nil
73
+ end
37
74
  end
75
+ else
76
+ if options.empty?
77
+ puts "ERROR: No option specified for install command."
78
+ else
79
+ puts "ERROR: Unknown '#{options.first}' option specified."
80
+ end
81
+ show_help
82
+ exit 1
38
83
  end
39
- else
40
- puts "ERROR: no such command with name: '#{ARGV[0]} found'"
84
+ end
85
+
86
+ unless ENV['TEST_MODE']
87
+ check_arguments
88
+ parse_options
41
89
  end
@@ -0,0 +1,87 @@
1
+ require 'fileutils'
2
+
3
+ module Howitzer
4
+ class BaseGenerator
5
+ def self.logger=(logger)
6
+ @logger = logger
7
+ end
8
+
9
+ def self.destination=(destination)
10
+ @destination = destination
11
+ end
12
+
13
+ def initialize
14
+ print_banner
15
+ manifest.each do |type, list|
16
+ case type
17
+ when :files
18
+ copy_files(list)
19
+ when :templates
20
+ copy_templates(list)
21
+ else nil
22
+ end
23
+ end
24
+ end
25
+
26
+ def manifest; end
27
+
28
+ protected
29
+ def banner; end
30
+
31
+ def logger
32
+ BaseGenerator.instance_variable_get(:@logger) || $stdout
33
+ end
34
+
35
+ def destination
36
+ BaseGenerator.instance_variable_get(:@destination) || Dir.pwd
37
+ end
38
+
39
+ def copy_files(list)
40
+ list.each do |data|
41
+ source_file = source_path(data[:source])
42
+
43
+ if File.exists?(source_file)
44
+ copy_with_path(data)
45
+ else
46
+ print_error("File '#{source_file}' was not found.")
47
+ end
48
+ end
49
+ end
50
+
51
+ def copy_templates(list)
52
+ #TODO implement me if it is require
53
+ end
54
+
55
+ def print_banner
56
+ logger.puts banner unless banner.empty?
57
+ end
58
+
59
+ def print_info(data)
60
+ logger.puts " #{data}"
61
+ end
62
+
63
+ def print_error(data)
64
+ logger.puts " ERROR: #{data}"
65
+ end
66
+
67
+ def source_path(file_name)
68
+ File.expand_path(
69
+ file_name, File.join(File.dirname(__FILE__), self.class.name.sub('Generator', '').sub('Howitzer::', '').downcase, 'templates')
70
+ )
71
+ end
72
+
73
+ def dest_path(path)
74
+ File.expand_path(File.join(destination, path))
75
+ end
76
+
77
+ def copy_with_path(data)
78
+ src = source_path(data[:source])
79
+ dst = dest_path(data[:destination])
80
+ FileUtils.mkdir_p(File.dirname(dst))
81
+ FileUtils.cp(src, dst)
82
+ print_info("Added '#{data[:destination]}' file")
83
+ rescue => e
84
+ print_error("Impossible to create '#{data[:destination]}' file. Reason: #{e.message}")
85
+ end
86
+ end
87
+ end
@@ -1,24 +1,20 @@
1
- require 'rbconfig'
2
-
3
- class ConfigGenerator < RubiGen::Base
4
- def initialize(runtime_args, runtime_options = {})
5
- super
6
- @destination_root = File.expand_path('config')
7
- end
8
-
9
- def manifest
10
- record do |m|
11
- m.directory ''
12
- m.template 'custom.yml', 'custom.yml'
13
- m.template 'default.yml', 'default.yml'
14
- m.file 'cucumber.yml', 'cucumber.yml'
1
+ require_relative '../base_generator'
2
+ module Howitzer
3
+ class ConfigGenerator < BaseGenerator
4
+ def manifest
5
+ { files:
6
+ [
7
+ { source: 'custom.yml', destination: 'config/custom.yml'},
8
+ { source: 'default.yml', destination: 'config/default.yml'}
9
+ ]
10
+ }
15
11
  end
16
- end
17
12
 
18
- protected
19
- def banner
20
- <<-EOF
21
- Creates config files.
22
- EOF
13
+ protected
14
+ def banner
15
+ <<-EOF
16
+ Creates config files.
17
+ EOF
18
+ end
23
19
  end
24
20
  end
@@ -6,8 +6,11 @@
6
6
  ###########################################################
7
7
  # APPLICATION SETTINGS #
8
8
  ###########################################################
9
+ app_base_auth_login: login
10
+ app_base_auth_pass: pass
11
+ app_protocol: http
9
12
  app_host: my.website.com
10
- app_url: "http://${app_host}"
13
+
11
14
  def_test_user: test@test.com
12
15
  def_test_pass: mypass
13
16
  def_test_name: Auto Tester
@@ -16,19 +19,17 @@
16
19
  # TEST ENVIRONMENTS SETTINGS #
17
20
  ###########################################################
18
21
 
19
- # Specify one of the following drivers: selenium, selenium_dev, webkit, poltergeist, sauce
20
- driver: webkit
22
+ # Specify one of the following drivers: selenium, selenium_dev, webkit, poltergeist, sauce, testingbot
23
+ driver: poltergeist
21
24
 
22
25
  # -Selenium-
23
26
  # specify one of next browsers: iexplore (ie), firefox (ff), chrome, opera
24
27
  sel_browser: ff
25
- sel_firefox_version: 10
26
- sel_firebug_version: 1.9.1
27
- sel_firepath_version: 0.9.7
28
28
 
29
29
  # -PhantomJS-
30
30
  # specify settings for poltergeist
31
- poltergeist_settings: {js_errors: false}
31
+ pjs_ignore_js_errors: false
32
+ pjs_ignore_ssl_errors: true
32
33
 
33
34
  # -SauceLabs-
34
35
  sl_user: some_user
@@ -40,6 +41,18 @@
40
41
  sl_max_duration: '1800'
41
42
  sl_idle_timeout: '180'
42
43
 
44
+ # -TestingBot- browsers that are supported: firefox => '8', googlechrome, iexplore => '9'
45
+ tb_api_key: client_key
46
+ tb_api_secret: client_secret
47
+ tb_url: "http://${tb_api_key}:${tb_api_secret}@hub.testingbot.com:80/wd/hub"
48
+ tb_platform: :WIN8
49
+ tb_browser_name: firefox
50
+ tb_browser_version: 8
51
+ tb_selenium_version: "2.18.0"
52
+ tb_max_duration: '1800'
53
+ tb_idle_timeout: '180'
54
+ tb_record_screenshot: false
55
+
43
56
  ###########################################################
44
57
  # DATABASE SETTINGS #
45
58
  ###########################################################
@@ -51,8 +64,14 @@
51
64
  ###########################################################
52
65
  log_dir: "log"
53
66
  txt_log: log.txt
67
+ html_log: log.html
54
68
  selenium_server_log: selenium-server.log
55
69
  required_clean_logs: true
70
+ rawler_log: rawler_log.txt
71
+ add_rawler_xml_log: false
72
+ rawler_xml_log: rawler_log.xml
73
+ add_rawler_html_log: false # not implemented yet
74
+ rawler_html_log: rawler_log.html # not implemented yet
56
75
 
57
76
  ###########################################################
58
77
  # MAIL SETTINGS #