mini_autobot 1.0.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c214dc6a65bed2d41f3c7ec0f9bb5ac7df24263
4
- data.tar.gz: 8db93a791eb4f29d235f775b4d42aebefac0c184
3
+ metadata.gz: e684144ffd7a276b076a65763d4f0d849b31a4a9
4
+ data.tar.gz: 294c362c21616c0bebba7a470be94b98b925f55d
5
5
  SHA512:
6
- metadata.gz: 0a9e36fa370f2cc199cab1ce0d07f0d8342d71074a2bf3cb46e6808b831596d426458c795f63079ba9fbac2e7f597696059d93f8251ae20d68cf0a9ab0261d2a
7
- data.tar.gz: 81b617d5e61a17786da396bb9011bf3a8c6b46e237dc3117b511be2d69f65a36998c86d9485152512277cd1547d484b180f25caf0e07d4f66c3c0445d83aa885
6
+ metadata.gz: 1515a7f66e0d545647aee3c12868e67ad1d84c6fb043499ffc7e9cd621ce6f5f129a69c1c7a02c32ee67570d4bca4a6da400959dad2b79e759c7c9c811c5d4c6
7
+ data.tar.gz: b3bcbddbcf9e96856b48057e60e3ad1cd8fe4f94eef45108643389bf8d5a7abaa7976f0eee72856606a3714494dde76b68dba38275637eac67aa34504ea920ca
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *.gem
2
2
  pkg
3
3
  Gemfile.lock
4
+ vendor
4
5
 
5
6
  # vi swap files (the extra letters are used when there are duplicates)
6
7
  *.sw[ponml]
@@ -0,0 +1,89 @@
1
+ module MiniAutobot
2
+
3
+ # Class that supports integration with Google Sheets
4
+ # See documentation here: https://developers.google.com/drive/v3/web/about-auth to set up OAuth 2.0
5
+ # access to your sheets. Place the info in google_drive_config.json in your config/mini_autobot folder
6
+ #
7
+ # To use, use the -g or --google_sheets parameter with the id of your sheet
8
+ # Example: -g 1gWbpPq7rrTdNtSJSN2ljDlPE-okf0w3w7ai5PlhY8bk
9
+ class GoogleSheets
10
+ require 'rubygems'
11
+ require 'google/api_client'
12
+ require 'google_drive'
13
+ require 'json'
14
+
15
+ def initialize(args)
16
+ @args = args
17
+ @session = session
18
+ @spreadsheet = spreadsheet
19
+ @worksheet = worksheet
20
+ @automation_serial_column = automation_serial_column
21
+ @selected_browser_column = selected_browser_column
22
+ end
23
+
24
+ # Updates all cells with the value provided that have the corresponding key in the Automation Serial Column
25
+ # At the end of your test, place the following line:
26
+ # Example:
27
+ # MiniAutobot.google_sheets.update_cells('Auto Pass', 'HP-1') if MiniAutobot.settings.google_sheets?
28
+ def update_cells(value, key)
29
+ rows = target_rows(key)
30
+ rows.each do |row|
31
+ @worksheet[row, @selected_browser_column] = value
32
+ end
33
+ @worksheet.save
34
+ end
35
+
36
+ private
37
+
38
+ def session
39
+ GoogleDrive.saved_session(@args[:session])
40
+ #GoogleDrive.saved_session(MiniAutobot.root.join('config/mini_autobot', 'google_drive_config.json'))
41
+ end
42
+
43
+ def spreadsheet
44
+ @session.spreadsheet_by_key(@args[:spreadsheet])
45
+ #@session.spreadsheet_by_key(MiniAutobot.settings.google_sheet)
46
+ end
47
+
48
+ def worksheet
49
+ environment_params = MiniAutobot.settings.env.split('_')
50
+ environment_params[0].capitalize!
51
+ environment_params[1].upcase!
52
+ environment = environment_params[0] + ' ' + environment_params[1]
53
+ worksheets = @spreadsheet.worksheets
54
+ worksheet = worksheets.find { |worksheet| worksheet.title == environment }
55
+ if worksheet.nil?
56
+ worksheet = worksheets.find { |worksheet| worksheet.title == environment_params[1] }
57
+ end
58
+ worksheet
59
+ end
60
+
61
+ # Determines which column the keys are that define the link between your automated test cases
62
+ # and the test cases in your Google Sheets spreadsheet
63
+ def automation_serial_column
64
+ (1..@worksheet.num_cols).find { |col| @worksheet[1, col] == 'Automation Serial Key' }
65
+ end
66
+
67
+ # This is the column where you record the results for a specific browser
68
+ def selected_browser_column
69
+ connector = MiniAutobot.settings.connector
70
+ desired_browser_string = nil
71
+ case connector
72
+ when /chrome/
73
+ desired_browser_string = 'Chrome'
74
+ when /ff/
75
+ desired_browser_string = 'FF'
76
+ when /firefox/
77
+ desired_browser_string = 'FF'
78
+ when /ie11/
79
+ desired_browser_string = 'IE11'
80
+ end
81
+ (1..@worksheet.num_cols).find { |col| @worksheet[1, col] == desired_browser_string }
82
+ end
83
+
84
+ def target_rows(key)
85
+ (1..@worksheet.num_rows).find_all { |row| @worksheet[row, @automation_serial_column] == key }
86
+ end
87
+
88
+ end
89
+ end
@@ -45,6 +45,10 @@ module MiniAutobot
45
45
  @@__gem_root__ ||= Pathname.new(File.realpath(File.join(File.dirname(__FILE__), '..', '..')))
46
46
  end
47
47
 
48
+ def self.google_sheets
49
+ @@google_sheets ||= GoogleSheets.new(session: MiniAutobot.root.join('config/mini_autobot', 'google_drive_config.json'), spreadsheet: MiniAutobot.settings.google_sheet)
50
+ end
51
+
48
52
  end
49
53
 
50
54
  require_relative 'runner'
@@ -55,6 +59,7 @@ require_relative 'connector'
55
59
  require_relative 'page_objects'
56
60
  require_relative 'parallel'
57
61
  require_relative 'settings'
62
+ require_relative 'google_sheets'
58
63
 
59
64
  require_relative 'test_case'
60
65
  require_relative 'console'
@@ -93,6 +93,14 @@ module MiniAutobot
93
93
  hsh.fetch(:verbosity_level, 0).to_i
94
94
  end
95
95
 
96
+ def google_sheets?
97
+ hsh[:google_sheets] != false
98
+ end
99
+
100
+ def google_sheet
101
+ hsh[:google_sheets]
102
+ end
103
+
96
104
  private
97
105
  attr_reader :hsh
98
106
 
@@ -1,3 +1,3 @@
1
1
  module MiniAutobot
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -78,6 +78,11 @@ module Minitest
78
78
  integer_value = value.nil? ? 1 : value.to_i
79
79
  options[:rerun_failure] = integer_value
80
80
  end
81
+
82
+ options[:google_sheets] = false
83
+ parser.on('-g', '--google-sheets SHEET', 'Report results to specified Google Sheets spreadsheet') do |value|
84
+ options[:google_sheets] = value
85
+ end
81
86
  end
82
87
 
83
88
  end
data/mini_autobot.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'mini_autobot/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "mini_autobot"
7
7
  s.version = MiniAutobot::VERSION
8
- s.authors = ["Ripta Pasay", "Peijie Hu", "RentPath"]
8
+ s.authors = ["Ripta Pasay", "Peijie Hu", "John Theodore", "RentPath"]
9
9
 
10
10
  s.summary = %q{Web automation framework on minitest, selenium webdriver, and page objects.}
11
11
  s.description = %q{Wrapper of minitest and selenium-webdriver that supports multiple webapps
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_autobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ripta Pasay
8
8
  - Peijie Hu
9
+ - John Theodore
9
10
  - RentPath
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2016-02-10 00:00:00.000000000 Z
14
+ date: 2016-02-23 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: activesupport
@@ -201,6 +202,7 @@ files:
201
202
  - lib/mini_autobot.rb
202
203
  - lib/mini_autobot/connector.rb
203
204
  - lib/mini_autobot/console.rb
205
+ - lib/mini_autobot/google_sheets.rb
204
206
  - lib/mini_autobot/init.rb
205
207
  - lib/mini_autobot/logger.rb
206
208
  - lib/mini_autobot/page_objects.rb