auto_test 0.0.9.3.4 → 0.0.9.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module AutoTest
2
- VERSION = "0.0.9.3.4"
2
+ VERSION = "0.0.9.3.5"
3
3
  end
@@ -1,195 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
- require 'auto_test/lib/auto_test'
5
- #
6
- # describe "Application" do
7
- #
8
- # describe "error path reduction" do
9
- # it "reduces the path to the error" do
10
- # load "#{Rails.root}/db/test_seeds.rb"
11
- # init_path
12
- # init_user_inputs
13
- # init_sessions
14
- # init_sessions_array
15
- # number_of_sessions = user_inputs("get_number_of_sessions").to_i
16
- # for i in 0..number_of_sessions-1 do
17
- # sess = Capybara::Session.new(:rack_test,Rails.application)
18
- # add_to_sessions_array sess
19
- # init_hash_sessions(i, Hash.new)
20
- # end
21
- # init_err_file
22
- # lno = 0
23
- # paths = File.new("lib/auto_test/log/paths.log")
24
- # user = Array.new(3)
25
- # session_index = 0
26
- # begin
27
- # puts "try_path 1"
28
- # puts Time.now
29
- # while line = paths.gets do
30
- # lno = lno + 1
31
- # # puts lno
32
- # if !line.chop!.end_with? "ID" then
33
- # hash = Hash.new
34
- #
35
- # a = line.gsub!(/[{}\"]/,'').split(/\=\>/)
36
- # session = get_sessions_array[a[0].split(":").first.to_i]
37
- # session_index = get_sessions_array.index(session)
38
- # if a[0].split(":").second == user_inputs("get_login_path") then
39
- # begin
40
- # # necesarry if user data has changed
41
- # # might have to be rescued if the user doesn´t exist anymore.
42
- # user[session_index] = user[session_index].class.find(user[session_index].id)
43
- # rescue
44
- # end
45
- # session.visit user_inputs("get_login_path")
46
- # hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = session.all('input').find_all{ |i| i[:type] == "submit"}.first.value
47
- # if user_inputs("use_db_users") then
48
- # user_inputs("get_login_attributes").each do |field|
49
- # session.fill_in field[1], :with => user[session_index].send(field[0].to_sym)
50
- # end
51
- # else
52
- # index = user_inputs("get_login_names").index(user_inputs("get_unique_login_attribute_name"))
53
- # user[session_index].class.find(:all).each do |u|
54
- # user_inputs("get_login_data").each do |d|
55
- # if d[index] == u.send(user_inputs("get_unique_login_attribute_name").to_sym) then
56
- # user_data = user_inputs("get_login_data")[index]
57
- # end
58
- # end
59
- # end
60
- # user_inputs("get_login_attributes").each_with_index do |field, i|
61
- # session.fill_in field[1], :with => user_data[i]
62
- # end
63
- # end
64
- # session.all('input').find_all{ |i| i[:type] == "submit"}.first.click
65
- # elsif a[1] == user_inputs("get_logout_path") then
66
- # hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = user_inputs("get_logout_path")
67
- # session.visit user_inputs("get_logout_path")
68
- # elsif a[1][0] == "[" then
69
- # texts = []
70
- # inputs = a[1][1,a[1].size-2].split(/,/)
71
- # i = 0
72
- # while i < inputs.size do
73
- # texts << inputs[i].strip
74
- # texts << inputs[i+1].strip
75
- # if inputs[i].strip.start_with? "radio___" then
76
- # session.choose inputs[i + 1].strip
77
- # elsif inputs[i].strip.start_with? "select___" then
78
- # session.select inputs[i + 1].strip, :from => inputs[i].gsub("select___",'').strip
79
- # else
80
- # input = session.all('input').find{ |inp| inp[:name] == inputs[i].strip}
81
- # input.set(inputs[i+1].strip)
82
- # end
83
- # i = i + 2
84
- # end
85
- # hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = texts
86
- # session.all('input').find_all{ |i| i[:type] == "submit"}.first.click
87
- # else
88
- # link = a[1].split(/\+\+\+/)
89
- # href = link[0]
90
- # text = link[1]
91
- # link = session.all('a').find{ |l| l[:href] == href && l.text == text }
92
- # hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = link[:href].to_s + "+++" + link.text.to_s
93
- # link.click
94
- # end
95
- # add_path(hash)
96
- #
97
- # else
98
- # add_path(line)
99
- # line_parts = line.split(":")
100
- # session_index = line_parts[0].to_i
101
- # id = line_parts[1].to_i
102
- # # get the Constant from the String, to find the right class
103
- # user[session_index] = Kernel.const_get(user_inputs("user_class")).find(id)
104
- # end
105
- # end
106
- # rescue => e
107
- # if err_message == e.message.to_s.split(/:/,2).first then
108
- # # puts "Found error again!"
109
- # add_path(hash)
110
- # last_path = path + []
111
- # puts Time.now
112
- #
113
- # puts "Replace"
114
- # puts Time.now
115
- # replace_same_users!(last_path)
116
- # puts Time.now
117
- # user_count = user_count(last_path)
118
- # puts "Half"
119
- # puts Time.now
120
- # # test the path, getting divided
121
- # for i in 1..user_count do
122
- # error_not_found = false
123
- # index = nil
124
- # path_still_changing = true
125
- # last_index = nil
126
- # while !error_not_found && path_still_changing do
127
- # return_val = delete_links_half_way(last_path, index, i)
128
- # index = return_val[1]
129
- # if index == last_index then
130
- # path_still_changing = false
131
- # else
132
- # last_index = index
133
- # path_still_changing = true
134
- # end
135
- # next_path = return_val[0]
136
- # error_not_found = try_path(next_path)
137
- # while error_not_found do
138
- # return_val = delete_links_half_way(last_path, index, i)
139
- # index = return_val[1]
140
- # next_path = return_val[0]
141
- # error_not_found = try_path(next_path)
142
- # end
143
- # if !error_not_found then
144
- # last_path = next_path
145
- # end
146
- # index = nil
147
- # end
148
- # end
149
- # puts Time.now
150
- #
151
- # puts "Jump"
152
- # puts Time.now
153
- # new_path = jump_to_last_user(last_path)
154
- # init_enlarging_counter
155
- # error_not_found = true
156
- # # test the jump_to_last_user path
157
- # while error_not_found do
158
- # error_not_found = try_path(new_path)
159
- # if error_not_found then
160
- # new_path = enlarge_path(last_path)
161
- # end
162
- # end
163
- # puts Time.now
164
- # last_path = new_path
165
- #
166
- #
167
- # puts "Delete Groups"
168
- # puts Time.now
169
- # last_path = delete_groups(last_path)
170
- # puts Time.now
171
- #
172
- # puts "Single"
173
- # puts Time.now
174
- # last_path = delete_single_links(last_path)
175
- # puts Time.now
176
- # puts "Delete IDs"
177
- # puts Time.now
178
- # delete_ids(last_path)
179
- # puts Time.now
180
- # f = File.new("lib/auto_test/log/new_path.log", "w")
181
- # f.puts last_path
182
- # f.close
183
- # else
184
- # puts "Different error, stopping..."
185
- # puts e
186
- # end
187
- # end
188
- # end
189
- # end
190
- # end
191
- #
192
-
4
+ require 'auto_test'
193
5
 
194
6
 
195
7
  describe "Application" do
@@ -209,18 +21,15 @@ describe "Application" do
209
21
  end
210
22
  init_err_file
211
23
  lno = 0
212
- paths = File.new("lib/auto_test/log/paths.log")
24
+ paths = File.new("#{gem_path}/../../log/paths.log")
213
25
  user = Array.new(number_of_sessions)
214
26
  session_index = 0
215
27
  begin
216
- puts "try_path 1"
217
- puts Time.now
28
+ # puts Time.now
218
29
  while line = paths.gets do
219
30
  lno = lno + 1
220
- # puts lno
221
31
  if !line.chop!.end_with? "ID" then
222
- hash = Hash.new
223
-
32
+ hash = Hash.new
224
33
  a = line.gsub!(/[{}\"]/,'').split(/\=\>/)
225
34
  session = get_sessions_array[a[0].split(":").first.to_i]
226
35
  session_index = get_sessions_array.index(session)
@@ -294,85 +103,59 @@ describe "Application" do
294
103
  user[session_index] = Kernel.const_get(user_inputs("user_class")).find(id)
295
104
  end
296
105
  end
297
- rescue => e
298
- if err_message == e.message.to_s.split(/:/,2).first then
299
- # puts "Found error again!"
300
- add_path(hash)
301
- puts Time.now
302
- puts "Jump"
303
- puts Time.now
304
- new_path = jump_to_last_user(path)
305
- init_enlarging_counter
306
- error_not_found = true
307
- # test the jump_to_last_user path
308
- while error_not_found do
309
- error_not_found = try_path(new_path)
310
- if error_not_found then
311
- new_path = enlarge_path(path)
312
- end
106
+ rescue => e
107
+ if err_message == e.message.to_s.split(/:/,2).first then
108
+ add_path(hash)
109
+ new_path = jump_to_last_user(path)
110
+ init_enlarging_counter
111
+ error_not_found = true
112
+ # test the jump_to_last_user path
113
+ while error_not_found do
114
+ error_not_found = try_path(new_path)
115
+ if error_not_found then
116
+ new_path = enlarge_path(path)
313
117
  end
314
- puts Time.now
315
- last_path = new_path
316
-
317
- puts "Replace"
318
- puts Time.now
319
- replace_same_users!(last_path)
320
- puts Time.now
321
- user_count = user_count(last_path)
322
- puts "Half"
323
- puts Time.now
324
- # test the path, getting divided
325
- for i in 1..user_count do
326
- error_not_found = false
327
- index = nil
328
- path_still_changing = true
329
- last_index = nil
330
- while !error_not_found && path_still_changing do
118
+ end
119
+ last_path = new_path
120
+ replace_same_users!(last_path)
121
+ user_count = user_count(last_path)
122
+ # test the path, getting divided
123
+ for i in 1..user_count do
124
+ error_not_found = false
125
+ index = nil
126
+ path_still_changing = true
127
+ last_index = nil
128
+ while !error_not_found && path_still_changing do
129
+ return_val = delete_links_half_way(last_path, index, i)
130
+ index = return_val[1]
131
+ if index == last_index then
132
+ path_still_changing = false
133
+ else
134
+ last_index = index
135
+ path_still_changing = true
136
+ end
137
+ next_path = return_val[0]
138
+ error_not_found = try_path(next_path)
139
+ while error_not_found do
331
140
  return_val = delete_links_half_way(last_path, index, i)
332
141
  index = return_val[1]
333
- if index == last_index then
334
- path_still_changing = false
335
- else
336
- last_index = index
337
- path_still_changing = true
338
- end
339
142
  next_path = return_val[0]
340
143
  error_not_found = try_path(next_path)
341
- while error_not_found do
342
- return_val = delete_links_half_way(last_path, index, i)
343
- index = return_val[1]
344
- next_path = return_val[0]
345
- error_not_found = try_path(next_path)
346
- end
347
- if !error_not_found then
348
- last_path = next_path
349
- end
350
- index = nil
351
144
  end
145
+ if !error_not_found then
146
+ last_path = next_path
147
+ end
148
+ index = nil
352
149
  end
353
- puts Time.now
354
-
355
- puts "Delete Groups"
356
- puts Time.now
357
- last_path = delete_groups(last_path)
358
- puts Time.now
359
-
360
- puts "Single"
361
- puts Time.now
362
- last_path = delete_single_links(last_path)
363
- puts Time.now
364
- puts "Delete IDs"
365
- puts Time.now
366
- delete_ids(last_path)
367
- puts Time.now
368
- f = File.new("lib/auto_test/log/new_path.log", "w")
369
- f.puts last_path
370
- f.close
371
- else
372
- puts "Different error, stopping..."
373
- puts e
374
- end
375
- end
150
+ end
151
+ last_path = delete_groups(last_path)
152
+ last_path = delete_single_links(last_path)
153
+ delete_ids(last_path)
154
+ f = File.new("#{gem_path}/../../log/new_path.log", "w")
155
+ f.puts last_path
156
+ f.close
157
+ end
158
+ end
376
159
  end
377
160
  end
378
161
  end
@@ -610,7 +393,6 @@ def try_path(path_to_try)
610
393
  error_not_found = true
611
394
  begin
612
395
  lno = 0
613
- # puts lno
614
396
  while lno < path_to_try.size do
615
397
  hash = Hash.new
616
398
  line = path_to_try[lno]
@@ -622,7 +404,6 @@ def try_path(path_to_try)
622
404
  end
623
405
  session_index = get_sessions_array.index(session)
624
406
  lno = lno + 1
625
- # puts lno
626
407
  if line.class == Hash then
627
408
  if line.values[0] == "Anmelden" then
628
409
  session.visit user_inputs("get_login_path")
@@ -774,12 +555,9 @@ def try_path(path_to_try)
774
555
  #puts "Found Error again, go on..."
775
556
  error_not_found = false
776
557
  else
777
- f = File.new("lib/auto_test/log/debugging.log", "w")
558
+ f = File.new("#{gem_path}/../../log/debugging.log", "w")
778
559
  f.puts path_to_try
779
560
  f.close
780
- # puts "Different Error:" + e.message.to_s
781
- # puts lno
782
- # puts line
783
561
  error_not_found = true
784
562
  end
785
563
  return error_not_found
@@ -947,7 +725,7 @@ end
947
725
 
948
726
  def init_user_inputs
949
727
  @user_inputs = Hash.new
950
- file = File.new("lib/auto_test/log/user_input.log", "r")
728
+ file = File.new("#{gem_path}/../../log/user_input.log", "r")
951
729
  while line = file.gets do
952
730
  b = line.split(/:/,2)
953
731
  @user_inputs["#{b[0].strip}"] = b[1].chop
@@ -989,3 +767,7 @@ def add_path(value)
989
767
  @path << value
990
768
  end
991
769
 
770
+ def gem_path
771
+ path = %x(gem which auto_test)
772
+ path = path[0..path.size-13]
773
+ end
@@ -6,7 +6,7 @@ namespace :auto_test do
6
6
  sh "rails server -e test -p 3002 -d"
7
7
  path = %x(gem which auto_test)
8
8
  path = path[0..path.size-13]
9
- sh "rspec '#{path}/../spec/requests/auto_spec.rb' -o '#{path}/../../log/rspec.txt'"
9
+ sh "rspec '#{path}/../spec/requests/auto_spec.rb'"# -o '#{path}/../../log/rspec.txt'"
10
10
  Rake::Task["auto_test:error_calc"].invoke
11
11
  Rake::Task["auto_test:stop"].invoke
12
12
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: auto_test
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.9.3.4
5
+ version: 0.0.9.3.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Maike Hargens