howitzer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/Gemfile +4 -0
  2. data/Gemfile.lock +113 -0
  3. data/LICENSE +22 -0
  4. data/README.md +44 -0
  5. data/Rakefile +2 -0
  6. data/bin/howitzer +41 -0
  7. data/generators/config/config_generator.rb +24 -0
  8. data/generators/config/templates/cucumber.yml +11 -0
  9. data/generators/config/templates/custom.yml +4 -0
  10. data/generators/config/templates/default.yml +76 -0
  11. data/generators/cucumber/cucumber_generator.rb +31 -0
  12. data/generators/cucumber/templates/common_steps.rb +23 -0
  13. data/generators/cucumber/templates/env.rb +38 -0
  14. data/generators/cucumber/templates/example.feature +16 -0
  15. data/generators/cucumber/templates/transformers.rb +28 -0
  16. data/generators/emails/emails_generator.rb +23 -0
  17. data/generators/emails/templates/example_email.rb +7 -0
  18. data/generators/pages/pages_generator.rb +23 -0
  19. data/generators/pages/templates/example_menu.rb +14 -0
  20. data/generators/pages/templates/example_page.rb +15 -0
  21. data/generators/root/root_generator.rb +25 -0
  22. data/generators/root/templates/.gitignore +20 -0
  23. data/generators/root/templates/Gemfile +4 -0
  24. data/generators/root/templates/Rakefile +4 -0
  25. data/generators/root/templates/boot.rb +16 -0
  26. data/generators/tasks/tasks_generator.rb +22 -0
  27. data/generators/tasks/templates/cucumber.rake +57 -0
  28. data/howitzer.gemspec +36 -0
  29. data/lib/howitzer.rb +5 -0
  30. data/lib/howitzer/helpers.rb +58 -0
  31. data/lib/howitzer/init.rb +5 -0
  32. data/lib/howitzer/utils.rb +14 -0
  33. data/lib/howitzer/utils/capybara_patched.rb +22 -0
  34. data/lib/howitzer/utils/capybara_settings.rb +110 -0
  35. data/lib/howitzer/utils/data_generator/data_storage.rb +41 -0
  36. data/lib/howitzer/utils/data_generator/gen.rb +89 -0
  37. data/lib/howitzer/utils/email/email.rb +46 -0
  38. data/lib/howitzer/utils/email/mail_client.rb +126 -0
  39. data/lib/howitzer/utils/email/mailgun.rb +175 -0
  40. data/lib/howitzer/utils/email/mailgun_helper.rb +35 -0
  41. data/lib/howitzer/utils/locator_store.rb +118 -0
  42. data/lib/howitzer/utils/logger.rb +108 -0
  43. data/lib/howitzer/version.rb +3 -0
  44. data/lib/howitzer/web_page.rb +62 -0
  45. metadata +334 -0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in howitzer.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ howitzer (0.0.1)
5
+ activeresource (= 3.2.8)
6
+ capybara
7
+ cucumber
8
+ i18n
9
+ launchy
10
+ log4r
11
+ mail
12
+ poltergeist
13
+ rake
14
+ repeater
15
+ rest-client
16
+ rspec (~> 2.0)
17
+ rubigen
18
+ selenium-webdriver
19
+ sexy_settings
20
+
21
+ GEM
22
+ remote: https://rubygems.org/
23
+ specs:
24
+ activemodel (3.2.8)
25
+ activesupport (= 3.2.8)
26
+ builder (~> 3.0.0)
27
+ activeresource (3.2.8)
28
+ activemodel (= 3.2.8)
29
+ activesupport (= 3.2.8)
30
+ activesupport (3.2.8)
31
+ i18n (~> 0.6)
32
+ multi_json (~> 1.0)
33
+ addressable (2.3.2)
34
+ builder (3.0.3)
35
+ capybara (1.1.2)
36
+ mime-types (>= 1.16)
37
+ nokogiri (>= 1.3.3)
38
+ rack (>= 1.0.0)
39
+ rack-test (>= 0.5.4)
40
+ selenium-webdriver (~> 2.0)
41
+ xpath (~> 0.1.4)
42
+ childprocess (0.3.5)
43
+ ffi (~> 1.0, >= 1.0.6)
44
+ cucumber (1.2.1)
45
+ builder (>= 2.1.2)
46
+ diff-lcs (>= 1.1.3)
47
+ gherkin (~> 2.11.0)
48
+ json (>= 1.4.6)
49
+ diff-lcs (1.1.3)
50
+ eventmachine (1.0.0)
51
+ faye-websocket (0.4.6)
52
+ eventmachine (>= 0.12.0)
53
+ ffi (1.1.5)
54
+ gherkin (2.11.2)
55
+ json (>= 1.4.6)
56
+ http_parser.rb (0.5.3)
57
+ i18n (0.6.1)
58
+ json (1.7.5)
59
+ launchy (2.1.2)
60
+ addressable (~> 2.3)
61
+ libwebsocket (0.1.5)
62
+ addressable
63
+ log4r (1.1.10)
64
+ mail (2.4.4)
65
+ i18n (>= 0.4.0)
66
+ mime-types (~> 1.16)
67
+ treetop (~> 1.4.8)
68
+ mime-types (1.19)
69
+ multi_json (1.3.6)
70
+ nokogiri (1.5.5)
71
+ poltergeist (0.7.0)
72
+ capybara (~> 1.1)
73
+ childprocess (~> 0.3)
74
+ faye-websocket (~> 0.4, >= 0.4.4)
75
+ http_parser.rb (~> 0.5.3)
76
+ multi_json (~> 1.0)
77
+ polyglot (0.3.3)
78
+ rack (1.4.1)
79
+ rack-test (0.6.2)
80
+ rack (>= 1.0)
81
+ rake (0.9.2.2)
82
+ repeater (0.0.1)
83
+ rest-client (1.6.7)
84
+ mime-types (>= 1.16)
85
+ rspec (2.11.0)
86
+ rspec-core (~> 2.11.0)
87
+ rspec-expectations (~> 2.11.0)
88
+ rspec-mocks (~> 2.11.0)
89
+ rspec-core (2.11.1)
90
+ rspec-expectations (2.11.3)
91
+ diff-lcs (~> 1.1.3)
92
+ rspec-mocks (2.11.3)
93
+ rubigen (1.5.7)
94
+ activesupport (>= 2.3.5)
95
+ i18n
96
+ rubyzip (0.9.9)
97
+ selenium-webdriver (2.25.0)
98
+ childprocess (>= 0.2.5)
99
+ libwebsocket (~> 0.1.3)
100
+ multi_json (~> 1.0)
101
+ rubyzip
102
+ sexy_settings (0.0.1)
103
+ treetop (1.4.10)
104
+ polyglot
105
+ polyglot (>= 0.3.1)
106
+ xpath (0.1.4)
107
+ nokogiri (~> 1.3)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ howitzer!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 StrongQA, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Howitzer
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+ Install it yourself as:
7
+
8
+ $ gem install howitzer
9
+
10
+ ## Usage
11
+
12
+ Write command in command line:
13
+
14
+ $ howitzer install --cucumber
15
+
16
+ ### This command will generate next folders and files:
17
+ ```
18
+ config/
19
+ cucumber.yml
20
+ default.yml
21
+ custom.yml
22
+ tasks/
23
+ cucumber.rake
24
+ emails/
25
+ example_email.rb
26
+ features/
27
+ support/env.rb
28
+ step_definitions/common_steps.rb
29
+ example.feature
30
+ pages/
31
+ example_page.rb
32
+ example_menu.rb
33
+ Gemfile
34
+ Rakefile
35
+ .gitignore
36
+ ```
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/howitzer ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
4
+ require 'rubigen'
5
+
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)
10
+ end
11
+
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"
35
+ else
36
+ puts "ERROR: no such generator with name: '#{option}' is available"
37
+ end
38
+ end
39
+ else
40
+ puts "ERROR: no such command with name: '#{ARGV[0]} found'"
41
+ end
@@ -0,0 +1,24 @@
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'
15
+ end
16
+ end
17
+
18
+ protected
19
+ def banner
20
+ <<-EOF
21
+ Creates config files.
22
+ EOF
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format pretty #{rerun}"
4
+ std_opts = "--verbose --expand --format html --out=./log/log.html --format junit --out=./log features --tags ~@wip --tags ~@bug"
5
+ %>
6
+ default: -r features <%= std_opts %> --tags ~@demo features
7
+ wip: -r features --tags @wip --wip features
8
+ demo: -r features <%= std_opts %> --tags @demo features
9
+ bug: -r features --tags @bug --wip features
10
+ none: --format pretty
11
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,4 @@
1
+ app_host: localhost:3000
2
+ driver: selenium
3
+ sel_browser: chrome
4
+ debug_mode: true
@@ -0,0 +1,76 @@
1
+ ###########################################################
2
+ # COMMON SETTINGS #
3
+ ###########################################################
4
+ debug_mode: false
5
+
6
+ ###########################################################
7
+ # APPLICATION SETTINGS #
8
+ ###########################################################
9
+ app_host: my.website.com
10
+ app_url: "http://${app_host}"
11
+ def_test_user: test@test.com
12
+ def_test_pass: mypass
13
+ def_test_name: Auto Tester
14
+
15
+ ###########################################################
16
+ # TEST ENVIRONMENTS SETTINGS #
17
+ ###########################################################
18
+
19
+ # Specify one of the following drivers: selenium, selenium_dev, webkit, poltergeist, sauce
20
+ driver: webkit
21
+
22
+ # -Selenium-
23
+ # specify one of next browsers: iexplore (ie), firefox (ff), chrome, opera
24
+ sel_browser: ff
25
+ sel_firefox_version: 10
26
+ sel_firebug_version: 1.9.1
27
+ sel_firepath_version: 0.9.7
28
+
29
+ # -SauceLabs-
30
+ sl_user: some_user
31
+ sl_api_key: some_api_key
32
+ sl_url: "http://${sl_user}:${sl_api_key}@ondemand.saucelabs.com:80/wd/hub"
33
+ sl_platform: :VISTA
34
+ sl_browser_name: firefox
35
+ sl_selenium_version: "2.18.0"
36
+ sl_max_duration: '1800'
37
+ sl_idle_timeout: '180'
38
+
39
+ ###########################################################
40
+ # DATABASE SETTINGS #
41
+ ###########################################################
42
+
43
+
44
+
45
+ ###########################################################
46
+ # LOGGER SETTINGS #
47
+ ###########################################################
48
+ log_dir: "log"
49
+ txt_log: log.txt
50
+ selenium_server_log: selenium-server.log
51
+ required_clean_logs: true
52
+
53
+ ###########################################################
54
+ # MAIL SETTINGS #
55
+ ###########################################################
56
+ mail_smtp_server: smtp.demo.com
57
+ mail_smtp_port: 25
58
+ mail_smtp_domain: demo.com
59
+ mail_smtp_user_name: test_user
60
+ mail_smtp_user_pass: mypass
61
+
62
+ mail_pop3_server: pop.demo.com
63
+ mail_pop3_port: 995
64
+ mail_pop3_timeout: 120
65
+ mail_pop3_domain: ${mail_smtp_domain}
66
+ mail_pop3_user_name: test_user
67
+ mail_pop3_user_pass: mypass
68
+
69
+ ############################################################
70
+ # TIMEOUTS #
71
+ ############################################################
72
+ timeout_tiny: 1
73
+ timeout_short: 3
74
+ timeout_small: 20
75
+ timeout_medium: 60
76
+
@@ -0,0 +1,31 @@
1
+ require 'rbconfig'
2
+
3
+ class CucumberGenerator < RubiGen::Base
4
+ def initialize(runtime_args, runtime_options = {})
5
+ super
6
+ @destination_root = File.expand_path('features')
7
+ end
8
+
9
+ def manifest
10
+ record do |m|
11
+ m.directory ''
12
+ BASEDIRS.each{|path| m.directory path}
13
+ m.template 'common_steps.rb', 'step_definitions/common_steps.rb'
14
+ m.template 'env.rb', 'support/env.rb'
15
+ m.template 'transformers.rb', 'support/transformers.rb'
16
+ m.template 'example.feature', 'example.feature'
17
+ end
18
+ end
19
+
20
+ protected
21
+ def banner
22
+ <<-EOS
23
+ Creates cucumber features structure.
24
+ EOS
25
+ end
26
+
27
+ BASEDIRS = %w(
28
+ step_definitions
29
+ support
30
+ )
31
+ end
@@ -0,0 +1,23 @@
1
+ #############################################################
2
+ # PREREQUISITES #
3
+ #############################################################
4
+
5
+ Given /^I have entered (.*) into the calculator$/ do |input_|
6
+ pending
7
+ end
8
+
9
+ ####################################
10
+ # ACTIONS #
11
+ ####################################
12
+
13
+ When /^I press (.*)$/ do |button|
14
+ pending
15
+ end
16
+
17
+ ####################################
18
+ # CHECKS #
19
+ ####################################
20
+
21
+ Then /^the result should be (.*) on the screen$/ do |output|
22
+ pending
23
+ end
@@ -0,0 +1,38 @@
1
+ require 'cucumber'
2
+ require 'capybara/cucumber'
3
+ require_relative '../../boot'
4
+
5
+ World(CapybaraSettings)
6
+ World(DataGenerator)
7
+
8
+ log.settings_as_formatted_text
9
+ DataStorage.store('sauce', :start_time, Time.now.utc)
10
+ DataStorage.store('sauce', :status, true)
11
+
12
+ if sauce_driver?
13
+ Capybara.drivers[:sauce][].options[:desired_capabilities][:name] = CapybaraSettings.suite_name
14
+ end
15
+
16
+ Before do |scenario|
17
+ log.print_feature_name(scenario.feature.title)
18
+ log.print_scenario_name(scenario.name)
19
+ @session_start = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
20
+ end
21
+
22
+ After do |scenario|
23
+ Gen.delete_all_mailboxes
24
+ if sauce_driver?
25
+ DataStorage.store('sauce', :status, false) if scenario.failed?
26
+ session_end = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
27
+ log.info "SAUCE VIDEO #@session_start - #{session_end} URL: #{sauce_resource_path('video.flv')}"
28
+ end
29
+ DataStorage.clear_ns("user")
30
+ end
31
+
32
+ at_exit do
33
+ if sauce_driver?
34
+ log.info "SAUCE SERVER LOG URL: #{CapybaraSettings.sauce_resource_path('selenium-server.log')}"
35
+ CapybaraSettings.update_sauce_job_status(passed: DataStorage.extract('sauce', :status))
36
+ end
37
+ Gen.delete_all_mailboxes
38
+ end