auto_test 0.1.9.8.6 → 0.1.9.8.7

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.
@@ -1,3 +1,3 @@
1
1
  module AutoTest
2
- VERSION = "0.1.9.8.6"
2
+ VERSION = "0.1.9.8.7"
3
3
  end
@@ -19,7 +19,7 @@ namespace :auto_test do
19
19
  task :error_calc do
20
20
  err = File.read("#{Rails.root}/log/errors.log")
21
21
  if err.to_i > 0 then
22
- puts "Do you want to see the error-path in firefox? Type yes/no:"
22
+ puts "Do you want to reduce the error-path to see it in firefox? Type yes/no:"
23
23
  a = STDIN.gets.chomp
24
24
  if a == "yes" then
25
25
  Rake::Task["auto_test:reduce_errors"].invoke
@@ -29,14 +29,14 @@ namespace :auto_test do
29
29
 
30
30
  desc "Reducing the error path"
31
31
  task :reduce_errors do
32
- puts "Reducing the error path, this could take a while..."
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
34
  Rake::Task["auto_test:start_action_path"].invoke
35
35
  end
36
36
 
37
37
  desc "starting the simulation"
38
38
  task :start_action_path do
39
- puts "Press Enter to see the path in Firefox! "
39
+ puts "Press Enter to see the error-path in Firefox! "
40
40
  server = true
41
41
  while STDIN.gets == "\n" do
42
42
  if server then
data/lib/test.rb CHANGED
@@ -9,6 +9,7 @@ module AutoTest
9
9
  init_fixtures
10
10
  init_action_path
11
11
  init_links
12
+ init_links
12
13
  init_depth
13
14
  init_inputs
14
15
  init_always_present
@@ -19,6 +20,10 @@ module AutoTest
19
20
  init_number_of_test_runs
20
21
  end
21
22
 
23
+ def init_links
24
+ @@links = []
25
+ end
26
+
22
27
  def init_fixtures
23
28
  @@use_fixtures = false
24
29
  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.1.9.8.6
5
+ version: 0.1.9.8.7
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-28 00:00:00 Z
13
+ date: 2012-11-09 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faker
@@ -101,7 +101,6 @@ files:
101
101
  - lib/dsl.rb
102
102
  - lib/error.rb
103
103
  - lib/page.rb
104
- - lib/simulation.rb
105
104
  - lib/spec/requests/auto_spec.rb
106
105
  - lib/spec/requests/error_reduction_spec.rb
107
106
  - lib/spec/requests/simulation_spec.rb
data/lib/simulation.rb DELETED
@@ -1,174 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV["RAILS_ENV"] ||= "test"
3
- #require File.expand_path("config/environment", __FILE__)
4
- require "watir-webdriver"
5
-
6
- def login(login_attributes, browser, user)
7
- if user_inputs("use_db_users") then
8
- user_inputs("get_login_attributes").each do |field|
9
- browser.text_field(:label => field[1]).set user.send(field[0].to_sym)
10
- end
11
- sleep 1
12
- else
13
- index = user_inputs("get_login_names").index(user_inputs("get_unique_login_attribute_name"))
14
- user.class.find(:all).each do |u|
15
- user_inputs("get_login_data").each do |d|
16
- if d[index] == u.send(user_inputs("get_unique_login_attribute_name").to_sym) then
17
- user_data = user_inputs("get_login_data")[index]
18
- end
19
- end
20
- end
21
- user_inputs("get_login_attributes").each_with_index do |field, i|
22
- browser.text_field(:label => field[1]).set user_data[i]
23
- end
24
- end
25
- sleep 2
26
- browser.button(:type => 'submit').click
27
- end
28
-
29
- def init_user_inputs
30
- @user_inputs = Hash.new
31
- file = File.new("log/user_input.log", "r")
32
- while line = file.gets do
33
- b = line.split(/:/,2)
34
- @user_inputs["#{b[0].strip}"] = b[1].chop
35
- end
36
- @user_inputs.each do |k,v|
37
- if v.start_with? "[" then
38
- x = v.split("],[")
39
- result = []
40
- x.each do |i|
41
- result << i.delete("[]\"").split(",")
42
- end
43
- result.each do |r|
44
- if r.class == String then
45
- r.strip!
46
- else
47
- r.each do |s|
48
- s.strip!
49
- end
50
- end
51
- end
52
- @user_inputs[k] = result
53
- end
54
- end
55
- end
56
-
57
- def user_inputs(key)
58
- @user_inputs[key]
59
- end
60
-
61
- def get_sessions_array
62
- @sessions_array
63
- end
64
-
65
- def init_sessions_array
66
- @sessions_array = []
67
- end
68
-
69
- def add_to_sessions_array(i,session)
70
- @sessions_array[i] = session
71
- end
72
-
73
- def path
74
- @path
75
- end
76
-
77
- def init_path
78
- @path = []
79
- end
80
-
81
- def add_path(value)
82
- @path << value
83
- end
84
-
85
- def search_sessions
86
- path_to_search = File.new("#{gem_path}/../../log/new_path.log")
87
- sessions = Array.new
88
- while line = path_to_search.gets do
89
- line.gsub!(/[{}\"]/,'')
90
- if line.class == String then
91
- session = line.split(":").first.to_i
92
- else
93
- session = line.gsub!(/[{}\"]/,'').split(":").first.to_i
94
- end
95
- if !(sessions.include? session) then
96
- sessions << session
97
- end
98
- end
99
- return sessions
100
- end
101
-
102
-
103
- load "#{Rails.root}/db/test_seeds.rb"
104
- init_path
105
- init_sessions_array
106
- init_user_inputs
107
- puts "Firefox is getting started..."
108
- paths = File.new("#{Rails.root}/log/new_path.log", "r")
109
- home = "localhost:3002"
110
- sessions = search_sessions
111
- number_of_sessions = sessions.size
112
- user = Array.new(user_inputs("get_number_of_sessions").to_i)
113
- for i in 0..number_of_sessions-1 do
114
- browser = Watir::Browser.new :ff
115
- add_to_sessions_array(sessions[i], browser)
116
- end
117
- while line = paths.gets do
118
- if !line.chop!.end_with? "ID" then
119
- hash = Hash.new
120
- a = line.gsub!(/[{}\"]/,'').split(/\=\>/)
121
- session = get_sessions_array[a[0].split(":").first.to_i]
122
- session_index = get_sessions_array.index(session)
123
- session.windows.first.use
124
- if a[0].split(":").second == user_inputs("get_login_path") then
125
- session.goto home + user_inputs("get_login_path")
126
- hash["#{a[0]}"] = a[1]
127
- login(user_inputs("get_login_attributes"), session, user[session_index].class.find(user[session_index].id))
128
- elsif a[1] == user_inputs("get_logout_path") then
129
- hash["#{a[0]}"] = user_inputs("get_logout_path")
130
- session.goto home + user_inputs("get_logout_path")
131
- elsif a[1][0] == "[" then
132
- texts = []
133
- inputs = a[1][1,a[1].size-2].split(/,/)
134
- i = 0
135
- while i < inputs.size do
136
- texts << inputs[i].strip
137
- texts << inputs[i+1].strip
138
- if inputs[i].strip.start_with? "radio___" then
139
- session.radio(:name => inputs[i].gsub("radio___",'').strip,:value=> inputs[i + 1].strip).set
140
- elsif inputs[i].strip.start_with? "select___" then
141
- session.select_list(:id => inputs[i].gsub("select___",'').strip).select(inputs[i + 1].strip)
142
- elsif inputs[i].strip.start_with? "checkbox___" then
143
- session.checkbox(:name => inputs[i].gsub("checkbox___",'').strip, :value => inputs[i + 1].strip).set
144
- else
145
- session.text_field(:name => inputs[i].strip).flash
146
- session.text_field(:name => inputs[i].strip).set inputs[i+1].strip
147
- end
148
- i = i + 2
149
- end
150
- hash["#{a[0]}"] = texts
151
- session.button(:type => "submit").click
152
- else
153
- link = a[1].split(/\+\+\+/)
154
- href = link[0]
155
- text = link[1]
156
- session.a(:href => href, :text => text).flash
157
- session.a(:href => href, :text => text).click
158
- begin
159
- session.driver.switch_to.alert.accept
160
- rescue
161
- end
162
- hash["#{a[0]}"] = a[1]
163
- end
164
- add_path(hash)
165
- sleep 2
166
- else
167
- add_path(line)
168
- line_parts = line.split(":")
169
- session_index = line_parts[0].to_i
170
- id = line_parts[1].to_i
171
- # get the Constant from the String, to find the right class
172
- user[session_index] = Kernel.const_get(user_inputs("user_class")).find(id)
173
- end
174
- end