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
@@ -1,31 +1,25 @@
1
- require 'rbconfig'
1
+ require_relative '../base_generator'
2
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'
3
+ module Howitzer
4
+ class CucumberGenerator < BaseGenerator
5
+ def manifest
6
+ { files:
7
+ [
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
+ }
17
16
  end
18
- end
19
17
 
20
- protected
21
- def banner
22
- <<-EOS
23
- Creates cucumber features structure.
24
- EOS
18
+ protected
19
+ def banner
20
+ <<-EOS
21
+ Integrates Cucumber to the framework
22
+ EOS
23
+ end
25
24
  end
26
-
27
- BASEDIRS = %w(
28
- step_definitions
29
- support
30
- )
31
25
  end
@@ -1,23 +1,16 @@
1
- require 'rbconfig'
1
+ require_relative '../base_generator'
2
2
 
3
- class EmailsGenerator < RubiGen::Base
4
-
5
- def initialize(runtime_args, runtime_options = {})
6
- super
7
- @destination_root = File.expand_path('emails')
8
- end
9
-
10
- def manifest
11
- record do |m|
12
- m.directory ''
13
- m.template 'example_email.rb', 'example_email.rb'
3
+ module Howitzer
4
+ class EmailsGenerator < BaseGenerator
5
+ def manifest
6
+ { files: [ source: 'example_email.rb', destination: '/emails/example_email.rb' ] }
14
7
  end
15
- end
16
8
 
17
- protected
18
- def banner
19
- <<-EOS
20
- Creates a simple email class."
21
- EOS
9
+ protected
10
+ def banner
11
+ <<-EOS
12
+ Creates a simple email class."
13
+ EOS
14
+ end
22
15
  end
23
16
  end
@@ -1,6 +1,7 @@
1
1
  class TestEmail < Email
2
2
  SUBJECT = "Test email"
3
3
 
4
+
4
5
  def addressed_to?(new_user)
5
6
  /Hi #{new_user}/ === plain_text_body
6
7
  end
@@ -1,23 +1,21 @@
1
- require 'rbconfig'
1
+ require_relative '../base_generator'
2
2
 
3
- class PagesGenerator < RubiGen::Base
4
- def initialize(runtime_args, runtime_options = {})
5
- super
6
- @destination_root = File.expand_path('pages')
7
- end
8
-
9
- def manifest
10
- record do |m|
11
- m.directory ''
12
- m.template 'example_page.rb', 'example_page.rb'
13
- m.template 'example_menu.rb', 'example_menu.rb'
3
+ module Howitzer
4
+ class PagesGenerator < BaseGenerator
5
+ def manifest
6
+ { files:
7
+ [
8
+ { source: 'example_page.rb', destination: 'pages/example_page.rb'},
9
+ { source: 'example_menu.rb', destination: 'pages/example_menu.rb'}
10
+ ]
11
+ }
14
12
  end
15
- end
16
13
 
17
- protected
18
- def banner
19
- <<-EOS
20
- Creates PageOriented pattern structure
21
- EOS
14
+ protected
15
+ def banner
16
+ <<-EOS
17
+ Creates PageOriented pattern structure
18
+ EOS
19
+ end
22
20
  end
23
21
  end
@@ -1,4 +1,5 @@
1
1
  module ExampleMenu
2
+
2
3
  def self.included(base)
3
4
  base.class_eval do
4
5
  add_locator :menu_button, ".menuButton"
@@ -2,7 +2,7 @@ require_relative 'example_menu'
2
2
 
3
3
  class ExamplePage < WebPage
4
4
  URL = '/'
5
- URL_PATTERN = /#{Regexp.escape(settings.app_host)}\/?/
5
+ validates :url, pattern: /#{Regexp.escape(settings.app_host)}\/?/
6
6
 
7
7
  add_field_locator :search_input, 'lst-ib'
8
8
  add_button_locator :search_btn, 'btnK'
@@ -1,25 +1,23 @@
1
- require 'rbconfig'
1
+ require_relative '../base_generator'
2
2
 
3
- class RootGenerator < RubiGen::Base
4
- def initialize(runtime_args, runtime_options = {})
5
- super
6
- @destination_root = File.expand_path('')
7
- end
8
-
9
- def manifest
10
- record do |m|
11
- m.directory ''
12
- m.template '.gitignore', '.gitignore'
13
- m.template 'Gemfile', 'Gemfile'
14
- m.template 'Rakefile', 'Rakefile'
15
- m.template 'boot.rb', 'boot.rb'
3
+ module Howitzer
4
+ class RootGenerator < BaseGenerator
5
+ def manifest
6
+ { files:
7
+ [
8
+ { source: '.gitignore', destination: '.gitignore'},
9
+ { source: 'Gemfile', destination: 'Gemfile'},
10
+ { source: 'Rakefile', destination: 'Rakefile'},
11
+ { source: 'boot.rb', destination: 'boot.rb'}
12
+ ]
13
+ }
16
14
  end
17
- end
18
15
 
19
- protected
20
- def banner
21
- <<-EOF
22
- Creates root config files.
23
- EOF
16
+ protected
17
+ def banner
18
+ <<-EOF
19
+ Creates root config files.
20
+ EOF
21
+ end
24
22
  end
25
23
  end
@@ -11,10 +11,11 @@ tmp/
11
11
  .rakeTasks
12
12
  .bundle
13
13
  .DS_STORE
14
+ .DS_Store
14
15
  *.xml
15
16
  *.log
16
17
  *.pem
17
18
  build-number.txt
18
19
  sauce_connect.log*
19
20
  *.*~
20
- capybara-*.html
21
+ capybara-*.html
@@ -1,4 +1,5 @@
1
1
  source "https://rubygems.org"
2
- source "http://gemcutter.org"
3
2
 
4
- gem 'howitzer'
3
+ gem 'howitzer', git: "git://github.com/romikoops/howitzer.git", branch: "develop"
4
+ gem 'debugger'
5
+
@@ -1,4 +1,14 @@
1
1
  require 'rake'
2
+ require 'rake/clean'
3
+ require 'howitzer/settings'
4
+ require 'howitzer/utils/log'
5
+
6
+ Dir.chdir(File.join(File.dirname(__FILE__), '.'))
7
+
8
+ if settings.required_clean_logs
9
+ CLEAN.include("#{settings.log_dir}/*")
10
+ Rake::Task[:clean].invoke
11
+ end
2
12
 
3
13
  Dir['tasks/**/*.rake'].each { |rake| load rake }
4
14
  ENV['RAKE_TASK'] = ARGV[0] if /^(?:r?spec|cucumber)/ === ARGV[0]
@@ -1,16 +1,10 @@
1
- require 'howitzer'
2
-
3
1
  Dir.chdir(File.join(File.dirname(__FILE__), '.'))
4
2
 
5
3
  def settings
6
4
  SexySettings::Base.instance()
7
5
  end
8
6
 
9
- if settings.required_clean_logs
10
- require 'rake/clean'
11
- CLEAN.include("#{settings.log_dir}/*")
12
- Rake::Task[:clean].invoke
13
- end
7
+ require 'howitzer'
14
8
 
15
- Dir[File.join(File.dirname(__FILE__), "./emails/*.rb")].each {|f| require f}
16
- Dir[File.join(File.dirname(__FILE__), "./pages/*.rb")].each {|f| require f}
9
+ Dir[File.join(File.dirname(__FILE__), "./emails/**/*.rb")].each {|f| require f}
10
+ Dir[File.join(File.dirname(__FILE__), "./pages/**/*.rb")].each {|f| require f}
@@ -0,0 +1,23 @@
1
+ require_relative '../base_generator'
2
+
3
+ module Howitzer
4
+ class RspecGenerator < BaseGenerator
5
+ def manifest
6
+ { files:
7
+ [
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
+ }
13
+ end
14
+
15
+ protected
16
+ def banner
17
+ <<-EOS
18
+ Integrates RSpec to the framework.
19
+ EOS
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Some feature" do
4
+ it "test scenario" do
5
+ expect(true).to be_true
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ require 'rspec'
2
+ 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}"
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
30
+ end
31
+
32
+ end
33
+
34
+ task default: "rspec:all"
@@ -0,0 +1,56 @@
1
+ require 'rspec'
2
+ require 'capybara/rspec'
3
+ require_relative '../boot'
4
+
5
+ RSpec.configure do |config|
6
+ log.settings_as_formatted_text
7
+
8
+ DataStorage.store('sauce', :start_time, Time.now.utc)
9
+ DataStorage.store('sauce', :status, true)
10
+
11
+ config.include CapybaraSettings
12
+ config.include Capybara::RSpecMatchers
13
+ config.include DataGenerator
14
+
15
+ config.mock_with(:rspec){|c| c.syntax = :expect}
16
+ config.expect_with(:rspec) { |c| c.syntax = :expect }
17
+
18
+ config.color_enabled = true
19
+ config.treat_symbols_as_metadata_keys_with_true_values = true
20
+
21
+ config.before(:all) do
22
+ if sauce_driver?
23
+ suite_name = "#{(ENV['RAKE_TASK'] || 'CUSTOM').sub("rspec:", '').upcase} #{settings.sl_browser_name.upcase}"
24
+ Capybara.drivers[:sauce][].options[:desired_capabilities][:name] = suite_name
25
+ end
26
+ end
27
+
28
+ config.before(:each) do
29
+ log.print_scenario_name(example.description.empty? ? example.metadata[:full_description] : example.description)
30
+ @session_start = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
31
+ end
32
+
33
+ config.after(:each) do
34
+ Gen.delete_all_mailboxes
35
+ DataStorage.clear_ns("user")
36
+ if sauce_driver?
37
+ session_end = duration(Time.now.utc - DataStorage.extract('sauce', :start_time))
38
+ log.info "SAUCE VIDEO #@session_start - #{session_end} URL: #{sauce_resource_path('video.flv')}"
39
+ end
40
+ end
41
+
42
+ config.after(:suite) do
43
+ if sauce_driver?
44
+ report_failures_count = config.reporter.instance_variable_get(:@failure_count)
45
+ DataStorage.store('sauce', :status, report_failures_count.zero?)
46
+ end
47
+ end
48
+
49
+ at_exit do
50
+ if sauce_driver?
51
+ log.info "SAUCE SERVER LOG URL: #{CapybaraSettings.sauce_resource_path('selenium-server.log')}"
52
+ CapybaraSettings.update_sauce_job_status(passed: DataStorage.extract('sauce', :status))
53
+ end
54
+ Gen.delete_all_mailboxes
55
+ end
56
+ end
@@ -1,22 +1,16 @@
1
- require 'rbconfig'
1
+ require_relative '../base_generator'
2
2
 
3
- class TasksGenerator < RubiGen::Base
4
- def initialize(runtime_args, runtime_options = {})
5
- super
6
- @destination_root = File.expand_path('tasks')
7
- end
8
-
9
- def manifest
10
- record do |m|
11
- m.directory ''
12
- m.template 'cucumber.rake', 'cucumber.rake'
3
+ module Howitzer
4
+ class TasksGenerator < BaseGenerator
5
+ def manifest
6
+ { files: [ source: 'common.rake', destination: 'tasks/common.rake' ] }
13
7
  end
14
- end
15
8
 
16
- protected
17
- def banner
18
- <<-EOF
19
- Creates RAKE tasks folder and file.
20
- EOF
9
+ protected
10
+ def banner
11
+ <<-EOF
12
+ Creates RAKE tasks folder and file.
13
+ EOF
14
+ end
21
15
  end
22
16
  end
@@ -0,0 +1,15 @@
1
+ desc "Check broken links"
2
+ task :check_links do
3
+ require 'rawler'
4
+ require 'active_support/core_ext'
5
+ require 'howitzer/helpers'
6
+
7
+ log.settings_as_formatted_text
8
+ opts = {
9
+ wait: 0.1,
10
+ logfile: File.expand_path(settings.rawler_log, settings.log_dir)
11
+ }
12
+ opts[:username] = settings.app_base_auth_login unless settings.app_base_auth_login.blank?
13
+ opts[:password] = settings.app_base_auth_pass unless settings.app_base_auth_pass.blank?
14
+ Rawler::Base.new(app_base_url, $stdout, opts).validate
15
+ end
data/howitzer.gemspec CHANGED
@@ -15,11 +15,11 @@ Gem::Specification.new do |gem|
15
15
  gem.name = "howitzer"
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = Howitzer::VERSION
18
- gem.required_ruby_version = '~> 1.9.2'
18
+ gem.required_ruby_version = '>= 1.9.3'
19
19
 
20
20
  gem.add_runtime_dependency 'rake'
21
- gem.add_runtime_dependency 'rubigen'
22
21
  gem.add_runtime_dependency 'i18n'
22
+ gem.add_runtime_dependency 'syntax'
23
23
  gem.add_runtime_dependency 'cucumber'
24
24
  gem.add_runtime_dependency 'rspec', '~> 2.0'
25
25
  gem.add_runtime_dependency 'sexy_settings'
@@ -29,4 +29,15 @@ Gem::Specification.new do |gem|
29
29
  gem.add_runtime_dependency 'mail'
30
30
  gem.add_runtime_dependency 'rest-client'
31
31
  gem.add_runtime_dependency 'poltergeist'
32
+ gem.add_runtime_dependency 'rawler'
33
+ gem.add_runtime_dependency 'capybara'
34
+ gem.add_runtime_dependency 'selenium-webdriver'
35
+ gem.add_runtime_dependency 'activeresource', '~>4.0'
36
+ gem.add_runtime_dependency 'testingbot'
37
+
38
+ gem.add_development_dependency("rspec", [">= 2.14.1"])
39
+ gem.add_development_dependency("fuubar", [">= 0.0.1"])
40
+ gem.add_development_dependency("rake")
41
+ gem.add_development_dependency("ffaker")
42
+
32
43
  end