rubygene 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +3 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +152 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/rubygene +207 -0
  11. data/bin/setup +8 -0
  12. data/lib/SkeletonApi/.gitignore +1 -0
  13. data/lib/SkeletonApi/Gemfile +6 -0
  14. data/lib/SkeletonApi/README.md +36 -0
  15. data/lib/SkeletonApi/Rakefile +11 -0
  16. data/lib/SkeletonApi/cucumber.yml +13 -0
  17. data/lib/SkeletonApi/features/services/.gitkeep +0 -0
  18. data/lib/SkeletonApi/features/specifications/.gitkeep +0 -0
  19. data/lib/SkeletonApi/features/steps_definitions/.gitkeep +0 -0
  20. data/lib/SkeletonApi/features/support/config/dev.yaml +1 -0
  21. data/lib/SkeletonApi/features/support/config/hmg.yaml +1 -0
  22. data/lib/SkeletonApi/features/support/env.rb +13 -0
  23. data/lib/SkeletonApi/results/report.html +0 -0
  24. data/lib/SkeletonApi/results/report.json +0 -0
  25. data/lib/SkeletonMobile/.gitignore +1 -0
  26. data/lib/SkeletonMobile/Gemfile +7 -0
  27. data/lib/SkeletonMobile/README.md +37 -0
  28. data/lib/SkeletonMobile/cucumber.yml +7 -0
  29. data/lib/SkeletonMobile/features/screens/.gitkeep +0 -0
  30. data/lib/SkeletonMobile/features/specifications/.gitkeep +0 -0
  31. data/lib/SkeletonMobile/features/steps_definitions/.gitkeep +0 -0
  32. data/lib/SkeletonMobile/features/support/appium.txt +4 -0
  33. data/lib/SkeletonMobile/features/support/env.rb +25 -0
  34. data/lib/SkeletonMobile/features/support/helper.rb +11 -0
  35. data/lib/SkeletonMobile/features/support/hooks.rb +23 -0
  36. data/lib/SkeletonMobile/features/support/page_helper.rb +3 -0
  37. data/lib/SkeletonMobile/results/report.html +0 -0
  38. data/lib/SkeletonMobile/results/report.json +0 -0
  39. data/lib/SkeletonMobile/results/screenshots/.gitkeep +0 -0
  40. data/lib/SkeletonWeb/.gitignore +1 -0
  41. data/lib/SkeletonWeb/Gemfile +10 -0
  42. data/lib/SkeletonWeb/README.md +49 -0
  43. data/lib/SkeletonWeb/Rakefile +23 -0
  44. data/lib/SkeletonWeb/cucumber.yml +15 -0
  45. data/lib/SkeletonWeb/features/pages/.gitkeep +0 -0
  46. data/lib/SkeletonWeb/features/specifications/.gitkeep +0 -0
  47. data/lib/SkeletonWeb/features/steps_definitions/.gitkeep +0 -0
  48. data/lib/SkeletonWeb/features/support/config/dev.yml +1 -0
  49. data/lib/SkeletonWeb/features/support/config/hmg.yml +1 -0
  50. data/lib/SkeletonWeb/features/support/env.rb +34 -0
  51. data/lib/SkeletonWeb/features/support/helper.rb +22 -0
  52. data/lib/SkeletonWeb/features/support/hooks.rb +15 -0
  53. data/lib/SkeletonWeb/features/support/page_helper.rb +6 -0
  54. data/lib/SkeletonWeb/results/report.html +0 -0
  55. data/lib/SkeletonWeb/results/report.json +0 -0
  56. data/lib/SkeletonWeb/results/screenshots/.gitkeep +0 -0
  57. data/lib/generate_ruby_tests/generate_ruby_test_helper.rb +59 -0
  58. data/lib/generate_ruby_tests/version.rb +3 -0
  59. data/lib/generate_ruby_tests.rb +5 -0
  60. data/lib/locales/en.yml +7 -0
  61. data/lib/locales/pt.yml +7 -0
  62. data/lib/templates/feature.tt +8 -0
  63. data/lib/templates/page.tt +6 -0
  64. data/lib/templates/screens.tt +5 -0
  65. data/lib/templates/services.tt +8 -0
  66. data/lib/templates/steps.tt +5 -0
  67. data/rubygene.gemspec +30 -0
  68. metadata +198 -0
@@ -0,0 +1,37 @@
1
+ ## Getting Started ##
2
+
3
+ ### Installing gems ###
4
+ To install gems type:
5
+ ```shell
6
+ bundle install
7
+ ```
8
+
9
+ ### Run tests in DEV ###
10
+ Type this in the tests folder:
11
+ ```shell
12
+ bundle exec cucumber
13
+ ```
14
+
15
+ ### Run tests in HMG ###
16
+ Type this in the tests folder:
17
+ ```shell
18
+ bundle exec cucumber -p json -p hmg
19
+ ```
20
+
21
+ ### HTML Report###
22
+ Type this in the tests folder:
23
+ ```shell
24
+ bundle exec cucumber -p html -p hmg
25
+ ```
26
+
27
+ ### Json Report###
28
+ Type this in the tests folder:
29
+ ```shell
30
+ bundle exec cucumber -p json -p hmg
31
+ ```
32
+
33
+ ### Run with tags###
34
+ Type this in the tests folder:
35
+ ```shell
36
+ bundle exec cucumber --tags @run
37
+ ```
@@ -0,0 +1,7 @@
1
+ ## YAML Templatesss
2
+ ---
3
+ default: -p pretty -p html
4
+ for_ci: --format progress
5
+ pretty: --format pretty
6
+ html: --format html --out=results/report.html
7
+ html: --format json --out=results/json.html
File without changes
@@ -0,0 +1,4 @@
1
+ [caps]
2
+ deviceName = "Nexus 5X API 25"
3
+ platformName= "Android"
4
+ app = "caminho_do_app.apk"
@@ -0,0 +1,25 @@
1
+ require 'appium_lib'
2
+ require 'yaml'
3
+ require_relative 'page_helper.rb'
4
+ require_relative 'helper.rb'
5
+
6
+ SERVER_URL = 'http://localhost:4723/wd/hub'.freeze
7
+ PORT = 4723
8
+ TWENTY_SECONDS = 20
9
+
10
+ World(Screens)
11
+ World(Helper)
12
+
13
+ Before do
14
+ def opts
15
+ {
16
+ caps: {
17
+ deviceName: 'Nexus 5X API 25',
18
+ platformName: 'Android',
19
+ app: File.join(File.dirname(__FILE__), 'nome_do_seu_app.apk'),
20
+ newCommandTimeout: '3600'
21
+ },
22
+ appium_lib: { server_url: SERVER_URL, port: PORT }
23
+ }
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ # !/usr/bin/env ruby
3
+ # metodo para tira screenshot e imbutir no relatorio html
4
+ module Helper
5
+ def take_screenshot(file_name, result)
6
+ file_path = "results/screenshots/test_#{result}"
7
+ screenshot = "#{file_path}/#{file_name}.png"
8
+ @driver.screenshot(screenshot)
9
+ embed(screenshot, 'image/png', 'Click here')
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ Before do
2
+ @appium_driver = Appium::Driver.new(opts, true)
3
+ Appium.promote_appium_methods Object
4
+ @settings = YAML.load_file(File.expand_path('../../cucumber.yml',
5
+ File.dirname(__FILE__)))
6
+ @driver.start_driver
7
+ @driver.set_wait(TWENTY_SECONDS)
8
+ end
9
+
10
+ def scroll_screen(xone, yone, xtwo, ytwo)
11
+ Appium::TouchAction.new.long_press(x: xone, y: yone)
12
+ .move_to(x: xtwo, y: ytwo).release.perform
13
+ end
14
+
15
+ After do |scenario|
16
+ scenario_name = scenario.name.gsub(/\s+/, '_').tr('/', '_')
17
+
18
+ if scenario.failed?
19
+ take_screenshot(scenario_name.downcase!, 'failed')
20
+ else
21
+ take_screenshot(scenario_name.downcase!, 'passed')
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ # Modulos para chamar as classes instanciadas
2
+ module Screens
3
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ .DS_Store
@@ -0,0 +1,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'capybara', '3.0.3'
4
+ gem 'cucumber'
5
+ gem 'selenium-webdriver'
6
+ gem 'rspec'
7
+ gem 'site_prism', '2.15'
8
+ gem 'syntax'
9
+ gem 'rubocop'
10
+ gem 'byebug'
@@ -0,0 +1,49 @@
1
+ ## Getting Started ##
2
+
3
+
4
+
5
+ ### Installing gems ###
6
+ To install gems type:
7
+ ```shell
8
+ bundle install
9
+ ```
10
+
11
+ ### Drivers: ###
12
+ Install and include in PATH
13
+ - [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)
14
+ - [phantomjs](http://phantomjs.org/)
15
+ - [internetExplorerDriver](http://www.seleniumhq.org/download/)
16
+ - [Firefox Geckodriver](https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver)
17
+
18
+ Install [Webdriver Safari extension](http://selenium-release.storage.googleapis.com/2.48/SafariDriver.safariextz).
19
+
20
+
21
+ ### Run tests in DEV with Chrome###
22
+ Type this in the tests folder:
23
+ ```shell
24
+ bundle exec cucumber -p ci -p html -p headless -p dev
25
+ ```
26
+
27
+ ### Run tests in DEV with headless###
28
+ Type this in the tests folder:
29
+ ```shell
30
+ bundle exec cucumber -p ci -p html -p headless -p dev
31
+ ```
32
+
33
+ ### Run tests in HMG with Chrome###
34
+ Type this in the tests folder:
35
+ ```shell
36
+ bundle exec cucumber -p pretty -p html -p no_headless -p hmg
37
+ ```
38
+
39
+ ### Run tests in HMG with headless###
40
+ Type this in the tests folder:
41
+ ```shell
42
+ bundle exec cucumber -p ci -p html -p headless -p hmg
43
+ ```
44
+
45
+ ### Run with tags###
46
+ Type this in the tests folder:
47
+ ```shell
48
+ bundle exec cucumber --tags @run
49
+ ```
@@ -0,0 +1,23 @@
1
+ desc "Executar os testes em dev usando o Chrome"
2
+ task :test_chrome_dev do
3
+ puts "Executando test:chrome:dev"
4
+ sh "bundle exec cucumber -p pretty -p html -p dev -p no_headless"
5
+ end
6
+
7
+ desc "Executar os testes em dev usando o Chrome headless"
8
+ task :test_chrome_dev_headless do
9
+ puts "Executando test:chrome:dev"
10
+ sh "bundle exec cucumber -p ci -p html -p dev -p headless"
11
+ end
12
+
13
+ desc "Executar os testes em hmg usando o Chrome"
14
+ task :test_chrome_hmg do
15
+ puts "Executando test:chrome:dev"
16
+ sh "bundle exec cucumber -p pretty -p html -p hmg -p no_headless"
17
+ end
18
+
19
+ desc "Executar os testes em hmg usando o Chrome headless"
20
+ task :test_chrome_hmg_headless do
21
+ puts "Executando test:chrome:dev"
22
+ sh "bundle exec cucumber -p ci -p html -p hmg -p headless"
23
+ end
@@ -0,0 +1,15 @@
1
+ ## YAML Templatesss
2
+ ---
3
+ default: -p pretty -p html -p no_headless -p hmg
4
+
5
+ pretty: --format pretty
6
+ ci: --format progress
7
+
8
+ html: --format html --out=results/report.html
9
+ json: --format json --out=results/report.json
10
+
11
+ hmg: ENVIRONMENT_TYPE=hmg
12
+ dev: ENVIRONMENT_TYPE=dev
13
+
14
+ headless: HEADLESS=headless
15
+ no_headless: HEADLESS=no_headless
File without changes
File without changes
@@ -0,0 +1 @@
1
+ url_default: https://www.google.com/
@@ -0,0 +1 @@
1
+ url_default: https://www.google.com/
@@ -0,0 +1,34 @@
1
+ require 'capybara'
2
+ require 'capybara/cucumber'
3
+ require 'byebug'
4
+ require 'selenium-webdriver'
5
+ require 'site_prism'
6
+ require 'rspec'
7
+ require_relative 'helper.rb'
8
+ require_relative 'page_helper.rb'
9
+
10
+ World(Pages)
11
+ World(Helper)
12
+
13
+ ENVIRONMENT_TYPE = ENV['ENVIRONMENT_TYPE']
14
+ HEADLESS = ENV['HEADLESS']
15
+
16
+ CONFIG = YAML.load_file(File.dirname(__FILE__) + "/config/#{ENVIRONMENT_TYPE}.yml")
17
+
18
+ ## register driver according with browser chosen
19
+ Capybara.register_driver :selenium do |app|
20
+ if HEADLESS.eql?('headless')
21
+ option = ::Selenium::WebDriver::Chrome::Options.new(args: ['--headless', '--disable-gpu', '--window-size=1600,1024'])
22
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: option)
23
+
24
+ elsif HEADLESS.eql?('no_headless')
25
+ option = ::Selenium::WebDriver::Chrome::Options.new(args: ['--disable-infobars', 'window-size=1600,1024'])
26
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: option)
27
+ end
28
+ end
29
+
30
+ Capybara.configure do |config|
31
+ config.default_driver = :selenium
32
+ config.app_host = CONFIG['url_default']
33
+ config.default_max_wait_time = 30
34
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ # !/usr/bin/env ruby
3
+ require 'fileutils'
4
+ # metodo para tira screenshot e imbutir no relatorio html
5
+ module Helper
6
+ def take_screenshot(file_name, result)
7
+ file_path = "results/screenshots/test_#{result}"
8
+ screenshot = "#{file_path}/#{file_name}.png"
9
+ page.save_screenshot(screenshot)
10
+ embed(screenshot, 'image/png', 'Click here')
11
+ end
12
+
13
+ def wait_for_ajax
14
+ Timeout.timeout(Capybara.default_max_wait_time) do
15
+ loop until finished_all_ajax_requests?
16
+ end
17
+ end
18
+
19
+ def finished_all_ajax_requests?
20
+ page.evaluate_script('jQuery.active').zero?
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'helper.rb'
2
+
3
+ After do |scenario|
4
+ scenario_name = scenario.name.gsub(/\s+/, '_').tr('/', '_')
5
+ scenario_name = scenario_name.gsub(',', '')
6
+ scenario_name = scenario_name.gsub('(', '')
7
+ scenario_name = scenario_name.gsub(')', '')
8
+ scenario_name = scenario_name.gsub('#', '')
9
+
10
+ if scenario.failed?
11
+ take_screenshot(scenario_name.downcase!, 'failed')
12
+ else
13
+ take_screenshot(scenario_name.downcase!, 'passed')
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ Dir[File.join(File.dirname(__FILE__),
2
+ '../pages/*_page.rb')].each { |file| require file }
3
+
4
+ # Modulos para chamar as classes instanciadas
5
+ module Pages
6
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ def create_feature_file(name)
5
+ # opcoes usadas para gerar o arquivo na funcao de modelo
6
+ opts = { name: camelize(name) }
7
+ # Thor cria um arquivo com base no modelo templates/feature.tt
8
+ template('feature', File.join(FileUtils.pwd, 'features', 'specifications',
9
+ "#{name.downcase}.feature"), opts)
10
+ end
11
+
12
+ def create_steps_file(name)
13
+ # opcoes usadas para gerar o arquivo na funcao de modelo
14
+ opts = { name: camelize(name) }
15
+ # Thor cria um arquivo com base no modelo templates/steps.tt
16
+ template('steps', File.join(FileUtils.pwd, 'features', 'steps_definitions',
17
+ "#{name.downcase}_steps.rb"), opts)
18
+ end
19
+
20
+ def create_page_file(name)
21
+ # opcoes usadas para gerar o arquivo na funcao de modelo
22
+ opts = { name: camelize(name) }
23
+ # Thor cria um arquivo com base no modelo templates/page.tt
24
+ template('page', File.join(FileUtils.pwd, 'features', 'pages',
25
+ "#{name.downcase}_page.rb"), opts)
26
+ end
27
+
28
+ def create_service_file(name)
29
+ # opcoes usadas para gerar o arquivo na funcao de modelo
30
+ opts = { name: camelize(name) }
31
+ # Thor cria um arquivo com base no modelo templates/services.tt
32
+ template('services', File.join(FileUtils.pwd, 'features', 'services',
33
+ "#{name.downcase}_services.rb"), opts)
34
+ end
35
+
36
+ def create_screens_file(name)
37
+ # opcoes usadas para gerar o arquivo na funcao de modelo
38
+ opts = { name: camelize(name) }
39
+ # Thor cria um arquivo com base no modelo templates/screens.tt
40
+ template('screens', File.join(FileUtils.pwd, 'features', 'screens',
41
+ "#{name.downcase}_screens.rb"), opts)
42
+ end
43
+
44
+ def camelize(string)
45
+ camelized = ''
46
+ string.split('_').each do |s|
47
+ camelized += s.capitalize
48
+ end
49
+ camelized
50
+ end
51
+
52
+ def in_root_project_folder?
53
+ # Olha se o usuario esta na pasta raiz do projeto
54
+ unless Dir.exist?(File.join(FileUtils.pwd, 'features', 'specifications'))
55
+ puts 'Please run this command on the root folder of the project'
56
+ exit 1
57
+ end
58
+ true
59
+ end
@@ -0,0 +1,3 @@
1
+ module GenerateRubyTests
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "generate_ruby_tests/version"
2
+
3
+ module GenerateRubyTests
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,7 @@
1
+ en:
2
+ first_scenario: "First Scenario"
3
+ comments:
4
+ insert_steps: "Insert steps"
5
+ elements: "Declare all the elements of this page"
6
+ actions: "Declare all actions of this page"
7
+ services: "Where is the configuration of a particular request"
@@ -0,0 +1,7 @@
1
+ pt:
2
+ first_scenario: "Primeiro Cenário"
3
+ comments:
4
+ insert_steps: "Insira os passos"
5
+ elements: "Declare todos os elementos da página"
6
+ actions: "Declare todas as ações da página"
7
+ services: "Onde fica as configuraçōes de uma determinada requisição"
@@ -0,0 +1,8 @@
1
+ <%= "# language: #{options[:lang]}" %>
2
+ <%= I18n.translate( :feature ) %>: <%= config[:name] %>
3
+
4
+ <%= I18n.translate( :background ) %>:
5
+ # <%= I18n.translate( "comments.insert_steps" ) %>
6
+
7
+ <%= I18n.translate( :scenario ) %>: <%= I18n.translate( :first_scenario ) %>
8
+ # <%= I18n.translate( "comments.insert_steps" ) %>
@@ -0,0 +1,6 @@
1
+ class <%= config[:name] %>Page < SitePrism::Page
2
+
3
+ # <%= I18n.translate 'comments.elements' %>
4
+ # element :button, pending 'Insert button identificator'
5
+
6
+ end
@@ -0,0 +1,5 @@
1
+ class <%= config[:name] %>Screen
2
+
3
+ # <%= I18n.translate 'comments.elements' %>
4
+
5
+ end
@@ -0,0 +1,8 @@
1
+ module <%= config[:name] %>Service
2
+ include HTTParty
3
+
4
+ # <%= I18n.translate 'comments.services' %>
5
+ base_uri CONFIG['url_default'].to_s
6
+ headers 'Content-Type' => 'application/json'
7
+ format :json
8
+ end
@@ -0,0 +1,5 @@
1
+ ######### <%= I18n.translate( :given ).upcase %> #########
2
+
3
+ ######### <%= I18n.translate( :when ).upcase %> #########
4
+
5
+ ######### <%= I18n.translate( :then ).upcase %> #########
data/rubygene.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'generate_ruby_tests/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'rubygene'
7
+ spec.version = GenerateRubyTests::VERSION
8
+ spec.authors = ['brunobatista25']
9
+ spec.email = ['brunobatista101@gmail.com']
10
+ spec.summary = %q{Generates an Web,Api and Mobile Test Automation project with Cucumber,
11
+ SitePrism, Capybara, Selenium, Httparty and JsonSchema.}
12
+ spec.description = %q{A simple gem to generate all files needed in a
13
+ project Mobile, Web and Api.}
14
+ spec.homepage = 'https://github.com/brunobatista25/RubyGene'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+
21
+ spec.executables = ['rubygene']
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.16'
25
+ spec.add_runtime_dependency 'gherkin', '2.12.2'
26
+ spec.add_runtime_dependency 'i18n', '>= 0.8.6'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_runtime_dependency 'thor', '>= 0.19.1'
30
+ end