auto_test 0.1.9.8 → 0.1.9.8.5

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.
@@ -166,8 +166,8 @@ module AutoTest
166
166
  session.fill_in field[1], :with => user.send(field[0].to_sym)
167
167
  end
168
168
  else
169
- get_login_attributes.each_with_index do |field, i|
170
- session.fill_in field[1], :with => get_user_data[i]
169
+ get_login_fields.each_with_index do |field, i|
170
+ session.fill_in field, :with => get_user_data[i]
171
171
  end
172
172
  end
173
173
  session.click_button get_login_button
@@ -1,3 +1,3 @@
1
1
  module AutoTest
2
- VERSION = "0.1.9.8"
2
+ VERSION = "0.1.9.8.5"
3
3
  end
data/lib/page.rb CHANGED
@@ -187,14 +187,13 @@ module AutoTest
187
187
  session.choose choices[i]
188
188
  end
189
189
 
190
- # choose a random checkbox
190
+ # choose a checkbox
191
191
  def choose_checkbox(name, input_texts, session)
192
192
  checkboxes = session.all('input').find_all{ |i| i[:type] == "checkbox" && i[:name] == name }
193
- choices = checkboxes.collect{ |r| r[:name] }
194
- i = rand(choices.length)
193
+ cb = checkboxes.first
195
194
  input_texts << "checkbox___" + name
196
- input_texts << choices[i].to_s
197
- session.check choices[i]
195
+ input_texts << cb[:value]
196
+ session.check cb[:name]
198
197
  end
199
198
 
200
199
  # select a random option from a select list
@@ -6,17 +6,17 @@ require 'auto_test'
6
6
 
7
7
  describe "Application" do
8
8
  describe "error path reduction" do
9
+ if AutoTest::Test.use_fixtures? then
10
+ fixtures(*AutoTest::Test.get_fixtures)
11
+ end
9
12
  it "reduces the path to the error" do
10
- init_user_inputs
13
+ DatabaseCleaner.strategy = :transaction
14
+ DatabaseCleaner.start
11
15
  load "#{Rails.root}/db/test_seeds.rb"
12
- if user_inputs("use_fixtures") then
13
- fixtures(*user_inputs("get_fixtures"))
14
- end
15
16
  init_path
16
-
17
17
  init_sessions
18
18
  init_sessions_array
19
- number_of_sessions = user_inputs("get_number_of_sessions").to_i
19
+ number_of_sessions = AutoTest::Test.get_number_of_sessions
20
20
  for i in 0..number_of_sessions-1 do
21
21
  sess = Capybara::Session.new(:rack_test,Rails.application)
22
22
  add_to_sessions_array sess
@@ -28,82 +28,81 @@ describe "Application" do
28
28
  user = Array.new(number_of_sessions)
29
29
  session_index = 0
30
30
  begin
31
- # puts Time.now
32
31
  while line = paths.gets do
33
32
  lno = lno + 1
34
33
  if !line.chop!.end_with? "ID" then
35
34
  hash = Hash.new
36
- a = line.gsub!(/[{}\"]/,'').split(/\=\>/)
37
- session = get_sessions_array[a[0].split(":").first.to_i]
38
- session_index = get_sessions_array.index(session)
39
- if a[0].split(":").second == user_inputs("get_login_path") then
40
- begin
41
- # necesarry if user data has changed
42
- # might have to be rescued if the user doesn´t exist anymore.
43
- user[session_index] = user[session_index].class.find(user[session_index].id)
44
- rescue
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 == AutoTest::Authentication.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 AutoTest::Authentication.get_login_path
46
+ hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = AutoTest::Authentication.get_login_button
47
+ if AutoTest::Authentication.use_db_users then
48
+ AutoTest::Authentication.get_login_attributes.each do |field|
49
+ session.fill_in field[1], :with => user[session_index].send(field[0].to_sym)
45
50
  end
46
- session.visit user_inputs("get_login_path")
47
- hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = user_inputs("get_login_button")
48
- if user_inputs("use_db_users") then
49
- user_inputs("get_login_attributes").each do |field|
50
- session.fill_in field[1], :with => user[session_index].send(field[0].to_sym)
51
- end
51
+ else
52
+ user_data = nil
53
+ index = AutoTest::Authentication.get_login_names.index(AutoTest::Authentication.get_unique_login_attribute_name)
54
+ user[session_index].class.find(:all).each do |u|
55
+ AutoTest::Authentication.get_login_data.each do |d|
56
+ if d[index] == u.send(AutoTest::Authentication.get_unique_login_attribute_name.to_sym) then
57
+ user_data = AutoTest::Authentication.get_login_data[index]
58
+ end
59
+ end
60
+ end
61
+ AutoTest::Authentication.get_login_attributes.each_with_index do |field, i|
62
+ session.fill_in field[1], :with => user_data[i]
63
+ end
64
+ end
65
+ session.click_button AutoTest::Authentication.get_login_button
66
+ elsif a[1] == AutoTest::Authentication.get_logout_path then
67
+ hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = AutoTest::Authentication.get_logout_path
68
+ session.visit AutoTest::Authentication.get_logout_path
69
+ elsif a[1][0] == "[" then
70
+ texts = []
71
+ inputs = a[1][1,a[1].size-2].split(/,/)
72
+ i = 0
73
+ while i < inputs.size do
74
+ texts << inputs[i].strip
75
+ texts << inputs[i+1].strip
76
+ if inputs[i].strip.start_with? "radio___" then
77
+ session.choose inputs[i + 1].strip
78
+ elsif inputs[i].strip.start_with? "select___" then
79
+ session.select inputs[i + 1].strip, :from => inputs[i].gsub("select___",'').strip
80
+ elsif inputs[i].strip.start_with? "checkbox___" then
81
+ session.check inputs[i].gsub("checkbox___",'').strip
52
82
  else
53
- index = user_inputs("get_login_names").index(user_inputs("get_unique_login_attribute_name"))
54
- user[session_index].class.find(:all).each do |u|
55
- user_inputs("get_login_data").each do |d|
56
- if d[index] == u.send(user_inputs("get_unique_login_attribute_name").to_sym) then
57
- user_data = user_inputs("get_login_data")[index]
58
- end
59
- end
60
- end
61
- user_inputs("get_login_attributes").each_with_index do |field, i|
62
- session.fill_in field[1], :with => user_data[i]
63
- end
64
- end
65
- session.click_button user_inputs("get_login_button")
66
- elsif a[1] == user_inputs("get_logout_path") then
67
- hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = user_inputs("get_logout_path")
68
- session.visit user_inputs("get_logout_path")
69
- elsif a[1][0] == "[" then
70
- texts = []
71
- inputs = a[1][1,a[1].size-2].split(/,/)
72
- i = 0
73
- while i < inputs.size do
74
- texts << inputs[i].strip
75
- texts << inputs[i+1].strip
76
- if inputs[i].strip.start_with? "radio___" then
77
- session.choose inputs[i + 1].strip
78
- elsif inputs[i].strip.start_with? "select___" then
79
- session.select inputs[i + 1].strip, :from => inputs[i].gsub("select___",'').strip
80
- elsif inputs[i].strip.start_with? "checkbox___" then
81
- session.check inputs[i + 1].strip
82
- else
83
- input = session.all('input').find{ |inp| inp[:name] == inputs[i].strip}
84
- input.set(inputs[i+1].strip)
85
- end
86
- i = i + 2
83
+ input = session.all('input').find{ |inp| inp[:name] == inputs[i].strip}
84
+ input.set(inputs[i+1].strip)
87
85
  end
88
- hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = texts
89
- session.all('input').find_all{ |i| i[:type] == "submit"}.first.click
90
- else
91
- link = a[1].split(/\+\+\+/)
92
- href = link[0]
93
- text = link[1]
94
- link = session.all('a').find{ |l| l[:href] == href && l.text == text }
95
- hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = link[:href].to_s + "+++" + link.text.to_s
96
- link.click
86
+ i = i + 2
97
87
  end
98
- add_path(hash)
99
-
88
+ hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = texts
89
+ session.all('input').find_all{ |i| i[:type] == "submit"}.first.click
90
+ else
91
+ link = a[1].split(/\+\+\+/)
92
+ href = link[0]
93
+ text = link[1]
94
+ link = session.all('a').find{ |l| l[:href] == href && l.text == text }
95
+ hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = link[:href].to_s + "+++" + link.text.to_s
96
+ link.click
97
+ end
98
+ add_path(hash)
100
99
  else
101
100
  add_path(line)
102
101
  line_parts = line.split(":")
103
102
  session_index = line_parts[0].to_i
104
103
  id = line_parts[1].to_i
105
104
  # get the Constant from the String, to find the right class
106
- user[session_index] = Kernel.const_get(user_inputs("user_class")).find(id)
105
+ user[session_index] = AutoTest::Authentication.user_class.find(id)
107
106
  end
108
107
  end
109
108
  rescue => e
@@ -200,7 +199,7 @@ def delete_links_without_input(new_path, number_of_links, session)
200
199
  # if the part of the session to be deleted is finished,
201
200
  # has no inputs and is smaller or equal to the wanted number of links,
202
201
  # delete the links of the session, other links get added to the path
203
- if n.values[0] == user_inputs("get_logout_path") && no_inputs && current_session == session then
202
+ if n.values[0] == AutoTest::Authentication.get_logout_path && no_inputs && current_session == session then
204
203
  if tmp.select{|x| x.class != String && x.keys[0].split(":").first.to_i == session}.size == number_of_links then
205
204
  tmp.delete_if{|x| x.class != String && x.keys[0].split(":").first.to_i == session}
206
205
  next_path << tmp
@@ -213,7 +212,7 @@ def delete_links_without_input(new_path, number_of_links, session)
213
212
  done = true
214
213
  got_one = false
215
214
  end
216
- elsif n.values[0] == user_inputs("get_logout_path") && current_session == session then
215
+ elsif n.values[0] == AutoTest::Authentication.get_logout_path && current_session == session then
217
216
  next_path << tmp
218
217
  tmp = []
219
218
  done = true
@@ -264,7 +263,7 @@ def delete_groups(new_path)
264
263
  next_path = []
265
264
  new_path.each_with_index do |n,ind|
266
265
  if n.class != String then
267
- if n.keys[0].split(":").second == user_inputs("get_login_path") && n.keys[0].split(":").first.to_i == i then
266
+ if n.keys[0].split(":").second == AutoTest::Authentication.get_login_path && n.keys[0].split(":").first.to_i == i then
268
267
  count = count + 1
269
268
  end
270
269
  if !(n.keys[0].split(":").first.to_i == i && count == no_of_group) then
@@ -283,7 +282,7 @@ def delete_groups(new_path)
283
282
  new_path = next_path
284
283
  end
285
284
  new_path.each do |n|
286
- if n.class != String && n.keys[0].split(":").first.to_i == i && n.values[0] == user_inputs("get_logout_path") then
285
+ if n.class != String && n.keys[0].split(":").first.to_i == i && n.values[0] == AutoTest::Authentication.get_logout_path then
287
286
  no_of_groups = no_of_groups + 1
288
287
  end
289
288
  end
@@ -298,8 +297,8 @@ def delete_single_links(new_path)
298
297
  i = 0
299
298
  while i < new_path.size do
300
299
  if (new_path[i].class != String &&
301
- !(new_path[i].values.include? user_inputs("get_logout_path")) &&
302
- !(new_path[i].keys[0].include? user_inputs("get_login_path"))) then
300
+ !(new_path[i].values.include? AutoTest::Authentication.get_logout_path) &&
301
+ !(new_path[i].keys[0].include? AutoTest::Authentication.get_login_path)) then
303
302
  next_path = new_path[0..i-1]+new_path[i+1..new_path.size]
304
303
  error_not_found = try_path(next_path)
305
304
  if !error_not_found then
@@ -366,7 +365,7 @@ def replace_same_users!(new_path)
366
365
  session = new_path[i].split(":").first.to_i
367
366
  if users[session] == new_path[i] then
368
367
  hash = Hash.new
369
- hash[last_paths[new_path[i].split(":").first.to_i]] = user_inputs("get_logout_path")
368
+ hash[last_paths[new_path[i].split(":").first.to_i]] = AutoTest::Authentication.get_logout_path
370
369
  new_path[i] = hash
371
370
  else
372
371
  users[session] = new_path[i]
@@ -383,7 +382,7 @@ def try_path(path_to_try)
383
382
  lno = 0
384
383
  init_sessions
385
384
  init_sessions_array
386
- number_of_sessions = user_inputs("get_number_of_sessions").to_i
385
+ number_of_sessions = AutoTest::Test.get_number_of_sessions
387
386
  for i in 0..number_of_sessions-1 do
388
387
  sess = Capybara::Session.new(:rack_test,Rails.application)
389
388
  add_to_sessions_array sess
@@ -409,29 +408,29 @@ def try_path(path_to_try)
409
408
  lno = lno + 1
410
409
  if line.class == Hash then
411
410
  if line.values[0] == "Anmelden" then
412
- session.visit user_inputs("get_login_path")
413
- hash["#{session_index}:#{session.current_path}"] = user_inputs("get_login_button")
414
- if user_inputs("use_db_users") then
415
- user_inputs("get_login_attributes").each do |field|
411
+ session.visit AutoTest::Authentication.get_login_path
412
+ hash["#{session_index}:#{session.current_path}"] = AutoTest::Authentication.get_login_button
413
+ if AutoTest::Authentication.use_db_users then
414
+ AutoTest::Authentication.get_login_attributes.each do |field|
416
415
  session.fill_in field[1], :with => user[session_index].send(field[0].to_sym)
417
416
  end
418
417
  else
419
- index = user_inputs("get_login_names").index(user_inputs("get_unique_login_attribute_name"))
418
+ index = AutoTest::Authentication.get_login_names.index(AutoTest::Authentication.get_unique_login_attribute_name)
420
419
  user[session_index].class.find(:all).each do |u|
421
- user_inputs("get_login_data").each do |d|
422
- if d[index] == u.send(user_inputs("get_unique_login_attribute_name").to_sym) then
423
- user_data = user_inputs("get_login_data")[index]
420
+ AutoTest::Authentication.get_login_data.each do |d|
421
+ if d[index] == u.send(AutoTest::Authentication.get_unique_login_attribute_name.to_sym) then
422
+ user_data = AutoTest::Authentication.get_login_data[index]
424
423
  end
425
424
  end
426
425
  end
427
- user_inputs("get_login_attributes").each_with_index do |field, i|
426
+ AutoTest::Authentication.get_login_attributes.each_with_index do |field, i|
428
427
  session.fill_in field[1], :with => user_data[i]
429
428
  end
430
429
  end
431
- session.click_button user_inputs("get_login_button")
432
- elsif line.values[0] == user_inputs("get_logout_path") then
433
- hash["#{session_index}:#{session.current_path}"] = user_inputs("get_logout_path")
434
- session.visit user_inputs("get_logout_path")
430
+ session.click_button AutoTest::Authentication.get_login_button
431
+ elsif line.values[0] == AutoTest::Authentication.get_logout_path then
432
+ hash["#{session_index}:#{session.current_path}"] = AutoTest::Authentication.get_logout_path
433
+ session.visit AutoTest::Authentication.get_logout_path
435
434
  elsif line.values[0].class == Array then
436
435
  inputs = line.values[0]
437
436
  if !session.all('input').empty? then
@@ -522,17 +521,17 @@ def try_path(path_to_try)
522
521
  path_to_try[lno-1].replace(hash)
523
522
  else
524
523
  # if there´s no authorization, no Strings will be saved in the path
525
- if user_inputs("use_db_users") then
524
+ if AutoTest::Authentication.use_db_users then
526
525
  id = line.split(":").second.to_i
527
526
  begin
528
- user[session_index] = Kernel.const_get(user_inputs("user_class")).find(id)
527
+ user[session_index] = AutoTest::Authentication.user_class.find(id)
529
528
  rescue
530
529
  index = lno + 1
531
530
  root_path = ""
532
531
  while root_path == "" && index < path_to_try.size do
533
532
  if path_to_try[index].class != String then
534
533
  if path_to_try[index].keys[0].split(":").first.to_i == session_index then
535
- if path_to_try[index].keys[0].split(":").second != user_inputs("get_login_path") then
534
+ if path_to_try[index].keys[0].split(":").second != AutoTest::Authentication.get_login_path then
536
535
  root_path = path_to_try[index].keys[0].split(":").second
537
536
  end
538
537
  end
@@ -544,7 +543,7 @@ def try_path(path_to_try)
544
543
  user[session_index] = find_next_user(root_path, session)
545
544
  end
546
545
  else
547
- user[session_index] = Kernel.const_get(user_inputs("user_class")).find(id)
546
+ user[session_index] = AutoTest::Authentication.user_class.find(id)
548
547
  end
549
548
  if user[session_index] == false then
550
549
  return error_not_found
@@ -588,15 +587,15 @@ end
588
587
  def find_next_user(root_path, session)
589
588
  index = 0
590
589
  u = 0
591
- user_size = Kernel.const_get(user_inputs("user_class")).find(:all).size
590
+ user_size = AutoTest::Authentication.user_class.find(:all).size
592
591
  while u < user_size do
593
- user = Kernel.const_get(user_inputs("user_class")).find(:first, :conditions => "id > #{index}")
592
+ user = AutoTest::Authentication.user_class.find(:first, :conditions => "id > #{index}")
594
593
  index = user.id
595
- session.visit user_inputs("get_login_path")
596
- user_inputs("get_login_attributes").each do |la|
594
+ session.visit AutoTest::Authentication.get_login_path
595
+ AutoTest::Authentication.get_login_attributes.each do |la|
597
596
  session.fill_in la[1], :with => user.send(la[0].to_sym)
598
597
  end
599
- session.click_button user_inputs("get_login_button")
598
+ session.click_button AutoTest::Authentication.get_login_button
600
599
  if session.current_path == root_path then
601
600
  return user
602
601
  end
@@ -710,12 +709,8 @@ def add_to_sessions_array(session)
710
709
  end
711
710
 
712
711
  def clean_and_seed_db
713
- DatabaseCleaner.strategy = :truncation
714
- DatabaseCleaner.start
715
712
  DatabaseCleaner.clean
716
- if user_inputs("use_fixtures") then
717
- fixtures(*user_inputs("get_fixtures"))
718
- end
713
+ DatabaseCleaner.start
719
714
  load "#{Rails.root}/db/test_seeds.rb"
720
715
  end
721
716
 
@@ -729,38 +724,6 @@ def err_message
729
724
  @err_message
730
725
  end
731
726
 
732
- def init_user_inputs
733
- @user_inputs = Hash.new
734
- file = File.new("#{Rails.root}/log/user_input.log", "r")
735
- while line = file.gets do
736
- b = line.split(/:/,2)
737
- @user_inputs["#{b[0].strip}"] = b[1].chop
738
- end
739
- @user_inputs.each do |k,v|
740
- if v.start_with? "[" then
741
- x = v.split("],[")
742
- result = []
743
- x.each do |i|
744
- result << i.delete("[]\"").split(",")
745
- end
746
- result.each do |r|
747
- if r.class == String then
748
- r.strip!
749
- else
750
- r.each do |s|
751
- s.strip!
752
- end
753
- end
754
- end
755
- @user_inputs[k] = result
756
- end
757
- end
758
- end
759
-
760
- def user_inputs(key)
761
- @user_inputs[key]
762
- end
763
-
764
727
  def path
765
728
  @path
766
729
  end
@@ -1,16 +1,17 @@
1
1
  require "watir-webdriver"
2
2
  require 'spec_helper'
3
+ require 'auto_test'
4
+
3
5
 
4
6
  describe "Application" do
5
7
  describe "auto_test" do
8
+
9
+ if AutoTest::Test.use_fixtures? then
10
+ fixtures(*AutoTest::Test.get_fixtures)
11
+ end
6
12
  it "simulates the error" do
7
- init_user_inputs
8
13
  load "#{Rails.root}/db/test_seeds.rb"
9
- if user_inputs("use_fixtures") then
10
- fixtures(*user_inputs("get_fixtures"))
11
- end
12
- init_path
13
- init_sessions_array
14
+ sessions_array = []
14
15
  puts "Firefox is getting started..."
15
16
  begin
16
17
  paths = File.new("#{Rails.root}/log/new_path.log", "r")
@@ -20,25 +21,25 @@ describe "Application" do
20
21
  home = "localhost:3002"
21
22
  sessions = search_sessions
22
23
  number_of_sessions = sessions.size
23
- user = Array.new(user_inputs("get_number_of_sessions").to_i)
24
+ user = Array.new(AutoTest::Test.get_number_of_sessions.to_i)
24
25
  for i in 0..number_of_sessions-1 do
25
26
  browser = Watir::Browser.new :ff
26
- add_to_sessions_array(sessions[i], browser)
27
+ sessions_array[sessions[i]] = browser
27
28
  end
28
29
  while line = paths.gets do
29
30
  if !line.chop!.end_with? "ID" then
30
31
  hash = Hash.new
31
32
  a = line.gsub!(/[{}\"]/,'').split(/\=\>/)
32
- session = get_sessions_array[a[0].split(":").first.to_i]
33
- session_index = get_sessions_array.index(session)
33
+ session = sessions_array[a[0].split(":").first.to_i]
34
+ session_index = sessions_array.index(session)
34
35
  session.windows.first.use
35
- if a[0].split(":").second == user_inputs("get_login_path") then
36
- session.goto home + user_inputs("get_login_path")
36
+ if a[0].split(":").second == AutoTest::Authentication.get_login_path then
37
+ session.goto home + AutoTest::Authentication.get_login_path
37
38
  hash["#{a[0]}"] = a[1]
38
- login(user_inputs("get_login_attributes"), session, user[session_index].class.find(user[session_index].id))
39
- elsif a[1] == user_inputs("get_logout_path") then
40
- hash["#{a[0]}"] = user_inputs("get_logout_path")
41
- session.goto home + user_inputs("get_logout_path")
39
+ login(session, user[session_index].class.find(user[session_index].id))
40
+ elsif a[1] == AutoTest::Authentication.get_logout_path then
41
+ hash["#{a[0]}"] = AutoTest::Authentication.get_logout_path
42
+ session.goto home + AutoTest::Authentication.get_logout_path
42
43
  elsif a[1][0] == "[" then
43
44
  texts = []
44
45
  inputs = a[1][1,a[1].size-2].split(/,/)
@@ -72,102 +73,49 @@ describe "Application" do
72
73
  end
73
74
  hash["#{a[0]}"] = a[1]
74
75
  end
75
- add_path(hash)
76
76
  sleep 2
77
77
  else
78
- add_path(line)
79
78
  line_parts = line.split(":")
80
79
  session_index = line_parts[0].to_i
81
80
  id = line_parts[1].to_i
82
81
  # get the Constant from the String, to find the right class
83
- user[session_index] = Kernel.const_get(user_inputs("user_class")).find(id)
82
+ user[session_index] = AutoTest::Authentication.user_class.find(id)
84
83
  end
85
84
  end
86
85
  end
87
86
  end
88
87
  end
89
88
 
90
- def login(login_attributes, browser, user)
91
- if user_inputs("use_db_users") then
92
- user_inputs("get_login_attributes").each do |field|
93
- browser.text_field(:label => field[1]).set user.send(field[0].to_sym)
89
+ def login(browser, user)
90
+ if AutoTest::Authentication.use_db_users then
91
+ Authentication.get_login_attributes.each do |field|
92
+ browser.text_field(:id => field[1]).set user.send(field[0].to_sym)
94
93
  end
95
94
  sleep 1
96
95
  else
97
- index = user_inputs("get_login_names").index(user_inputs("get_unique_login_attribute_name"))
96
+ index = AutoTest::Authentication.get_login_names.index(AutoTest::Authentication.get_unique_login_attribute_name)
97
+ user_data = nil
98
98
  user.class.find(:all).each do |u|
99
- user_inputs("get_login_data").each do |d|
100
- if d[index] == u.send(user_inputs("get_unique_login_attribute_name").to_sym) then
101
- user_data = user_inputs("get_login_data")[index]
99
+ AutoTest::Authentication.get_login_data.each do |d|
100
+ if d[index] == u.send(AutoTest::Authentication.get_unique_login_attribute_name.to_sym) then
101
+ user_data = AutoTest::Authentication.get_login_data[index]
102
102
  end
103
103
  end
104
104
  end
105
- user_inputs("get_login_attributes").each_with_index do |field, i|
106
- browser.text_field(:label => field[1]).set user_data[i]
105
+ AutoTest::Authentication.get_login_fields.each_with_index do |field, i|
106
+ browser.text_field(:id => field).set user_data[i]
107
107
  end
108
108
  end
109
109
  sleep 2
110
110
  browser.button(:type => 'submit').click
111
111
  end
112
112
 
113
- def init_user_inputs
114
- @user_inputs = Hash.new
115
- file = File.new("log/user_input.log", "r")
116
- while line = file.gets do
117
- b = line.split(/:/,2)
118
- @user_inputs["#{b[0].strip}"] = b[1].chop
119
- end
120
- @user_inputs.each do |k,v|
121
- if v.start_with? "[" then
122
- x = v.split("],[")
123
- result = []
124
- x.each do |i|
125
- result << i.delete("[]\"").split(",")
126
- end
127
- result.each do |r|
128
- if r.class == String then
129
- r.strip!
130
- else
131
- r.each do |s|
132
- s.strip!
133
- end
134
- end
135
- end
136
- @user_inputs[k] = result
137
- end
138
- end
139
- end
140
-
141
- def user_inputs(key)
142
- @user_inputs[key]
143
- end
144
-
145
- def get_sessions_array
146
- @sessions_array
147
- end
148
-
149
- def init_sessions_array
150
- @sessions_array = []
151
- end
152
-
153
- def add_to_sessions_array(i,session)
154
- @sessions_array[i] = session
155
- end
156
-
157
- def path
158
- @path
159
- end
160
-
161
- def init_path
162
- @path = []
163
- end
164
-
165
- def add_path(value)
166
- @path << value
167
- end
168
-
169
113
  def search_sessions
170
- path_to_search = File.new("#{Rails.root}/log/new_path.log")
114
+ begin
115
+ path_to_search = File.new("#{Rails.root}/log/new_path.log", "r")
116
+ rescue
117
+ path_to_search = File.new("#{Rails.root}/log/paths.log","r")
118
+ end
171
119
  sessions = Array.new
172
120
  while line = path_to_search.gets do
173
121
  line.gsub!(/[{}\"]/,'')
@@ -31,7 +31,6 @@ namespace :auto_test do
31
31
  task :reduce_errors do
32
32
  puts "Reducing the error path, this could take a while..."
33
33
  sh "rspec #{path}/spec/requests/error_reduction_spec.rb -o '#{path}/../log/reduce_err.txt'"
34
- sh "rm '#{path}/../log/reduce_err.txt'"
35
34
  Rake::Task["auto_test:start_action_path"].invoke
36
35
  end
37
36
 
data/lib/test.rb CHANGED
@@ -314,29 +314,6 @@ module AutoTest
314
314
  @@no_session_links
315
315
  end
316
316
 
317
- def write_user_input_to_file
318
- f = File.new("#{Rails.root}/log/user_input.log", "w")
319
- if Test.no_auth then
320
- f.puts("get_number_of_test_runs:#{get_number_of_test_runs}
321
- get_number_of_sessions:#{get_number_of_sessions}")
322
- else
323
- f.puts("get_number_of_test_runs:#{get_number_of_test_runs}
324
- use_fixtures:#{use_fixtures}
325
- get_login_path:#{Authentication.get_login_path}
326
- #{if use_fixtures? then 'get_fixtures'+get_fixtures end}
327
- get_logout_path:#{Authentication.get_logout_path}
328
- get_login_button:#{Authentication.get_login_button}
329
- get_login_attributes:#{Authentication.get_login_attributes}
330
- get_number_of_sessions:#{get_number_of_sessions}
331
- get_login_data:#{Authentication.get_login_data}
332
- get_login_names:#{Authentication.get_login_names}
333
- get_unique_login_attribute_name:#{Authentication.get_unique_login_attribute_name}
334
- use_db_users:#{Authentication.use_db_users}
335
- user_class:#{Authentication.user_class}")
336
- end
337
- f.close
338
- end
339
-
340
317
  end
341
318
 
342
319
  autoload :Authentication, 'authentication'
data/lib/test_starter.rb CHANGED
@@ -2,7 +2,6 @@ class TestStarter
2
2
  include AutoTest
3
3
  # method to start the test and handle errors
4
4
  def test
5
- Test.write_user_input_to_file
6
5
  for j in 1..Test.get_number_of_test_runs do
7
6
  Test.run = j
8
7
  if !Test.stop?
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: auto_test
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.9.8
5
+ version: 0.1.9.8.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Maike Hargens
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-10-24 00:00:00 Z
13
+ date: 2012-10-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faker