mini_autobot 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62aec5cf1e896d6538e1fc95e40c7dd363f6fea5
4
- data.tar.gz: 921b07fdf3301c8f90a1b459fc07e002b5b27e97
3
+ metadata.gz: 80059c285bd2170b2b4b42a57868e69a44e64e0f
4
+ data.tar.gz: 52b6b819430bd80b071b2af54feb9da0b22ba88b
5
5
  SHA512:
6
- metadata.gz: 74d3522d79870e1fbaef113596c306552dc4419fb2839f0b0ccc2b5eb5fe19f29072eee254e8c6bfff8ab2118aa649588319b04a910695b597d1c52c9f9b3269
7
- data.tar.gz: 80b79b22143258853c5b67e1a40eb0ee18b04cdffce1d90f17b0d1691734d9338917c8c82d86e78060328ead5089f69d4da46f1f8e7266e054bc7655c51047fc
6
+ metadata.gz: afedd247da6343ded1820432cd07f18b454939ef0501f94a7e8ac38f03fc04a65d6c53cc36e243f86d94df152a538bbde45976942bf919c7e0caf688ea6fcbb6
7
+ data.tar.gz: 2f23f89c7a8704f0f5b4dc980767c7fa538f1f6c40da64a47644ce9b1a021688b4b83e5a42c58c6195b4ff092316520a7fddaae578aef40b1e840113224f97f9
@@ -17,6 +17,7 @@ module MiniAutobot
17
17
  include Utils::Loggable
18
18
  include Utils::PageObjectHelper
19
19
  include Utils::OverlayAndWidgetHelper
20
+ extend ElementContainer
20
21
 
21
22
  attr_accessor :assertions
22
23
  attr_accessor :failures
@@ -44,6 +45,14 @@ module MiniAutobot
44
45
  @failures = []
45
46
  end
46
47
 
48
+ def find_first(how, what)
49
+ driver.find_element(how, what)
50
+ end
51
+
52
+ def find_all(how, what)
53
+ driver.all(how, what)
54
+ end
55
+
47
56
  # Returns the current path loaded in the driver.
48
57
  #
49
58
  # @return [String] The current path, without hostname.
@@ -0,0 +1,50 @@
1
+ module MiniAutobot
2
+ module PageObjects
3
+ module ElementContainer
4
+
5
+ def element(element_name, *find_args)
6
+ build element_name, *find_args do |how, what|
7
+ define_method element_name.to_s do
8
+ find_first(how, what)
9
+ end
10
+ end
11
+ end
12
+
13
+ def elements(collection_name, *find_args)
14
+ build collection_name, *find_args do |how, what|
15
+ define_method collection_name.to_s do
16
+ find_all(how, what)
17
+ end
18
+ end
19
+ end
20
+ alias_method :collection, :elements
21
+
22
+ def add_to_mapped_items(item)
23
+ @mapped_items ||= []
24
+ @mapped_items << item.to_s
25
+ end
26
+
27
+ private
28
+
29
+ def build(name, *find_args)
30
+ if find_args.empty?
31
+ create_no_selector name
32
+ else
33
+ add_to_mapped_items name
34
+ if find_args.size == 1
35
+ yield(:css, *find_args)
36
+ else
37
+ yield(*find_args)
38
+ end
39
+ end
40
+ end
41
+
42
+ def create_no_selector(method_name)
43
+ define_method method_name do
44
+ fail MiniAutobot::NoSelectorForElement.new, "#{self.class.name} => :#{method_name} needs a selector"
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -9,6 +9,7 @@ module MiniAutobot
9
9
  include Utils::Castable
10
10
  include Utils::PageObjectHelper
11
11
  include Utils::OverlayAndWidgetHelper
12
+ extend ElementContainer
12
13
 
13
14
  attr_reader :driver
14
15
 
@@ -25,6 +26,14 @@ module MiniAutobot
25
26
  @page
26
27
  end
27
28
 
29
+ def find_first(how, what)
30
+ driver.find_element(how, what)
31
+ end
32
+
33
+ def find_all(how, what)
34
+ driver.all(how, what)
35
+ end
36
+
28
37
  # By default, any driver state is accepted for any page. This method
29
38
  # should be overridden in subclasses.
30
39
  def validate!
@@ -9,6 +9,7 @@ module MiniAutobot
9
9
  include Utils::Castable
10
10
  include Utils::PageObjectHelper
11
11
  include Utils::OverlayAndWidgetHelper
12
+ extend ElementContainer
12
13
 
13
14
  attr_reader :driver, :element, :page
14
15
 
@@ -23,8 +24,13 @@ module MiniAutobot
23
24
  @page
24
25
  end
25
26
 
26
- attr_reader :driver
27
- attr_reader :element
27
+ def find_first(how, what)
28
+ element.find_element(how, what)
29
+ end
30
+
31
+ def find_all(how, what)
32
+ element.all(how, what)
33
+ end
28
34
 
29
35
  # Explicitly wait for a certain condition to be true:
30
36
  # wait.until { driver.find_element(:css, 'body.tmpl-srp') }
@@ -17,6 +17,7 @@ module MiniAutobot
17
17
  end
18
18
 
19
19
  # Major classes and modules
20
+ require_relative 'page_objects/element_container'
20
21
  require_relative 'page_objects/base'
21
22
  require_relative 'page_objects/overlay/base'
22
23
  require_relative 'page_objects/widgets/base'
@@ -5,7 +5,8 @@ module MiniAutobot
5
5
 
6
6
  def initialize(simultaneous_jobs, all_tests)
7
7
  @start_time = Time.now
8
- clean_result!
8
+
9
+ @result_dir = 'logs/tap_results'
9
10
 
10
11
  connector = MiniAutobot.settings.connector
11
12
  @on_sauce = true if connector.include? 'saucelabs'
@@ -30,12 +31,41 @@ module MiniAutobot
30
31
  @platform.include?('osx')
31
32
  end
32
33
 
33
- # remove all results files under logs/tap_results/ if there's any
34
+ # remove all results files under @result_dir if there's any
34
35
  def clean_result!
35
- FileUtils.rm_rf(Dir.glob('logs/tap_results/*')) unless Dir.glob('logs/tap_results/*').empty?
36
+ raise Exception, '@result_dir is not set' if @result_dir.nil?
37
+ unless Dir.glob("#{@result_dir}/*").empty?
38
+ FileUtils.rm_rf(Dir.glob("#{@result_dir}/*"))
39
+ end
36
40
  puts "Cleaning result files.\n"
37
41
  end
38
42
 
43
+ def remove_redundant_tap
44
+ ever_failed_tests_file = "#{@result_dir}/ever_failed_tests.json"
45
+ if File.file? ever_failed_tests_file
46
+ data_hash = JSON.parse(File.read(ever_failed_tests_file))
47
+ data_hash.keys.each do |test|
48
+ if test.start_with? 'test_'
49
+ tap_result_file = "#{@result_dir}/#{test}.t"
50
+ result_lines = IO.readlines(tap_result_file)
51
+ last_tap_start_index = 0
52
+ last_tap_end_index = result_lines.size - 1
53
+ result_lines.each_with_index do |l, index|
54
+ last_tap_start_index = index if l.delete!("\n") == '1..1'
55
+ end
56
+ File.open(tap_result_file, 'w') do |f|
57
+ f.puts result_lines[last_tap_start_index..last_tap_end_index]
58
+ end
59
+ puts "Processed #{tap_result_file}"
60
+ else
61
+ next
62
+ end
63
+ end
64
+ else
65
+ puts "==> File #{ever_failed_tests_file} doesn't exist - all tests passed!"
66
+ end
67
+ end
68
+
39
69
  def count_autobot_process
40
70
  counting_process_output = IO.popen "ps -ef | grep 'bin/#{@static_run_command}' -c"
41
71
  counting_process_output.readlines[0].to_i - 1 # minus grep process
@@ -60,13 +90,12 @@ module MiniAutobot
60
90
 
61
91
  Process.waitall
62
92
  puts "\nAll Complete! Started at #{@start_time} and finished at #{Time.now}\n"
63
- exit
64
93
  end
65
94
 
66
95
  # runs each test from a test set in a separate child process
67
96
  def run_test_set(test_set)
68
97
  test_set.each do |test|
69
- run_command = "#{@static_run_command} -n #{test} #{@pipe_tap} > logs/tap_results/#{test}.t"
98
+ run_command = "#{@static_run_command} -n #{test} #{@pipe_tap} > #{@result_dir}/#{test}.t"
70
99
  pipe = IO.popen(run_command)
71
100
  puts "Running #{test} #{pipe.pid}"
72
101
  end
@@ -101,7 +101,10 @@ module MiniAutobot
101
101
 
102
102
  if @@runnables_count == mini_autobot_runnables.size
103
103
  parallel = Parallel.new(MiniAutobot.settings.parallel, @@selected_methods)
104
+ parallel.clean_result!
104
105
  parallel.run_in_parallel!
106
+ parallel.remove_redundant_tap if MiniAutobot.settings.rerun_failure
107
+ exit
105
108
  end
106
109
 
107
110
  return [] # no test will run
@@ -1,3 +1,3 @@
1
1
  module MiniAutobot
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_autobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ripta Pasay
@@ -10,174 +10,174 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-15 00:00:00.000000000 Z
13
+ date: 2016-02-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
21
  version: '4.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  version: '4.2'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: faker
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ~>
34
34
  - !ruby/object:Gem::Version
35
35
  version: '1.4'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ~>
41
41
  - !ruby/object:Gem::Version
42
42
  version: '1.4'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: minitap
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
47
+ - - ~>
48
48
  - !ruby/object:Gem::Version
49
49
  version: 0.5.3
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
54
+ - - ~>
55
55
  - !ruby/object:Gem::Version
56
56
  version: 0.5.3
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: pry
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - "~>"
61
+ - - ~>
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0.10'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - "~>"
68
+ - - ~>
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0.10'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: minitest
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - "~>"
75
+ - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 5.4.0
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - "~>"
82
+ - - ~>
83
83
  - !ruby/object:Gem::Version
84
84
  version: 5.4.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: selenium-webdriver
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
89
+ - - ~>
90
90
  - !ruby/object:Gem::Version
91
91
  version: '2.46'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - "~>"
96
+ - - ~>
97
97
  - !ruby/object:Gem::Version
98
98
  version: '2.46'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: rest-client
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - "~>"
103
+ - - ~>
104
104
  - !ruby/object:Gem::Version
105
105
  version: '1.8'
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - "~>"
110
+ - - ~>
111
111
  - !ruby/object:Gem::Version
112
112
  version: '1.8'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rake
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">="
117
+ - - '>='
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: rspec
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - "~>"
131
+ - - ~>
132
132
  - !ruby/object:Gem::Version
133
133
  version: 3.3.0
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - "~>"
138
+ - - ~>
139
139
  - !ruby/object:Gem::Version
140
140
  version: 3.3.0
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: guard
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ">="
145
+ - - '>='
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ">="
152
+ - - '>='
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: guard-minitest
157
157
  requirement: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ">="
159
+ - - '>='
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  type: :development
163
163
  prerelease: false
164
164
  version_requirements: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ">="
166
+ - - '>='
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: yard
171
171
  requirement: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - ">="
173
+ - - '>='
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
178
  version_requirements: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ">="
180
+ - - '>='
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  description: |-
@@ -190,9 +190,9 @@ executables:
190
190
  extensions: []
191
191
  extra_rdoc_files: []
192
192
  files:
193
- - ".gitignore"
194
- - ".rspec"
195
- - ".ruby-version"
193
+ - .gitignore
194
+ - .rspec
195
+ - .ruby-version
196
196
  - Gemfile
197
197
  - LICENSE
198
198
  - README.md
@@ -208,6 +208,7 @@ files:
208
208
  - lib/mini_autobot/logger.rb
209
209
  - lib/mini_autobot/page_objects.rb
210
210
  - lib/mini_autobot/page_objects/base.rb
211
+ - lib/mini_autobot/page_objects/element_container.rb
211
212
  - lib/mini_autobot/page_objects/overlay/base.rb
212
213
  - lib/mini_autobot/page_objects/widgets/base.rb
213
214
  - lib/mini_autobot/parallel.rb
@@ -240,17 +241,17 @@ require_paths:
240
241
  - lib
241
242
  required_ruby_version: !ruby/object:Gem::Requirement
242
243
  requirements:
243
- - - ">="
244
+ - - '>='
244
245
  - !ruby/object:Gem::Version
245
246
  version: '0'
246
247
  required_rubygems_version: !ruby/object:Gem::Requirement
247
248
  requirements:
248
- - - ">="
249
+ - - '>='
249
250
  - !ruby/object:Gem::Version
250
251
  version: '0'
251
252
  requirements: []
252
253
  rubyforge_project:
253
- rubygems_version: 2.4.5.1
254
+ rubygems_version: 2.0.14
254
255
  signing_key:
255
256
  specification_version: 4
256
257
  summary: Web automation framework on minitest, selenium webdriver, and page objects.